Re: [patch 00/10] mount ownership and unprivileged mount syscall (v8)
On Thu, Feb 14, 2008 at 10:21:03PM -0800, Andrew Morton wrote: Linus has just merged all the VFS renaming patches, so the decks are clear for looking at this work. However David and Christoph are beavering away on the r-o-bind-mounts patches and I expect that there will be overlaps with unprivileged mounts. Could we coordinate things a bit please? Decide who goes first, review and maybe even test each others work, etc? Al is setting up a git tree for VFS work. per-mount r/o will go in as one of the first things, aswell as his rework of the path lookup logic to fix the intents mess. Thanks. ---end quoted text--- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 00/10] mount ownership and unprivileged mount syscall (v8)
On Fri, 15 Feb 2008 04:01:20 -0500 Christoph Hellwig [EMAIL PROTECTED] wrote: On Thu, Feb 14, 2008 at 10:21:03PM -0800, Andrew Morton wrote: Linus has just merged all the VFS renaming patches, so the decks are clear for looking at this work. However David and Christoph are beavering away on the r-o-bind-mounts patches and I expect that there will be overlaps with unprivileged mounts. Could we coordinate things a bit please? Decide who goes first, review and maybe even test each others work, etc? Al is setting up a git tree for VFS work. per-mount r/o will go in as one of the first things, aswell as his rework of the path lookup logic to fix the intents mess. That didn't answer my question.. - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 00/10] mount ownership and unprivileged mount syscall (v8)
On Fri, Feb 15, 2008 at 01:09:51AM -0800, Andrew Morton wrote: However David and Christoph are beavering away on the r-o-bind-mounts patches and I expect that there will be overlaps with unprivileged mounts. Could we coordinate things a bit please? Decide who goes first, review and maybe even test each others work, etc? Al is setting up a git tree for VFS work. per-mount r/o will go in as one of the first things, aswell as his rework of the path lookup logic to fix the intents mess. That didn't answer my question.. Well, Al as the defacto VFS maintainer will decide on the ordering. Reviewing this stuff properly is still on my todo list, but currently I'm busy with more important things. - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: i_version changes
Peter Staubach a écrit : Few month ago, I ran a FFSB test on a 2.6.23 kernel enabling or not the i_version flag. http://bullopensource.org/ext4/20071116/ffsb-write.html This is good information. A couple of questions -- what is the -I 256 option used for the ext4 mkfs? This option force the inode size to 256Bytes instead of 128. The requirement is to have a 64bits i_version counter, therefore the ext4 inode as to be extended to 256Bytes. What was the variance between the results of the 5 runs? Is 2% significant or not? I didn't keep the raw results, but they were all very close to the average (less than 1% of the average). - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] ext3 freeze feature
Hi, Christoph Hellwig wrote: On Fri, Feb 08, 2008 at 08:26:57AM -0500, Andreas Dilger wrote: You may as well make the common ioctl the same as the XFS version, both by number and parameters, so that applications which already understand the XFS ioctl will work on other filesystems. Yes. In facy you should be able to lift the implementations of XFS_IOC_FREEZE and XFS_IOC_THAW to generic code, there's nothing XFS-specific in there. According to Documentation/ioctl-number.txt, XFS_IOC_XXXs (_IOWR('X', aa, bb)) are defined for XFS like below. From Documentation/ioctl-number.txt: CodeSeq#Include FileComments : : 'X' all linux/xfs_fs.h So XFS_IOC_FREEZE and XFS_IOC_THAW cannot be lifted to generic code simply. I think we should create new generic numbers for freeze and thaw like FIBMAP as followings. linux/fs.h: #define FIFREEZE _IO(0x00,3) #define FITHAW _IO(0x00,4) And xfs_freeze calls XFS_IOC_FREEZE with a magic number 1, but what is 1? Instead, I'd like the sec to timeout on freeze API in order to thaw the filesystem automatically. It can prevent a filesystem from staying frozen forever. (Because a freezer may cause a deadlock by accessing the frozen filesystem.) Any comments are very welcome. Cheers, Takashi - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] ext3 freeze feature
Takashi Sato wrote: Hi, Christoph Hellwig wrote: On Fri, Feb 08, 2008 at 08:26:57AM -0500, Andreas Dilger wrote: You may as well make the common ioctl the same as the XFS version, both by number and parameters, so that applications which already understand the XFS ioctl will work on other filesystems. Yes. In facy you should be able to lift the implementations of XFS_IOC_FREEZE and XFS_IOC_THAW to generic code, there's nothing XFS-specific in there. According to Documentation/ioctl-number.txt, XFS_IOC_XXXs (_IOWR('X', aa, bb)) are defined for XFS like below. From Documentation/ioctl-number.txt: CodeSeq#Include FileComments : : 'X' all linux/xfs_fs.h It also says: 'f' 00-1F linux/ext2_fs.h and yet include/linux.h has: #define FS_IOC_GETFLAGS _IOR('f', 1, long) #define FS_IOC_SETFLAGS _IOW('f', 2, long) as generic vfs ioctls. These ioctls started out as EXT2_IOC_SETFLAGS/EXT2_IOC_GETFLAGS but they were generically useful, other filesystems picked them up, and they were elevated to the vfs. So XFS_IOC_FREEZE and XFS_IOC_THAW cannot be lifted to generic code simply. It would be a simple matter of changing the documentation, I think. I think we should create new generic numbers for freeze and thaw like FIBMAP as followings. linux/fs.h: #define FIFREEZE _IO(0x00,3) #define FITHAW _IO(0x00,4) And xfs_freeze calls XFS_IOC_FREEZE with a magic number 1, but what is 1? Looks like it's called level but it's probably a holdover, it doesn't look like it's used. Instead, I'd like the sec to timeout on freeze API in order to thaw the filesystem automatically. It can prevent a filesystem from staying frozen forever. (Because a freezer may cause a deadlock by accessing the frozen filesystem.) I'm still not very comfortable with the timeout; if you un-freeze on a timer, how do you know that the work for which you needed the fileystem frozen is complete? How would you know if your snapshot was good if there's a possibility that the fs unfroze while it was being taken? Thanks, -Eric Any comments are very welcome. Cheers, Takashi - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [linux-cifs-client] review 5, was Re: projected date for mount.cifs to support DFS junction points
Sorry guys, but I have a lot of work for the last 3 weeks, so I couldn't spare much time for a hobby and react quickly. Here is what I've done the last weekend. Attached: fixed patch [5/5] (0001-DFS-patch-that-connects-inode-with-dfs-handling-ops.patch). fixed mixed case in struct member (0002-Fixed-mixed-case-name-in-structure-dfs_info3_param.patch) Also I noticed that patch 2/5 is not completely applied yet. I'll send Steve interim patch I've made to make thing compiled and working. Christoph Hellwig wrote: +#ifdef CONFIG_CIFS_DFS_UPCALL + if (is_remote) { + inode-i_op = + cifs_dfs_referral_inode_operations; + inode-i_fop = NULL; i_fop should never be set to NULL. Just leave it alone so it stays at empty_fops. +#ifdef CONFIG_CIFS_DFS_UPCALL + if (is_remote) { + inode-i_op = + cifs_dfs_referral_inode_operations; + inode-i_fop = NULL; + } else { + inode-i_op = cifs_dir_inode_ops; + inode-i_fop = cifs_dir_ops; + } +#else inode-i_op = cifs_dir_inode_ops; inode-i_fop = cifs_dir_ops; +#endif This code and everything surrounding it is duplicated in two functions. Please refactor it into a common helper before adding new code to it. ___ linux-cifs-client mailing list [EMAIL PROTECTED] https://lists.samba.org/mailman/listinfo/linux-cifs-client . -- Best regards, - Igor Mammedov, niallain at gmail.com From 490ed5e40713206bf3011880b03cd9f5766b5467 Mon Sep 17 00:00:00 2001 From: Igor Mammedov [EMAIL PROTECTED] Date: Fri, 15 Feb 2008 19:31:42 +0300 Subject: [PATCH] DFS patch that connects inode with dfs handling ops if it is DFS junction point. DFS junction point is detected by EREMOTE error from CIFSSMBQPathInfo.Then we need to request server again, this time with full path name so we could get correct info for this inode. It is final DFS patch that gets all patchset working and it depends on all previous DFS patches. Signed-off-by: Igor Mammedov [EMAIL PROTECTED] --- fs/cifs/cifs_dfs_ref.c | 10 + fs/cifs/cifsfs.h | 11 ++ fs/cifs/inode.c| 93 +--- 3 files changed, 62 insertions(+), 52 deletions(-) diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c index 413ee23..3161986 100644 --- a/fs/cifs/cifs_dfs_ref.c +++ b/fs/cifs/cifs_dfs_ref.c @@ -29,6 +29,16 @@ LIST_HEAD(cifs_dfs_automount_list); * DFS functions */ +void cifs_dfs_ref_inode_op_fixup(int is_remote, struct inode *inode) +{ + if (is_remote) { + inode-i_op = cifs_dfs_referral_inode_operations; + } else { + inode-i_op = cifs_dir_inode_ops; + inode-i_fop = cifs_dir_ops; + } +} + void dfs_shrink_umount_helper(struct vfsmount *vfsmnt) { mark_mounts_for_expiry(cifs_dfs_automount_list); diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 195b14d..d693e2d 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h @@ -91,6 +91,17 @@ extern int cifs_dir_notify(struct file *, unsigned long arg); extern struct dentry_operations cifs_dentry_ops; extern struct dentry_operations cifs_ci_dentry_ops; +#ifdef CONFIG_CIFS_DFS_UPCALL +extern void cifs_dfs_ref_inode_op_fixup(int is_remote, struct inode *inode); +#else +static inline void cifs_dfs_ref_inode_op_fixup(int is_remote, + struct inode *inode) +{ + inode-i_op = cifs_dir_inode_ops; + inode-i_fop = cifs_dir_ops; +} +#endif /* DFS_UPCALL */ + /* Functions related to symlinks */ extern void *cifs_follow_link(struct dentry *direntry, struct nameidata *nd); extern void cifs_put_link(struct dentry *direntry, diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 6020add..79e61c5 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -37,7 +37,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, struct cifsTconInfo *pTcon; struct inode *inode; struct cifs_sb_info *cifs_sb = CIFS_SB(sb); - char *tmp_path; + int is_remote = 0; pTcon = cifs_sb-tcon; cFYI(1, (Getting info on %s, search_path)); @@ -48,30 +48,10 @@ int cifs_get_inode_info_unix(struct inode **pinode, /* dump_mem(\nUnixQPathInfo return data, findData, sizeof(findData)); */ if (rc) { - if (rc == -EREMOTE) { - tmp_path = - kmalloc(strnlen(pTcon-treeName, - MAX_TREE_SIZE + 1) + -strnlen(search_path, MAX_PATHCONF) + 1, -GFP_KERNEL); - if (tmp_path == NULL) -return -ENOMEM; - - /* have to skip first of the double backslash of - UNC name */ - strncpy(tmp_path, pTcon-treeName, MAX_TREE_SIZE); - strncat(tmp_path, search_path, MAX_PATHCONF); - rc = connect_to_dfs_path(xid, pTcon-ses, - /* treename + */ tmp_path, -
Re: [linux-cifs-client] review 5, was Re: projected date for mount.cifs to support DFS junction points
On Fri, Feb 15, 2008 at 07:37:35PM +0300, Q (Igor Mammedov) wrote: Sorry guys, but I have a lot of work for the last 3 weeks, so I couldn't spare much time for a hobby and react quickly. No problem. I know this problem very well as almost all of my core kernel contributions are spare time as well. Thanks for keeping up the work. Here is what I've done the last weekend. Attached: fixed patch [5/5] (0001-DFS-patch-that-connects-inode-with-dfs-handling-ops.patch). fixed mixed case in struct member (0002-Fixed-mixed-case-name-in-structure-dfs_info3_param.patch) The second one is trivially correct and should be pushed to Linus asap as small cleanup. Patch 1 is not exactly what I had in mind, I was thinking about factoring out the common bits of cifs-cifs_get_inode_info and cifs-cifs_get_inode_info_unix to avoid having all the logic to set the various options twice. I've attached two quick and untested patches showing what I mean. I think in this case having the ifdef for that two line statement setting the inode operations here is fine. But thinking about it I'm not even sure if it's good idea to make dfs support conditional. Any reason it can't just be included unconditionally? Index: linux-2.6/fs/cifs/inode.c === --- linux-2.6.orig/fs/cifs/inode.c 2008-02-15 17:44:48.0 +0100 +++ linux-2.6/fs/cifs/inode.c 2008-02-15 17:52:04.0 +0100 @@ -29,6 +29,46 @@ #include cifs_debug.h #include cifs_fs_sb.h + +static void cifs_set_ops(struct inode *inode) +{ + struct cifs_sb_info *cifs_sb = CIFS_SB(inode-i_sb); + + switch (inode-i_mode S_IFMT) { + case S_IFREG: + inode-i_op = cifs_file_inode_ops; + if (cifs_sb-mnt_cifs_flags CIFS_MOUNT_DIRECT_IO) { + if (cifs_sb-mnt_cifs_flags CIFS_MOUNT_NO_BRL) + inode-i_fop = cifs_file_direct_nobrl_ops; + else + inode-i_fop = cifs_file_direct_ops; + } else if (cifs_sb-mnt_cifs_flags CIFS_MOUNT_NO_BRL) + inode-i_fop = cifs_file_nobrl_ops; + else { /* not direct, send byte range locks */ + inode-i_fop = cifs_file_ops; + } + + + /* check if server can support readpages */ + if (cifs_sb-tcon-ses-server-maxBuf + PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) + inode-i_data.a_ops = cifs_addr_ops_smallbuf; + else + inode-i_data.a_ops = cifs_addr_ops; + break; + case S_IFDIR: + inode-i_op = cifs_dir_inode_ops; + inode-i_fop = cifs_dir_ops; + break; + case S_IFLNK: + inode-i_op = cifs_symlink_inode_ops; + break; + default: + init_special_inode(inode, inode-i_mode, inode-i_rdev); + break; + } +} + int cifs_get_inode_info_unix(struct inode **pinode, const unsigned char *search_path, struct super_block *sb, int xid) { @@ -178,39 +218,8 @@ int cifs_get_inode_info_unix(struct inod cFYI(1, (Size %ld and blocks %llu, (unsigned long) inode-i_size, (unsigned long long)inode-i_blocks)); - if (S_ISREG(inode-i_mode)) { - cFYI(1, (File inode)); - inode-i_op = cifs_file_inode_ops; - if (cifs_sb-mnt_cifs_flags CIFS_MOUNT_DIRECT_IO) { - if (cifs_sb-mnt_cifs_flags CIFS_MOUNT_NO_BRL) - inode-i_fop = - cifs_file_direct_nobrl_ops; - else - inode-i_fop = cifs_file_direct_ops; - } else if (cifs_sb-mnt_cifs_flags CIFS_MOUNT_NO_BRL) - inode-i_fop = cifs_file_nobrl_ops; - else /* not direct, send byte range locks */ - inode-i_fop = cifs_file_ops; - - /* check if server can support readpages */ - if (pTcon-ses-server-maxBuf - PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) - inode-i_data.a_ops = cifs_addr_ops_smallbuf; - else - inode-i_data.a_ops = cifs_addr_ops; - } else if (S_ISDIR(inode-i_mode)) { - cFYI(1, (Directory inode)); - inode-i_op = cifs_dir_inode_ops; - inode-i_fop = cifs_dir_ops; - } else if (S_ISLNK(inode-i_mode)) { - cFYI(1, (Symbolic Link inode)); - inode-i_op = cifs_symlink_inode_ops; - /*
Re: [linux-cifs-client] review 5, was Re: projected date for mount.cifs to support DFS junction points
On 2/15/08, Christoph Hellwig [EMAIL PROTECTED] wrote: On Fri, Feb 15, 2008 at 07:37:35PM +0300, Q (Igor Mammedov) wrote: Here is what I've done the last weekend. Attached: fixed patch [5/5] (0001-DFS-patch-that-connects-inode-with-dfs-handling-ops.patch). Not merged yet. fixed mixed case in struct member 0002-Fixed-mixed-case-name-in-structure-dfs_info3_param.patch) Now merged into cifs-2.6.git The second one is trivially correct and should be pushed to Linus asap as small cleanup. Patch 1 is not exactly what I had in mind, I was thinking about factoring out the common bits of cifs-cifs_get_inode_info and cifs-cifs_get_inode_info_unix to avoid having all the logic to set the various options twice. I've attached two quick and untested patches showing what I mean. I think in this case having the ifdef for that two line statement setting the inode operations here is fine. I reviewed and merged into cifs-2.6.git one of the two patches from Christoph (the cifs_set_ops one), but wanted to look more carefully at the other (cifs_get_info_remote) to make sure that buf was being freed in the cifs_get_inode_info path (otherwise it is fine). But thinking about it I'm not even sure if it's good idea to make dfs support conditional. Any reason it can't just be included unconditionally? It would make the code slightly smaller (perhaps useful someday for OLPC or embedded) and removes a piece of code that is not needed in all home networks (although DFS is useful even to some of these). I lean toward removing the ifdef when it has made it through one or two more release cycles and is no longer experimental. SInce there are a few experimental features (Kerberos and DFS) that are broadly useful - but not all users need both, I don't mind keeping the configure for each different for the short term but don't have a strong opinion on this. -- Thanks, Steve - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [linux-cifs-client] review 5, was Re: projected date for mount.cifs to support DFS junction points
If you like these kind of consolidation patches here's another one: Index: linux-2.6/fs/cifs/inode.c === --- linux-2.6.orig/fs/cifs/inode.c 2008-02-15 22:46:08.0 +0100 +++ linux-2.6/fs/cifs/inode.c 2008-02-15 23:09:28.0 +0100 @@ -98,6 +98,90 @@ static int cifs_get_inode_info_remote(st return rc; } +static void cifs_unix_info_to_inode(struct inode *inode, + FILE_UNIX_BASIC_INFO *info, int force_uid_gid) +{ + struct cifs_sb_info *cifs_sb = CIFS_SB(inode-i_sb); + struct cifsInodeInfo *cifsInfo = CIFS_I(inode); + __u64 num_of_bytes = le64_to_cpu(info-NumOfBytes); + __u64 end_of_file = le64_to_cpu(info-EndOfFile); + + inode-i_atime = cifs_NTtimeToUnix(le64_to_cpu(info-LastAccessTime)); + inode-i_mtime = + cifs_NTtimeToUnix(le64_to_cpu(info-LastModificationTime)); + inode-i_ctime = cifs_NTtimeToUnix(le64_to_cpu(info-LastStatusChange)); + inode-i_mode = le64_to_cpu(info-Permissions); + + /* +* Since we set the inode type below we need to mask off +* to avoid strange results if bits set above. +*/ + inode-i_mode = ~S_IFMT; + switch (le32_to_cpu(info-Type)) { + case UNIX_FILE: + inode-i_mode |= S_IFREG; + break; + case UNIX_SYMLINK: + inode-i_mode |= S_IFLNK; + break; + case UNIX_DIR: + inode-i_mode |= S_IFDIR; + break; + case UNIX_CHARDEV: + inode-i_mode |= S_IFCHR; + inode-i_rdev = MKDEV(le64_to_cpu(info-DevMajor), + le64_to_cpu(info-DevMinor) MINORMASK); + break; + case UNIX_BLOCKDEV: + inode-i_mode |= S_IFBLK; + inode-i_rdev = MKDEV(le64_to_cpu(info-DevMajor), + le64_to_cpu(info-DevMinor) MINORMASK); + break; + case UNIX_FIFO: + inode-i_mode |= S_IFIFO; + break; + case UNIX_SOCKET: + inode-i_mode |= S_IFSOCK; + break; + default: + /* safest to call it a file if we do not know */ + inode-i_mode |= S_IFREG; + cFYI(1, (unknown type %d, le32_to_cpu(info-Type))); + break; + } + + if ((cifs_sb-mnt_cifs_flags CIFS_MOUNT_OVERR_UID) + !force_uid_gid) + inode-i_uid = cifs_sb-mnt_uid; + else + inode-i_uid = le64_to_cpu(info-Uid); + + if ((cifs_sb-mnt_cifs_flags CIFS_MOUNT_OVERR_GID) + !force_uid_gid) + inode-i_gid = cifs_sb-mnt_gid; + else + inode-i_gid = le64_to_cpu(info-Gid); + + inode-i_nlink = le64_to_cpu(info-Nlinks); + + spin_lock(inode-i_lock); + if (is_size_safe_to_change(cifsInfo, end_of_file)) { + /* +* We can not safely change the file size here if the client +* is writing to it due to potential races. +*/ + i_size_write(inode, end_of_file); + + /* +* i_blocks is not related to (i_size / i_blksize), +* but instead 512 byte (2**9) size is required for +* calculating num blocks. +*/ + inode-i_blocks = (512 - 1 + num_of_bytes) 9; + } + spin_unlock(inode-i_lock); +} + int cifs_get_inode_info_unix(struct inode **pinode, const unsigned char *search_path, struct super_block *sb, int xid) { @@ -122,7 +206,6 @@ int cifs_get_inode_info_unix(struct inod return rc; else { struct cifsInodeInfo *cifsInfo; - __u32 type = le32_to_cpu(findData.Type); __u64 num_of_bytes = le64_to_cpu(findData.NumOfBytes); __u64 end_of_file = le64_to_cpu(findData.EndOfFile); @@ -153,73 +236,8 @@ int cifs_get_inode_info_unix(struct inod /* this is ok to set on every inode revalidate */ atomic_set(cifsInfo-inUse, 1); - inode-i_atime = - cifs_NTtimeToUnix(le64_to_cpu(findData.LastAccessTime)); - inode-i_mtime = - cifs_NTtimeToUnix(le64_to_cpu - (findData.LastModificationTime)); - inode-i_ctime = - cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange)); - inode-i_mode = le64_to_cpu(findData.Permissions); - /* since we set the inode type below we need to mask off - to avoid strange results if bits set above */ - inode-i_mode = ~S_IFMT; - if (type == UNIX_FILE) { - inode-i_mode |= S_IFREG; - } else if (type == UNIX_SYMLINK) { - inode-i_mode |= S_IFLNK; -
[patch 02/18] Use page_cache_xxx functions in mm/filemap.c
Convert the uses of PAGE_CACHE_xxx. Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- mm/filemap.c | 91 +-- 1 file changed, 46 insertions(+), 45 deletions(-) Index: linux-2.6/mm/filemap.c === --- linux-2.6.orig/mm/filemap.c 2008-02-14 15:20:25.570017244 -0800 +++ linux-2.6/mm/filemap.c 2008-02-15 16:14:31.616843824 -0800 @@ -325,8 +325,8 @@ int wait_on_page_writeback_range(struct int sync_page_range(struct inode *inode, struct address_space *mapping, loff_t pos, loff_t count) { - pgoff_t start = pos PAGE_CACHE_SHIFT; - pgoff_t end = (pos + count - 1) PAGE_CACHE_SHIFT; + pgoff_t start = page_cache_index(mapping, pos); + pgoff_t end = page_cache_index(mapping, pos + count - 1); int ret; if (!mapping_cap_writeback_dirty(mapping) || !count) @@ -357,8 +357,8 @@ EXPORT_SYMBOL(sync_page_range); int sync_page_range_nolock(struct inode *inode, struct address_space *mapping, loff_t pos, loff_t count) { - pgoff_t start = pos PAGE_CACHE_SHIFT; - pgoff_t end = (pos + count - 1) PAGE_CACHE_SHIFT; + pgoff_t start = page_cache_index(mapping, pos); + pgoff_t end = page_cache_index(mapping, pos + count - 1); int ret; if (!mapping_cap_writeback_dirty(mapping) || !count) @@ -387,7 +387,7 @@ int filemap_fdatawait(struct address_spa return 0; return wait_on_page_writeback_range(mapping, 0, - (i_size - 1) PAGE_CACHE_SHIFT); + page_cache_index(mapping, i_size - 1)); } EXPORT_SYMBOL(filemap_fdatawait); @@ -435,8 +435,8 @@ int filemap_write_and_wait_range(struct /* See comment of filemap_write_and_wait() */ if (err != -EIO) { int err2 = wait_on_page_writeback_range(mapping, - lstart PAGE_CACHE_SHIFT, - lend PAGE_CACHE_SHIFT); + page_cache_index(mapping, lstart), + page_cache_index(mapping, lend)); if (!err) err = err2; } @@ -900,11 +900,11 @@ static void do_generic_file_read(struct unsigned int prev_offset; int error; - index = *ppos PAGE_CACHE_SHIFT; - prev_index = ra-prev_pos PAGE_CACHE_SHIFT; - prev_offset = ra-prev_pos (PAGE_CACHE_SIZE-1); - last_index = (*ppos + desc-count + PAGE_CACHE_SIZE-1) PAGE_CACHE_SHIFT; - offset = *ppos ~PAGE_CACHE_MASK; + index = page_cache_index(mapping, *ppos); + prev_index = page_cache_index(mapping, ra-prev_pos); + prev_offset = page_cache_offset(mapping, ra-prev_pos); + last_index = page_cache_next(mapping, *ppos + desc-count); + offset = page_cache_offset(mapping, *ppos); for (;;) { struct page *page; @@ -941,16 +941,16 @@ page_ok: */ isize = i_size_read(inode); - end_index = (isize - 1) PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); if (unlikely(!isize || index end_index)) { page_cache_release(page); goto out; } /* nr is the maximum number of bytes to copy from this page */ - nr = PAGE_CACHE_SIZE; + nr = page_cache_size(mapping); if (index == end_index) { - nr = ((isize - 1) ~PAGE_CACHE_MASK) + 1; + nr = page_cache_offset(mapping, isize - 1) + 1; if (nr = offset) { page_cache_release(page); goto out; @@ -985,8 +985,8 @@ page_ok: */ ret = actor(desc, page, offset, nr); offset += ret; - index += offset PAGE_CACHE_SHIFT; - offset = ~PAGE_CACHE_MASK; + index += page_cache_index(mapping, offset); + offset = page_cache_offset(mapping, offset); prev_offset = offset; page_cache_release(page); @@ -1076,11 +1076,8 @@ no_cached_page: } out: - ra-prev_pos = prev_index; - ra-prev_pos = PAGE_CACHE_SHIFT; - ra-prev_pos |= prev_offset; - - *ppos = ((loff_t)index PAGE_CACHE_SHIFT) + offset; + ra-prev_pos = page_cache_pos(mapping, prev_index, prev_offset); + *ppos = page_cache_pos(mapping, index, offset); if (filp) file_accessed(filp); } @@ -1259,8 +1256,8 @@ asmlinkage ssize_t sys_readahead(int fd, if (file) { if
[patch 03/18] Use page_cache_xxx in mm/page-writeback.c
Use page_cache_xxx in mm/page-writeback.c Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- mm/page-writeback.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Index: mm/mm/page-writeback.c === --- mm.orig/mm/page-writeback.c 2007-11-28 12:27:32.211962401 -0800 +++ mm/mm/page-writeback.c 2007-11-28 14:10:34.338227137 -0800 @@ -818,8 +818,8 @@ int write_cache_pages(struct address_spa index = mapping-writeback_index; /* Start from prev offset */ end = -1; } else { - index = wbc-range_start PAGE_CACHE_SHIFT; - end = wbc-range_end PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, wbc-range_start); + end = page_cache_index(mapping, wbc-range_end); if (wbc-range_start == 0 wbc-range_end == LLONG_MAX) range_whole = 1; scanned = 1; @@ -1025,7 +1025,7 @@ int __set_page_dirty_nobuffers(struct pa __inc_zone_page_state(page, NR_FILE_DIRTY); __inc_bdi_stat(mapping-backing_dev_info, BDI_RECLAIMABLE); - task_io_account_write(PAGE_CACHE_SIZE); + task_io_account_write(page_cache_size(mapping)); } radix_tree_tag_set(mapping-page_tree, page_index(page), PAGECACHE_TAG_DIRTY); -- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 04/18] Use page_cache_xxx in mm/truncate.c
Use page_cache_xxx in mm/truncate.c Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- mm/truncate.c | 35 ++- 1 file changed, 18 insertions(+), 17 deletions(-) Index: linux-2.6.24-rc6-mm1/mm/truncate.c === --- linux-2.6.24-rc6-mm1.orig/mm/truncate.c 2007-12-26 20:06:38.863513630 -0800 +++ linux-2.6.24-rc6-mm1/mm/truncate.c 2007-12-26 20:06:48.143568906 -0800 @@ -46,9 +46,10 @@ void do_invalidatepage(struct page *page (*invalidatepage)(page, offset); } -static inline void truncate_partial_page(struct page *page, unsigned partial) +static inline void truncate_partial_page(struct address_space *mapping, + struct page *page, unsigned partial) { - zero_user_segment(page, partial, PAGE_CACHE_SIZE); + zero_user_segment(page, partial, page_cache_size(mapping)); if (PagePrivate(page)) do_invalidatepage(page, partial); } @@ -101,7 +102,7 @@ truncate_complete_page(struct address_sp if (PagePrivate(page)) do_invalidatepage(page, 0); - cancel_dirty_page(page, PAGE_CACHE_SIZE); + cancel_dirty_page(page, page_cache_size(mapping)); remove_from_page_cache(page); ClearPageUptodate(page); @@ -160,9 +161,9 @@ invalidate_complete_page(struct address_ void truncate_inode_pages_range(struct address_space *mapping, loff_t lstart, loff_t lend) { - const pgoff_t start = (lstart + PAGE_CACHE_SIZE-1) PAGE_CACHE_SHIFT; + const pgoff_t start = page_cache_next(mapping, lstart); pgoff_t end; - const unsigned partial = lstart (PAGE_CACHE_SIZE - 1); + const unsigned partial = page_cache_offset(mapping, lstart); struct pagevec pvec; pgoff_t next; int i; @@ -170,8 +171,9 @@ void truncate_inode_pages_range(struct a if (mapping-nrpages == 0) return; - BUG_ON((lend (PAGE_CACHE_SIZE - 1)) != (PAGE_CACHE_SIZE - 1)); - end = (lend PAGE_CACHE_SHIFT); + BUG_ON(page_cache_offset(mapping, lend) != + page_cache_size(mapping) - 1); + end = page_cache_index(mapping, lend); pagevec_init(pvec, 0); next = start; @@ -197,8 +199,8 @@ void truncate_inode_pages_range(struct a } if (page_mapped(page)) { unmap_mapping_range(mapping, - (loff_t)page_indexPAGE_CACHE_SHIFT, - PAGE_CACHE_SIZE, 0); + page_cache_pos(mapping, page_index, 0), + page_cache_size(mapping), 0); } truncate_complete_page(mapping, page); unlock_page(page); @@ -211,7 +213,7 @@ void truncate_inode_pages_range(struct a struct page *page = find_lock_page(mapping, start - 1); if (page) { wait_on_page_writeback(page); - truncate_partial_page(page, partial); + truncate_partial_page(mapping, page, partial); unlock_page(page); page_cache_release(page); } @@ -239,8 +241,8 @@ void truncate_inode_pages_range(struct a wait_on_page_writeback(page); if (page_mapped(page)) { unmap_mapping_range(mapping, - (loff_t)page-indexPAGE_CACHE_SHIFT, - PAGE_CACHE_SIZE, 0); + page_cache_pos(mapping, page-index, 0), + page_cache_size(mapping), 0); } if (page-index next) next = page-index; @@ -424,9 +426,8 @@ int invalidate_inode_pages2_range(struct * Zap the rest of the file in one hit. */ unmap_mapping_range(mapping, - (loff_t)page_indexPAGE_CACHE_SHIFT, - (loff_t)(end - page_index + 1) -PAGE_CACHE_SHIFT, + page_cache_pos(mapping, page_index, 0), + page_cache_pos(mapping, end - page_index + 1, 0), 0); did_range_unmap = 1; } else { @@ -434,8 +435,8 @@ int invalidate_inode_pages2_range(struct * Just zap this page
[patch 05/18] Use page_cache_xxx in mm/rmap.c
V2-V3: - vma_address(): Check for truncation if this is a file based page. return -EFAULT if truncation occurred. - page_referenced_file(): Only use mapping after we have made sure that the mapping is valid and the page is locked. Use page_cache_xxx in mm/rmap.c Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- mm/rmap.c | 23 +++ 1 file changed, 19 insertions(+), 4 deletions(-) Index: linux-2.6/mm/rmap.c === --- linux-2.6.orig/mm/rmap.c2008-02-14 15:20:25.574017171 -0800 +++ linux-2.6/mm/rmap.c 2008-02-15 16:14:40.016907160 -0800 @@ -190,9 +190,21 @@ static void page_unlock_anon_vma(struct static inline unsigned long vma_address(struct page *page, struct vm_area_struct *vma) { - pgoff_t pgoff = page-index (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff; unsigned long address; + if (PageAnon(page)) + pgoff = page-index; + else { + struct address_space *mapping = page-mapping; + + if (!mapping) + /* Page was truncated */ + return -EFAULT; + + pgoff = page-index mapping_order(mapping); + } + address = vma-vm_start + ((pgoff - vma-vm_pgoff) PAGE_SHIFT); if (unlikely(address vma-vm_start || address = vma-vm_end)) { /* page should be within @vma mapping range */ @@ -348,7 +360,7 @@ static int page_referenced_file(struct p { unsigned int mapcount; struct address_space *mapping = page-mapping; - pgoff_t pgoff = page-index (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff; struct vm_area_struct *vma; struct prio_tree_iter iter; int referenced = 0; @@ -368,6 +380,9 @@ static int page_referenced_file(struct p */ BUG_ON(!PageLocked(page)); + /* Safe to use mapping */ + pgoff = page-index mapping_order(mapping); + spin_lock(mapping-i_mmap_lock); /* @@ -468,7 +483,7 @@ out: static int page_mkclean_file(struct address_space *mapping, struct page *page) { - pgoff_t pgoff = page-index (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page-index mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = 0; @@ -899,7 +914,7 @@ static int try_to_unmap_anon(struct page static int try_to_unmap_file(struct page *page, int migration) { struct address_space *mapping = page-mapping; - pgoff_t pgoff = page-index (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page-index mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = SWAP_AGAIN; -- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 06/18] Use page_cache_xxx in mm/filemap_xip.c
Use page_cache_xxx in mm/filemap_xip.c Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- mm/filemap_xip.c | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) Index: linux-2.6/mm/filemap_xip.c === --- linux-2.6.orig/mm/filemap_xip.c 2008-02-14 15:20:25.570017244 -0800 +++ linux-2.6/mm/filemap_xip.c 2008-02-15 16:14:43.296931634 -0800 @@ -62,24 +62,24 @@ do_xip_mapping_read(struct address_space BUG_ON(!mapping-a_ops-get_xip_page); - index = *ppos PAGE_CACHE_SHIFT; - offset = *ppos ~PAGE_CACHE_MASK; + index = page_cache_index(mapping, *ppos); + offset = page_cache_offset(mapping, *ppos); isize = i_size_read(inode); if (!isize) goto out; - end_index = (isize - 1) PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); for (;;) { struct page *page; unsigned long nr, ret; /* nr is the maximum number of bytes to copy from this page */ - nr = PAGE_CACHE_SIZE; + nr = page_cache_size(mapping); if (index = end_index) { if (index end_index) goto out; - nr = ((isize - 1) ~PAGE_CACHE_MASK) + 1; + nr = page_cache_next(mapping, isize); if (nr = offset) { goto out; } @@ -118,8 +118,8 @@ do_xip_mapping_read(struct address_space */ ret = actor(desc, page, offset, nr); offset += ret; - index += offset PAGE_CACHE_SHIFT; - offset = ~PAGE_CACHE_MASK; + index += page_cache_index(mapping, offset); + offset = page_cache_offset(mapping, offset); if (ret == nr desc-count) continue; @@ -132,7 +132,7 @@ no_xip_page: } out: - *ppos = ((loff_t) index PAGE_CACHE_SHIFT) + offset; + *ppos = page_cache_pos(mapping, index, offset); if (filp) file_accessed(filp); } @@ -221,7 +221,7 @@ static int xip_file_fault(struct vm_area /* XXX: are VM_FAULT_ codes OK? */ - size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) PAGE_CACHE_SHIFT; + size = page_cache_next(mapping, i_size_read(inode)); if (vmf-pgoff = size) return VM_FAULT_SIGBUS; @@ -291,9 +291,9 @@ __xip_file_write(struct file *filp, cons size_t copied; char *kaddr; - offset = (pos (PAGE_CACHE_SIZE -1)); /* Within page */ - index = pos PAGE_CACHE_SHIFT; - bytes = PAGE_CACHE_SIZE - offset; + offset = page_cache_offset(mapping, pos); /* Within page */ + index = page_cache_index(mapping, pos); + bytes = page_cache_size(mapping) - offset; if (bytes count) bytes = count; @@ -404,8 +404,8 @@ EXPORT_SYMBOL_GPL(xip_file_write); int xip_truncate_page(struct address_space *mapping, loff_t from) { - pgoff_t index = from PAGE_CACHE_SHIFT; - unsigned offset = from (PAGE_CACHE_SIZE-1); + pgoff_t index = page_cache_index(mapping, from); + unsigned offset = page_cache_offset(mapping, from); unsigned blocksize; unsigned length; struct page *page; -- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 08/18] Use page_cache_xxx in fs/libfs.c
Use page_cache_xxx in fs/libfs.c Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- fs/libfs.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) Index: linux-2.6/fs/libfs.c === --- linux-2.6.orig/fs/libfs.c 2008-02-14 15:19:12.777509805 -0800 +++ linux-2.6/fs/libfs.c2008-02-15 16:14:49.160975533 -0800 @@ -17,7 +17,8 @@ int simple_getattr(struct vfsmount *mnt, { struct inode *inode = dentry-d_inode; generic_fillattr(inode, stat); - stat-blocks = inode-i_mapping-nrpages (PAGE_CACHE_SHIFT - 9); + stat-blocks = inode-i_mapping-nrpages + (page_cache_shift(inode-i_mapping) - 9); return 0; } @@ -341,10 +342,10 @@ int simple_prepare_write(struct file *fi unsigned from, unsigned to) { if (!PageUptodate(page)) { - if (to - from != PAGE_CACHE_SIZE) + if (to - from != page_cache_size(file-f_mapping)) zero_user_segments(page, 0, from, - to, PAGE_CACHE_SIZE); + to, page_cache_size(file-f_mapping)); } return 0; } @@ -372,8 +373,9 @@ int simple_write_begin(struct file *file static int simple_commit_write(struct file *file, struct page *page, unsigned from, unsigned to) { - struct inode *inode = page-mapping-host; - loff_t pos = ((loff_t)page-index PAGE_CACHE_SHIFT) + to; + struct address_space *mapping = page-mapping; + struct inode *inode = mapping-host; + loff_t pos = page_cache_pos(mapping, page-index, to); if (!PageUptodate(page)) SetPageUptodate(page); -- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 07/18] Use page_cache_xxx in mm/migrate.c
V2-V3: - Only use mapping in remove_file_migration_ptes after it was checked for NULL. Use page_cache_xxx in mm/migrate.c Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- mm/migrate.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Index: linux-2.6/mm/migrate.c === --- linux-2.6.orig/mm/migrate.c 2008-02-14 15:20:25.570017244 -0800 +++ linux-2.6/mm/migrate.c 2008-02-15 16:14:46.304954466 -0800 @@ -197,11 +197,12 @@ static void remove_file_migration_ptes(s struct vm_area_struct *vma; struct address_space *mapping = page_mapping(new); struct prio_tree_iter iter; - pgoff_t pgoff = new-index (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff; if (!mapping) return; + pgoff = new-index mapping_order(mapping); spin_lock(mapping-i_mmap_lock); vma_prio_tree_foreach(vma, iter, mapping-i_mmap, pgoff, pgoff) -- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 09/18] Use page_cache_xxx in fs/sync
Use page_cache_xxx in fs/sync. Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- fs/sync.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: linux-2.6/fs/sync.c === --- linux-2.6.orig/fs/sync.c2008-02-14 15:19:13.645515948 -0800 +++ linux-2.6/fs/sync.c 2008-02-15 16:14:52.000998613 -0800 @@ -260,8 +260,8 @@ int do_sync_mapping_range(struct address ret = 0; if (flags SYNC_FILE_RANGE_WAIT_BEFORE) { ret = wait_on_page_writeback_range(mapping, - offset PAGE_CACHE_SHIFT, - endbyte PAGE_CACHE_SHIFT); + page_cache_index(mapping, offset), + page_cache_index(mapping, endbyte)); if (ret 0) goto out; } @@ -275,8 +275,8 @@ int do_sync_mapping_range(struct address if (flags SYNC_FILE_RANGE_WAIT_AFTER) { ret = wait_on_page_writeback_range(mapping, - offset PAGE_CACHE_SHIFT, - endbyte PAGE_CACHE_SHIFT); + page_cache_index(mapping, offset), + page_cache_index(mapping, endbyte)); } out: return ret; -- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 10/18] Use page_cache_xxx in fs/buffer.c
V2-V3: - alloc_page_buffers(): Add comment to explain use of page-mapping - Consistently determine mapping if there is a reference chain page-mapping-host to determine the inode. Use page_cache_xxx in fs/buffer.c. Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- fs/buffer.c | 112 ++-- 1 file changed, 65 insertions(+), 47 deletions(-) Index: linux-2.6/fs/buffer.c === --- linux-2.6.orig/fs/buffer.c 2008-02-15 16:11:18.567307640 -0800 +++ linux-2.6/fs/buffer.c 2008-02-15 16:14:54.753021832 -0800 @@ -270,7 +270,7 @@ __find_get_block_slow(struct block_devic struct page *page; int all_mapped = 1; - index = block (PAGE_CACHE_SHIFT - bd_inode-i_blkbits); + index = block (page_cache_shift(bd_mapping) - bd_inode-i_blkbits); page = find_get_page(bd_mapping, index); if (!page) goto out; @@ -712,7 +712,7 @@ static int __set_page_dirty(struct page __inc_zone_page_state(page, NR_FILE_DIRTY); __inc_bdi_stat(mapping-backing_dev_info, BDI_RECLAIMABLE); - task_io_account_write(PAGE_CACHE_SIZE); + task_io_account_write(page_cache_size(mapping)); } radix_tree_tag_set(mapping-page_tree, page_index(page), PAGECACHE_TAG_DIRTY); @@ -924,7 +924,13 @@ struct buffer_head *alloc_page_buffers(s try_again: head = NULL; - offset = PAGE_SIZE; + + /* +* Page is locked to serialize alloc_page_buffers() +* so we can use page-mapping here. +*/ + offset = page_cache_size(page-mapping); + while ((offset -= size) = 0) { bh = alloc_buffer_head(GFP_NOFS); if (!bh) @@ -1636,6 +1642,7 @@ static int __block_write_full_page(struc struct buffer_head *bh, *head; const unsigned blocksize = 1 inode-i_blkbits; int nr_underway = 0; + struct address_space *mapping = inode-i_mapping; BUG_ON(!PageLocked(page)); @@ -1656,7 +1663,8 @@ static int __block_write_full_page(struc * handle that here by just cleaning them. */ - block = (sector_t)page-index (PAGE_CACHE_SHIFT - inode-i_blkbits); + block = (sector_t)page-index + (page_cache_shift(mapping) - inode-i_blkbits); head = page_buffers(page); bh = head; @@ -1772,7 +1780,7 @@ recover: } while ((bh = bh-b_this_page) != head); SetPageError(page); BUG_ON(PageWriteback(page)); - mapping_set_error(page-mapping, err); + mapping_set_error(mapping, err); set_page_writeback(page); do { struct buffer_head *next = bh-b_this_page; @@ -1839,8 +1847,8 @@ static int __block_prepare_write(struct struct buffer_head *bh, *head, *wait[2], **wait_bh=wait; BUG_ON(!PageLocked(page)); - BUG_ON(from PAGE_CACHE_SIZE); - BUG_ON(to PAGE_CACHE_SIZE); + BUG_ON(from page_cache_size(inode-i_mapping)); + BUG_ON(to page_cache_size(inode-i_mapping)); BUG_ON(from to); blocksize = 1 inode-i_blkbits; @@ -1849,7 +1857,8 @@ static int __block_prepare_write(struct head = page_buffers(page); bbits = inode-i_blkbits; - block = (sector_t)page-index (PAGE_CACHE_SHIFT - bbits); + block = (sector_t)page-index + (page_cache_shift(inode-i_mapping) - bbits); for(bh = head, block_start = 0; bh != head || !block_start; block++, block_start=block_end, bh = bh-b_this_page) { @@ -1964,8 +1973,8 @@ int block_write_begin(struct file *file, unsigned start, end; int ownpage = 0; - index = pos PAGE_CACHE_SHIFT; - start = pos (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + start = page_cache_offset(mapping, pos); end = start + len; page = *pagep; @@ -2012,7 +2021,7 @@ int block_write_end(struct file *file, s struct inode *inode = mapping-host; unsigned start; - start = pos (PAGE_CACHE_SIZE - 1); + start = page_cache_offset(mapping, pos); if (unlikely(copied len)) { /* @@ -2077,7 +2086,8 @@ EXPORT_SYMBOL(generic_write_end); */ int block_read_full_page(struct page *page, get_block_t *get_block) { - struct inode *inode = page-mapping-host; + struct address_space *mapping = page-mapping; + struct inode *inode = mapping-host; sector_t iblock, lblock; struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE]; unsigned int blocksize; @@ -2090,7 +2100,8 @@ int block_read_full_page(struct page *pa create_empty_buffers(page, blocksize, 0); head
[patch 11/18] Use page_cache_xxx in mm/mpage.c
Use page_cache_xxx in mm/mpage.c Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- fs/mpage.c | 28 1 file changed, 16 insertions(+), 12 deletions(-) Index: linux-2.6/fs/mpage.c === --- linux-2.6.orig/fs/mpage.c 2008-02-14 15:19:12.989511284 -0800 +++ linux-2.6/fs/mpage.c2008-02-15 16:14:58.093049603 -0800 @@ -125,7 +125,8 @@ mpage_alloc(struct block_device *bdev, static void map_buffer_to_page(struct page *page, struct buffer_head *bh, int page_block) { - struct inode *inode = page-mapping-host; + struct address_space *mapping = page-mapping; + struct inode *inode = mapping-host; struct buffer_head *page_bh, *head; int block = 0; @@ -134,9 +135,9 @@ map_buffer_to_page(struct page *page, st * don't make any buffers if there is only one buffer on * the page and the page just needs to be set up to date */ - if (inode-i_blkbits == PAGE_CACHE_SHIFT + if (inode-i_blkbits == page_cache_shift(mapping) buffer_uptodate(bh)) { - SetPageUptodate(page); + SetPageUptodate(page); return; } create_empty_buffers(page, 1 inode-i_blkbits, 0); @@ -169,9 +170,10 @@ do_mpage_readpage(struct bio *bio, struc sector_t *last_block_in_bio, struct buffer_head *map_bh, unsigned long *first_logical_block, get_block_t get_block) { - struct inode *inode = page-mapping-host; + struct address_space *mapping = page-mapping; + struct inode *inode = mapping-host; const unsigned blkbits = inode-i_blkbits; - const unsigned blocks_per_page = PAGE_CACHE_SIZE blkbits; + const unsigned blocks_per_page = page_cache_size(mapping) blkbits; const unsigned blocksize = 1 blkbits; sector_t block_in_file; sector_t last_block; @@ -188,7 +190,7 @@ do_mpage_readpage(struct bio *bio, struc if (page_has_buffers(page)) goto confused; - block_in_file = (sector_t)page-index (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t)page-index (page_cache_shift(mapping) - blkbits); last_block = block_in_file + nr_pages * blocks_per_page; last_block_in_file = (i_size_read(inode) + blocksize - 1) blkbits; if (last_block last_block_in_file) @@ -276,7 +278,8 @@ do_mpage_readpage(struct bio *bio, struc } if (first_hole != blocks_per_page) { - zero_user_segment(page, first_hole blkbits, PAGE_CACHE_SIZE); + zero_user_segment(page, first_hole blkbits, + page_cache_size(mapping)); if (first_hole == 0) { SetPageUptodate(page); unlock_page(page); @@ -454,7 +457,7 @@ static int __mpage_writepage(struct page struct inode *inode = page-mapping-host; const unsigned blkbits = inode-i_blkbits; unsigned long end_index; - const unsigned blocks_per_page = PAGE_CACHE_SIZE blkbits; + const unsigned blocks_per_page = page_cache_size(mapping) blkbits; sector_t last_block; sector_t block_in_file; sector_t blocks[MAX_BUF_PER_PAGE]; @@ -523,7 +526,8 @@ static int __mpage_writepage(struct page * The page has no buffers: map it to disk */ BUG_ON(!PageUptodate(page)); - block_in_file = (sector_t)page-index (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t)page-index + (page_cache_shift(mapping) - blkbits); last_block = (i_size - 1) blkbits; map_bh.b_page = page; for (page_block = 0; page_block blocks_per_page; ) { @@ -555,7 +559,7 @@ static int __mpage_writepage(struct page first_unmapped = page_block; page_is_mapped: - end_index = i_size PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, i_size); if (page-index = end_index) { /* * The page straddles i_size. It must be zeroed out on each @@ -565,11 +569,11 @@ page_is_mapped: * is zeroed when mapped, and writes to that region are not * written out to the file. */ - unsigned offset = i_size (PAGE_CACHE_SIZE - 1); + unsigned offset = page_cache_offset(mapping, i_size); if (page-index end_index || !offset) goto confused; - zero_user_segment(page, offset, PAGE_CACHE_SIZE); + zero_user_segment(page, offset, page_cache_size(mapping)); } /* -- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL
[patch 13/18] Use page_cache_xxx in fs/splice.c
Use page_cache_xxx in fs/splice.c Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- fs/splice.c | 27 ++- 1 file changed, 14 insertions(+), 13 deletions(-) Index: linux-2.6/fs/splice.c === --- linux-2.6.orig/fs/splice.c 2008-02-14 15:19:13.645515948 -0800 +++ linux-2.6/fs/splice.c 2008-02-15 16:15:07.021124374 -0800 @@ -285,9 +285,9 @@ __generic_file_splice_read(struct file * .spd_release = spd_release_page, }; - index = *ppos PAGE_CACHE_SHIFT; - loff = *ppos ~PAGE_CACHE_MASK; - req_pages = (len + loff + PAGE_CACHE_SIZE - 1) PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, *ppos); + loff = page_cache_offset(mapping, *ppos); + req_pages = page_cache_next(mapping, len + loff); nr_pages = min(req_pages, (unsigned)PIPE_BUFFERS); /* @@ -342,7 +342,7 @@ __generic_file_splice_read(struct file * * Now loop over the map and see if we need to start IO on any * pages, fill in the partial map, etc. */ - index = *ppos PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, *ppos); nr_pages = spd.nr_pages; spd.nr_pages = 0; for (page_nr = 0; page_nr nr_pages; page_nr++) { @@ -354,7 +354,8 @@ __generic_file_splice_read(struct file * /* * this_len is the max we'll use from this page */ - this_len = min_t(unsigned long, len, PAGE_CACHE_SIZE - loff); + this_len = min_t(unsigned long, len, + page_cache_size(mapping) - loff); page = pages[page_nr]; if (PageReadahead(page)) @@ -414,7 +415,7 @@ fill_it: * i_size must be checked after PageUptodate. */ isize = i_size_read(mapping-host); - end_index = (isize - 1) PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); if (unlikely(!isize || index end_index)) break; @@ -428,7 +429,7 @@ fill_it: /* * max good bytes in this page */ - plen = ((isize - 1) ~PAGE_CACHE_MASK) + 1; + plen = page_cache_offset(mapping, isize - 1) + 1; if (plen = loff) break; @@ -453,7 +454,7 @@ fill_it: */ while (page_nr nr_pages) page_cache_release(pages[page_nr++]); - in-f_ra.prev_pos = (loff_t)index PAGE_CACHE_SHIFT; + in-f_ra.prev_pos = page_cache_pos(mapping, index, 0); if (spd.nr_pages) return splice_to_pipe(pipe, spd); @@ -579,11 +580,11 @@ static int pipe_to_file(struct pipe_inod if (unlikely(ret)) return ret; - offset = sd-pos ~PAGE_CACHE_MASK; + offset = page_cache_offset(mapping, sd-pos); this_len = sd-len; - if (this_len + offset PAGE_CACHE_SIZE) - this_len = PAGE_CACHE_SIZE - offset; + if (this_len + offset page_cache_size(mapping)) + this_len = page_cache_size(mapping) - offset; ret = pagecache_write_begin(file, mapping, sd-pos, this_len, AOP_FLAG_UNINTERRUPTIBLE, page, fsdata); @@ -790,7 +791,7 @@ generic_file_splice_write_nolock(struct unsigned long nr_pages; *ppos += ret; - nr_pages = (ret + PAGE_CACHE_SIZE - 1) PAGE_CACHE_SHIFT; + nr_pages = page_cache_next(mapping, ret); /* * If file or inode is SYNC and we actually wrote some data, @@ -852,7 +853,7 @@ generic_file_splice_write(struct pipe_in unsigned long nr_pages; *ppos += ret; - nr_pages = (ret + PAGE_CACHE_SIZE - 1) PAGE_CACHE_SHIFT; + nr_pages = page_cache_next(mapping, ret); /* * If file or inode is SYNC and we actually wrote some data, -- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 14/18] Use page_cache_xxx in ext2
Use page_cache_xxx functions in fs/ext2/* Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- fs/ext2/dir.c | 41 +++-- 1 file changed, 23 insertions(+), 18 deletions(-) Index: linux-2.6/fs/ext2/dir.c === --- linux-2.6.orig/fs/ext2/dir.c2008-02-14 15:19:11.961504128 -0800 +++ linux-2.6/fs/ext2/dir.c 2008-02-15 16:15:09.997149018 -0800 @@ -63,7 +63,7 @@ static inline void ext2_put_page(struct static inline unsigned long dir_pages(struct inode *inode) { - return (inode-i_size+PAGE_CACHE_SIZE-1)PAGE_CACHE_SHIFT; + return page_cache_next(inode-i_mapping, inode-i_size); } /* @@ -74,10 +74,11 @@ static unsigned ext2_last_byte(struct inode *inode, unsigned long page_nr) { unsigned last_byte = inode-i_size; + struct address_space *mapping = inode-i_mapping; - last_byte -= page_nr PAGE_CACHE_SHIFT; - if (last_byte PAGE_CACHE_SIZE) - last_byte = PAGE_CACHE_SIZE; + last_byte -= page_cache_pos(mapping, page_nr, 0); + if (last_byte page_cache_size(mapping)) + last_byte = page_cache_size(mapping); return last_byte; } @@ -105,18 +106,19 @@ static int ext2_commit_chunk(struct page static void ext2_check_page(struct page *page) { - struct inode *dir = page-mapping-host; + struct address_space *mapping = page-mapping; + struct inode *dir = mapping-host; struct super_block *sb = dir-i_sb; unsigned chunk_size = ext2_chunk_size(dir); char *kaddr = page_address(page); u32 max_inumber = le32_to_cpu(EXT2_SB(sb)-s_es-s_inodes_count); unsigned offs, rec_len; - unsigned limit = PAGE_CACHE_SIZE; + unsigned limit = page_cache_size(mapping); ext2_dirent *p; char *error; - if ((dir-i_size PAGE_CACHE_SHIFT) == page-index) { - limit = dir-i_size ~PAGE_CACHE_MASK; + if (page_cache_index(mapping, dir-i_size) == page-index) { + limit = page_cache_offset(mapping, dir-i_size); if (limit (chunk_size - 1)) goto Ebadsize; if (!limit) @@ -168,7 +170,7 @@ Einumber: bad_entry: ext2_error (sb, ext2_check_page, bad entry in directory #%lu: %s - offset=%lu, inode=%lu, rec_len=%d, name_len=%d, - dir-i_ino, error, (page-indexPAGE_CACHE_SHIFT)+offs, + dir-i_ino, error, page_cache_pos(mapping, page-index, offs), (unsigned long) le32_to_cpu(p-inode), rec_len, p-name_len); goto fail; @@ -177,7 +179,7 @@ Eend: ext2_error (sb, ext2_check_page, entry in directory #%lu spans the page boundary offset=%lu, inode=%lu, - dir-i_ino, (page-indexPAGE_CACHE_SHIFT)+offs, + dir-i_ino, page_cache_pos(mapping, page-index, offs), (unsigned long) le32_to_cpu(p-inode)); fail: SetPageChecked(page); @@ -276,8 +278,9 @@ ext2_readdir (struct file * filp, void * loff_t pos = filp-f_pos; struct inode *inode = filp-f_path.dentry-d_inode; struct super_block *sb = inode-i_sb; - unsigned int offset = pos ~PAGE_CACHE_MASK; - unsigned long n = pos PAGE_CACHE_SHIFT; + struct address_space *mapping = inode-i_mapping; + unsigned int offset = page_cache_offset(mapping, pos); + unsigned long n = page_cache_index(mapping, pos); unsigned long npages = dir_pages(inode); unsigned chunk_mask = ~(ext2_chunk_size(inode)-1); unsigned char *types = NULL; @@ -298,14 +301,14 @@ ext2_readdir (struct file * filp, void * ext2_error(sb, __FUNCTION__, bad page in #%lu, inode-i_ino); - filp-f_pos += PAGE_CACHE_SIZE - offset; + filp-f_pos += page_cache_size(mapping) - offset; return -EIO; } kaddr = page_address(page); if (unlikely(need_revalidate)) { if (offset) { offset = ext2_validate_entry(kaddr, offset, chunk_mask); - filp-f_pos = (nPAGE_CACHE_SHIFT) + offset; + filp-f_pos = page_cache_pos(mapping, n, offset); } filp-f_version = inode-i_version; need_revalidate = 0; @@ -328,7 +331,7 @@ ext2_readdir (struct file * filp, void * offset = (char *)de - kaddr; over = filldir(dirent, de-name, de-name_len, - (nPAGE_CACHE_SHIFT) | offset, +
[patch 12/18] Use page_cache_xxx in mm/fadvise.c
Use page_cache_xxx in mm/fadvise.c Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- mm/fadvise.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: linux-2.6/mm/fadvise.c === --- linux-2.6.orig/mm/fadvise.c 2008-02-14 15:20:25.566017193 -0800 +++ linux-2.6/mm/fadvise.c 2008-02-15 16:15:04.157100371 -0800 @@ -91,8 +91,8 @@ asmlinkage long sys_fadvise64_64(int fd, } /* First and last PARTIAL page! */ - start_index = offset PAGE_CACHE_SHIFT; - end_index = endbyte PAGE_CACHE_SHIFT; + start_index = page_cache_index(mapping, offset); + end_index = page_cache_index(mapping, endbyte); /* Careful about overflow on the +1 */ nrpages = end_index - start_index + 1; @@ -112,8 +112,8 @@ asmlinkage long sys_fadvise64_64(int fd, filemap_flush(mapping); /* First and last FULL page! */ - start_index = (offset+(PAGE_CACHE_SIZE-1)) PAGE_CACHE_SHIFT; - end_index = (endbyte PAGE_CACHE_SHIFT); + start_index = page_cache_next(mapping, offset); + end_index = page_cache_index(mapping, endbyte); if (end_index = start_index) invalidate_mapping_pages(mapping, start_index, -- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 15/18] Use page_cache_xxx in fs/ext3
Use page_cache_xxx in fs/ext3 Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- fs/ext3/dir.c |3 ++- fs/ext3/inode.c | 39 --- 2 files changed, 22 insertions(+), 20 deletions(-) Index: linux-2.6/fs/ext3/dir.c === --- linux-2.6.orig/fs/ext3/dir.c2008-02-14 15:19:11.977504226 -0800 +++ linux-2.6/fs/ext3/dir.c 2008-02-15 16:15:13.021174127 -0800 @@ -133,7 +133,8 @@ static int ext3_readdir(struct file * fi map_bh, 0, 0); if (err 0) { pgoff_t index = map_bh.b_blocknr - (PAGE_CACHE_SHIFT - inode-i_blkbits); + (page_cache_shift(inode-i_mapping) + - inode-i_blkbits); if (!ra_has_index(filp-f_ra, index)) page_cache_sync_readahead( sb-s_bdev-bd_inode-i_mapping, Index: linux-2.6/fs/ext3/inode.c === --- linux-2.6.orig/fs/ext3/inode.c 2008-02-14 15:19:11.977504226 -0800 +++ linux-2.6/fs/ext3/inode.c 2008-02-15 16:15:13.049174361 -0800 @@ -1147,8 +1147,8 @@ static int ext3_write_begin(struct file pgoff_t index; unsigned from, to; - index = pos PAGE_CACHE_SHIFT; - from = pos (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + from = page_cache_offset(mapping, pos); to = from + len; retry: @@ -1244,7 +1244,7 @@ static int ext3_ordered_write_end(struct unsigned from, to; int ret = 0, ret2; - from = pos (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page), @@ -1314,7 +1314,7 @@ static int ext3_journalled_write_end(str int partial = 0; unsigned from, to; - from = pos (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; if (copied len) { @@ -1477,6 +1477,7 @@ static int ext3_ordered_writepage(struct handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode-i_mapping); J_ASSERT(PageLocked(page)); @@ -1499,8 +1500,7 @@ static int ext3_ordered_writepage(struct (1 BH_Dirty)|(1 BH_Uptodate)); } page_bufs = page_buffers(page); - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bget_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one); ret = block_write_full_page(page, ext3_get_block, wbc); @@ -1517,13 +1517,12 @@ static int ext3_ordered_writepage(struct * and generally junk. */ if (ret == 0) { - err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, - NULL, journal_dirty_data_fn); + err = walk_page_buffers(handle, page_bufs, 0, pagesize, + NULL, journal_dirty_data_fn); if (!ret) ret = err; } - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bput_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one); err = ext3_journal_stop(handle); if (!ret) ret = err; @@ -1571,10 +1570,12 @@ out_fail: static int ext3_journalled_writepage(struct page *page, struct writeback_control *wbc) { - struct inode *inode = page-mapping-host; + struct address_space *mapping = page-mapping; + struct inode *inode = mapping-host; handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode-i_mapping); if (ext3_journal_current_handle()) goto no_write; @@ -1591,17 +1592,16 @@ static int ext3_journalled_writepage(str * doesn't seem much point in redirtying the page here. */ ClearPageChecked(page); - ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, - ext3_get_block); + ret = block_prepare_write(page, 0, pagesize, ext3_get_block); if (ret != 0) { ext3_journal_stop(handle); goto out_unlock; } ret = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, do_journal_get_write_access); + pagesize, NULL, do_journal_get_write_access); err = walk_page_buffers(handle, page_buffers(page),
[patch 16/18] Use page_cache_xxx in fs/ext4
Use page_cache_xxx in fs/ext4 Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- fs/ext4/dir.c |3 ++- fs/ext4/inode.c | 34 +- 2 files changed, 19 insertions(+), 18 deletions(-) Index: linux-2.6/fs/ext4/dir.c === --- linux-2.6.orig/fs/ext4/dir.c2008-02-14 15:19:11.993504338 -0800 +++ linux-2.6/fs/ext4/dir.c 2008-02-15 16:15:16.385202022 -0800 @@ -132,7 +132,8 @@ static int ext4_readdir(struct file * fi err = ext4_get_blocks_wrap(NULL, inode, blk, 1, map_bh, 0, 0); if (err 0) { pgoff_t index = map_bh.b_blocknr - (PAGE_CACHE_SHIFT - inode-i_blkbits); + (page_cache_size(inode-i_mapping) + - inode-i_blkbits); if (!ra_has_index(filp-f_ra, index)) page_cache_sync_readahead( sb-s_bdev-bd_inode-i_mapping, Index: linux-2.6/fs/ext4/inode.c === --- linux-2.6.orig/fs/ext4/inode.c 2008-02-14 15:19:12.005504520 -0800 +++ linux-2.6/fs/ext4/inode.c 2008-02-15 16:15:16.389202066 -0800 @@ -1142,8 +1142,8 @@ static int ext4_write_begin(struct file pgoff_t index; unsigned from, to; - index = pos PAGE_CACHE_SHIFT; - from = pos (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + from = page_cache_offset(mapping, pos); to = from + len; retry: @@ -1238,7 +1238,7 @@ static int ext4_ordered_write_end(struct unsigned from, to; int ret = 0, ret2; - from = pos (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page), @@ -1308,7 +1308,7 @@ static int ext4_journalled_write_end(str int partial = 0; unsigned from, to; - from = pos (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; if (copied len) { @@ -1471,6 +1471,7 @@ static int ext4_ordered_writepage(struct handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode-i_mapping); J_ASSERT(PageLocked(page)); @@ -1493,8 +1494,7 @@ static int ext4_ordered_writepage(struct (1 BH_Dirty)|(1 BH_Uptodate)); } page_bufs = page_buffers(page); - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bget_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one); ret = block_write_full_page(page, ext4_get_block, wbc); @@ -1511,13 +1511,12 @@ static int ext4_ordered_writepage(struct * and generally junk. */ if (ret == 0) { - err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, + err = walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, jbd2_journal_dirty_data_fn); if (!ret) ret = err; } - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bput_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one); err = ext4_journal_stop(handle); if (!ret) ret = err; @@ -1569,6 +1568,7 @@ static int ext4_journalled_writepage(str handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode-i_mapping); if (ext4_journal_current_handle()) goto no_write; @@ -1585,17 +1585,16 @@ static int ext4_journalled_writepage(str * doesn't seem much point in redirtying the page here. */ ClearPageChecked(page); - ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, - ext4_get_block); + ret = block_prepare_write(page, 0, pagesize, ext4_get_block); if (ret != 0) { ext4_journal_stop(handle); goto out_unlock; } ret = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, do_journal_get_write_access); + pagesize, NULL, do_journal_get_write_access); err = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, write_end_fn); + pagesize, NULL, write_end_fn); if (ret == 0) ret = err; EXT4_I(inode)-i_state |= EXT4_STATE_JDATA; @@ -1818,8 +1817,8 @@ void
[patch 18/18] Use page_cache_xxx for fs/xfs
V2-V3: - xfs_page_trace: Determine mapping from inode - xfs_probe_page: Make mapping check easier to read Use page_cache_xxx for fs/xfs Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- fs/xfs/linux-2.6/xfs_aops.c | 58 ++-- fs/xfs/linux-2.6/xfs_lrw.c |4 +-- 2 files changed, 32 insertions(+), 30 deletions(-) Index: linux-2.6/fs/xfs/linux-2.6/xfs_aops.c === --- linux-2.6.orig/fs/xfs/linux-2.6/xfs_aops.c 2008-02-14 15:19:13.777516867 -0800 +++ linux-2.6/fs/xfs/linux-2.6/xfs_aops.c 2008-02-15 16:15:22.377251601 -0800 @@ -75,7 +75,7 @@ xfs_page_trace( xfs_inode_t *ip; bhv_vnode_t *vp = vn_from_inode(inode); loff_t isize = i_size_read(inode); - loff_t offset = page_offset(page); + loff_t offset = page_cache_pos(inode-i_mapping, page-index, 0); int delalloc = -1, unmapped = -1, unwritten = -1; if (page_has_buffers(page)) @@ -599,11 +599,12 @@ xfs_probe_page( int mapped) { int ret = 0; + struct address_space*mapping = page-mapping; if (PageWriteback(page)) return 0; - if (page-mapping PageDirty(page)) { + if (mapping PageDirty(page)) { if (page_has_buffers(page)) { struct buffer_head *bh, *head; @@ -618,7 +619,7 @@ xfs_probe_page( break; } while ((bh = bh-b_this_page) != head); } else - ret = mapped ? 0 : PAGE_CACHE_SIZE; + ret = mapped ? 0 : page_cache_size(mapping); } return ret; @@ -645,7 +646,7 @@ xfs_probe_cluster( } while ((bh = bh-b_this_page) != head); /* if we reached the end of the page, sum forwards in following pages */ - tlast = i_size_read(inode) PAGE_CACHE_SHIFT; + tlast = page_cache_index(inode-i_mapping, i_size_read(inode)); tindex = startpage-index + 1; /* Prune this back to avoid pathological behavior */ @@ -663,14 +664,14 @@ xfs_probe_cluster( size_t pg_offset, pg_len = 0; if (tindex == tlast) { - pg_offset = - i_size_read(inode) (PAGE_CACHE_SIZE - 1); + pg_offset = page_cache_offset(inode-i_mapping, + i_size_read(inode)); if (!pg_offset) { done = 1; break; } } else - pg_offset = PAGE_CACHE_SIZE; + pg_offset = page_cache_size(inode-i_mapping); if (page-index == tindex !TestSetPageLocked(page)) { pg_len = xfs_probe_page(page, pg_offset, mapped); @@ -752,7 +753,8 @@ xfs_convert_page( int bbits = inode-i_blkbits; int len, page_dirty; int count = 0, done = 0, uptodate = 1; - xfs_off_t offset = page_offset(page); + struct address_space*map = inode-i_mapping; + xfs_off_t offset = page_cache_pos(map, page-index, 0); if (page-index != tindex) goto fail; @@ -760,7 +762,7 @@ xfs_convert_page( goto fail; if (PageWriteback(page)) goto fail_unlock_page; - if (page-mapping != inode-i_mapping) + if (page-mapping != map) goto fail_unlock_page; if (!xfs_is_delayed_page(page, (*ioendp)-io_type)) goto fail_unlock_page; @@ -772,20 +774,19 @@ xfs_convert_page( * Derivation: * * End offset is the highest offset that this page should represent. -* If we are on the last page, (end_offset (PAGE_CACHE_SIZE - 1)) -* will evaluate non-zero and be less than PAGE_CACHE_SIZE and +* If we are on the last page, (end_offset page_cache_mask()) +* will evaluate non-zero and be less than page_cache_size() and * hence give us the correct page_dirty count. On any other page, * it will be zero and in that case we need page_dirty to be the * count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page-index + 1) PAGE_CACHE_SHIFT, + (xfs_off_t)page_cache_pos(map, page-index + 1, 0), i_size_read(inode)); len = 1 inode-i_blkbits; - p_offset = min_t(unsigned long, end_offset
[patch 17/18] Use page_cache_xxx in fs/reiserfs
V2-V3: - reiserfs_commit_write(): Use common method to extract mapping from page-mapping-host chain Use page_cache_xxx in fs/reiserfs Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- fs/reiserfs/file.c|5 +++-- fs/reiserfs/inode.c | 36 ++-- fs/reiserfs/ioctl.c |2 +- fs/reiserfs/stree.c |5 +++-- fs/reiserfs/tail_conversion.c |5 +++-- fs/reiserfs/xattr.c | 19 ++- 6 files changed, 42 insertions(+), 30 deletions(-) Index: linux-2.6/fs/reiserfs/file.c === --- linux-2.6.orig/fs/reiserfs/file.c 2008-02-14 15:19:13.573515455 -0800 +++ linux-2.6/fs/reiserfs/file.c2008-02-15 16:15:19.373226761 -0800 @@ -161,11 +161,12 @@ int reiserfs_commit_page(struct inode *i int partial = 0; unsigned blocksize; struct buffer_head *bh, *head; - unsigned long i_size_index = inode-i_size PAGE_CACHE_SHIFT; + unsigned long i_size_index = + page_cache_index(inode-i_mapping, inode-i_size); int new; int logit = reiserfs_file_data_log(inode); struct super_block *s = inode-i_sb; - int bh_per_page = PAGE_CACHE_SIZE / s-s_blocksize; + int bh_per_page = page_cache_size(inode-i_mapping) / s-s_blocksize; struct reiserfs_transaction_handle th; int ret = 0; Index: linux-2.6/fs/reiserfs/inode.c === --- linux-2.6.orig/fs/reiserfs/inode.c 2008-02-14 15:19:13.633515774 -0800 +++ linux-2.6/fs/reiserfs/inode.c 2008-02-15 16:15:19.397226989 -0800 @@ -337,7 +337,8 @@ static int _get_block_create_0(struct in goto finished; } // read file tail into part of page - offset = (cpu_key_k_offset(key) - 1) (PAGE_CACHE_SIZE - 1); + offset = page_cache_offset(inode-i_mapping, + cpu_key_k_offset(key) - 1); fs_gen = get_generation(inode-i_sb); copy_item_head(tmp_ih, ih); @@ -523,10 +524,10 @@ static int convert_tail_for_hole(struct return -EIO; /* always try to read until the end of the block */ - tail_start = tail_offset (PAGE_CACHE_SIZE - 1); + tail_start = page_cache_offset(inode-i_mapping, tail_offset); tail_end = (tail_start | (bh_result-b_size - 1)) + 1; - index = tail_offset PAGE_CACHE_SHIFT; + index = page_cache_index(inode-i_mapping, tail_offset); /* hole_page can be zero in case of direct_io, we are sure that we cannot get here if we write with O_DIRECT into tail page */ @@ -2000,11 +2001,13 @@ static int grab_tail_page(struct inode * /* we want the page with the last byte in the file, ** not the page that will hold the next byte for appending */ - unsigned long index = (p_s_inode-i_size - 1) PAGE_CACHE_SHIFT; + unsigned long index = page_cache_index(p_s_inode-i_mapping, + p_s_inode-i_size - 1); unsigned long pos = 0; unsigned long start = 0; unsigned long blocksize = p_s_inode-i_sb-s_blocksize; - unsigned long offset = (p_s_inode-i_size) (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_offset(p_s_inode-i_mapping, + p_s_inode-i_size); struct buffer_head *bh; struct buffer_head *head; struct page *page; @@ -2076,7 +2079,8 @@ int reiserfs_truncate_file(struct inode { struct reiserfs_transaction_handle th; /* we want the offset for the first byte after the end of the file */ - unsigned long offset = p_s_inode-i_size (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_offset(p_s_inode-i_mapping, + p_s_inode-i_size); unsigned blocksize = p_s_inode-i_sb-s_blocksize; unsigned length; struct page *page = NULL; @@ -2225,7 +2229,7 @@ static int map_block_for_writepage(struc } else if (is_direct_le_ih(ih)) { char *p; p = page_address(bh_result-b_page); - p += (byte_offset - 1) (PAGE_CACHE_SIZE - 1); + p += page_cache_offset(inode-i_mapping, byte_offset - 1); copy_size = ih_item_len(ih) - pos_in_item; fs_gen = get_generation(inode-i_sb); @@ -2324,7 +2328,8 @@ static int reiserfs_write_full_page(stru struct writeback_control *wbc) { struct inode *inode = page-mapping-host; - unsigned long end_index = inode-i_size PAGE_CACHE_SHIFT; + unsigned long end_index = page_cache_index(inode-i_mapping, + inode-i_size); int error = 0;
[patch 01/18] Define functions for page cache handling
V2-V3: - Use mapping instead of a as the address space parameter We use the macros PAGE_CACHE_SIZE PAGE_CACHE_SHIFT PAGE_CACHE_MASK and PAGE_CACHE_ALIGN in various places in the kernel. Many times common operations like calculating the offset or the index are coded using shifts and adds. This patch provides inline functions to get the calculations accomplished without having to explicitly shift and add constants. All functions take an address_space pointer. The address space pointer will be used in the future to eventually support a variable size page cache. Information reachable via the mapping may then determine page size. New functionRelated base page constant page_cache_shift(a) PAGE_CACHE_SHIFT page_cache_size(a) PAGE_CACHE_SIZE page_cache_mask(a) PAGE_CACHE_MASK page_cache_index(a, pos)Calculate page number from position page_cache_next(addr, pos) Page number of next page page_cache_offset(a, pos) Calculate offset into a page page_cache_pos(a, index, offset) Form position based on page number and an offset. This provides a basis that would allow the conversion of all page cache handling in the kernel and ultimately allow the removal of the PAGE_CACHE_* constants. Reviewed-by: Dave Chinner [EMAIL PROTECTED] Signed-off-by: Christoph Lameter [EMAIL PROTECTED] --- include/linux/pagemap.h | 53 +++- 1 file changed, 52 insertions(+), 1 deletion(-) Index: linux-2.6.24-rc6-mm1/include/linux/pagemap.h === --- linux-2.6.24-rc6-mm1.orig/include/linux/pagemap.h 2007-12-26 21:12:59.773000516 -0800 +++ linux-2.6.24-rc6-mm1/include/linux/pagemap.h2007-12-26 21:19:15.537477621 -0800 @@ -52,12 +52,61 @@ static inline void mapping_set_gfp_mask( * space in smaller chunks for same flexibility). * * Or rather, it _will_ be done in larger chunks. + * + * The following constants can be used if a filesystem only supports a single + * page size. */ #define PAGE_CACHE_SHIFT PAGE_SHIFT #define PAGE_CACHE_SIZEPAGE_SIZE #define PAGE_CACHE_MASKPAGE_MASK #define PAGE_CACHE_ALIGN(addr) (((addr)+PAGE_CACHE_SIZE-1)PAGE_CACHE_MASK) +/* + * Functions that are currently setup for a fixed PAGE_SIZE. The use of + * these may allow larger page sizes in the future. + */ +static inline int mapping_order(struct address_space *mapping) +{ + return 0; +} + +static inline int page_cache_shift(struct address_space *mapping) +{ + return PAGE_SHIFT; +} + +static inline unsigned int page_cache_size(struct address_space *mapping) +{ + return PAGE_SIZE; +} + +static inline unsigned int page_cache_offset(struct address_space *mapping, + loff_t pos) +{ + return pos ~PAGE_MASK; +} + +static inline pgoff_t page_cache_index(struct address_space *mapping, + loff_t pos) +{ + return pos page_cache_shift(mapping); +} + +/* + * Index of the page starting on or after the given position. + */ +static inline pgoff_t page_cache_next(struct address_space *mapping, + loff_t pos) +{ + return page_cache_index(mapping, pos + page_cache_size(mapping) - 1); +} + +static inline loff_t page_cache_pos(struct address_space *mapping, + pgoff_t index, unsigned long offset) +{ + return ((loff_t)index page_cache_shift(mapping)) + offset; +} + #define page_cache_get(page) get_page(page) #define page_cache_release(page) put_page(page) void release_pages(struct page **pages, int nr, int cold); -- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 00/18] Page cache: Replace PAGE_CACHE_xx with inline functions V4
This patchset cleans up page cache handling by replacing open coded shifts and adds with inline function calls. The ultimate goal is to replace all uses of PAGE_CACHE_xxx in the kernel through the use of these functions. All the functions take a mapping parameter. The mapping parameter is required if we want to support large block sizes in filesystems and block devices. Patchset against upstream as of today (2.6.25-rc2) Patchset can be pulled from git://git.kernel.org/pub/scm/linux/kernel/git/christoph/vm.git pagecache-inline V2-V4: - Rediff to upstream. Surprisingly no rejects at all so it seems that all of the pagecache patches that were in mm were merged. Just had to refresh the patches. V2-V3: - Audit to check that uses of page-mapping are valid. Improve a couple of places. Make it clearer how the mappings are determined and handled (see the comments of each patch for detailed descriptions). - Use a consistent method to determine the mapping if a function already does determine the inode via page-mapping-host. V1-V2: - Review by Dave Chinner. Multiple improvements and fixes. - Review by Fengguand Wu with more improvements. -- - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html