Permit filesystem local caching and NFS superblock sharing [try #10]
Subsystems (55)
David Howells
maintainercover Permit filesystem local caching and NFS superblock sharing [try #10]
These patches make it possible to share NFS superblocks between related mounts, where "related" means on the same server and FSID. Inodes and dentries will be shared where the NFS filehandles are the same (for example if two NFS3 files come from the same export but from different mounts, such as is not uncommon with autofs on /home).
These patches also add local caching for network filesystems such as NFS and AFS.
The first six patches (NFS superblock sharing) can be applied without the remaining patches (filesystem local caching).
Changes [try #9] that have been made:
(*) [PATCH] NFS: Permit filesystem to perform statfs with a known root dentry
[*] Inclusions of linux/mount.h have been added where necessary to make
allyesconfig build successfully.
(*) [PATCH] NFS: Share NFS superblocks per-protocol per-server per-FSID
[*] The exports from fs/namespace.c and fs/namei.c are no longer required.
(*) [PATCH] FS-Cache: Release page->private in failed readahead
[*] The try_to_release_page() is called instead of calling the
releasepage() op directly.
[*] The page is locked before try_to_release_page() is called.
[*] The call to try_to_release_page() and page_cache_release() have been
abstracted out into a helper function as this bit of code occurs twice..
Changes [try #10] that have been made:
(*) [PATCH] NFS: Permit filesystem to perform statfs with a known root dentry
[*] Pass a dentry rather than a vfsmount to the statfs() op as the key by
which to determine the filesystem.
(*) [PATCH] NFS: Share NFS superblocks per-protocol per-server per-FSID
[*] nfs4_pathname_string() needed an extra const.
(*) [PATCH] FS-Cache: Release page->private in failed readahead
[*] The comment header on the helper function is much expanded. This
states why there's a need to call the releasepage() op in the event of an error.
[*] BUG() if the page is already locked when we try and lock it.
[*] Don't set the page mapping pointer until we've locked the page.
[*] The page is unlocked after try_to_release_page() is called.
(*) The release-page patch now comes before the fscache-afs patch as well as
the fscache-nfs patch.
---
In response to those who've asked, there are at least three reasons for implementing superblock sharing:
(1) As I understand what I've been told, NFSv4 requires a 1:1 mapping between server files and client files. I suspect this has to do with the management of leases.
(2) We can reduce the resource consumption on NFSv2 and NFSv3 clients as well as on NFSv4 clients by sharing superblocks that cover overlapping segments of the file space.
Consider a machine that's used by a lot of people at the same time, each of whom has an automounted NFS homedir off of the same server - and in fact off of the same disk on the that server. Currently, with Linus's tree, each one will get a separate superblock to represent them; with Trond's tree, each one will still get a separate superblock unless they share the same root filehandle; and with my patches, they'll get the same superblock.
If two homedirs have a hard link between them (unlikely, I know, but by no means impossible, and probably more likely with, say, data such as NFS mounted git repositories), then you have the possibility of aliasing. This means that you can have two or more inodes in core that refer to the same server object, and each of these inodes can have pages that refer to the same remote pages on the server - aliasing again. You _have_ to have two inodes because they're covered by separate superblocks.
Aliasing is bad, generally, because you end up using more storage than you need to (pagecache and inode cache in this case), and you have the problem of keeping them in sync. It's also twice as hard to keep two inodes up to date when they change on the server as to keep one up to date.
If you can use the same superblock where possible, then you can cut out aliasing on that client since you can share dentries that have the same file handle (hard links or subtrees).
Part of the problem with NFSv2 and NFSv3 is that you invoke mountd to get the filehandle to a subtree, but you may not be able to work out how two different subtrees relate. The getsb patch permits the superblock to have more than one root, which allows us to defer this problem until we see the root of one subtree cropping up in another subtree - at which point we can splice the former into the latter.
(3) In my local file caching patches (FS-Cache), I have two reasons for wanting this:
(a) Unique keys. I need a unique key to find an object in the cache. If we can get inode aliases, then I end up with several inodes referring to the same cache object. This also means that I have to use a fair bit of extra memory to keep track of the multiple cookie mappings in FS-Cache, and have to compare keys a lot to find duplicate mappings.
If I can assume that the _netfs_ will manage the 1:1 mapping, I can use a lot less memory and save some processing capacity also.
I don't want to invent random keys to differentiate aliased superblocks or inodes as that destroys the persistence capabilities of the cache across power failures and reboots.
(b) Callbacks. I want a callback that the netfs passes to FS-Cache to permit the cache to update the metadata in the cache from netfs metadata at convenient times. However, if there's more than one inode alias in core, which one should the cache use?
AFS doesn't have anything like these problems because mounts are always made from the root of a volume, and AFS was designed with local caching in mind.
The getsb and statfs patches are a consequence of NFS being permitted to mount arbitrary subtrees from the server.
David
David Howells
maintainerPATCH 1/14 NFS: Permit filesystem to override root dentry on mount [try #10]
The attached patch extends the get_sb() filesystem operation to take an extra argument that permits the VFS to pass in the target vfsmount that defines the mountpoint.
The filesystem is then required to manually set the superblock and root dentry pointers. For most filesystems, this should be done with simple_set_mnt() which will set the superblock pointer and then set the root dentry to the superblock's s_root (as per the old default behaviour).
This patch permits a superblock to be implicitly shared amongst several mount points, such as can be done with NFS to avoid potential inode aliasing (see patch #5). In such a case, simple_set_mnt() would not be called, and instead the mnt_root and mnt_sb would be set directly.
This patch also changes the superblock cleanup routine to make it use shrink_dcache_sb() instead of shrink_dcache_anon(). This required is because the superblock may now have multiple trees that aren't actually bound to s_root, but that still need to be cleaned up. The currently called functions assume that the whole tree is rooted at s_root, and that anonymous dentries are not the roots of trees which results in dentries being left unculled.
Following discussion with Al Viro, the following changes [try #2] were made to the previous attempt at this set of patches:
(*) The vfsmount is now passed into the get_sb() method for a filesystem
instead of passing a pointer to a pointer to a dentry into which get_sb() could stick a root dentry if it wanted. get_sb() now instantiates the superblock and root dentry pointers in the vfsmount itself.
(*) The get_sb() method now returns an integer (0 or -ve error number) rather
than the superblock pointer or cast error number.
(*) the get_sb_*() convenience functions in the core kernel now take a
vfsmount pointer argument and return an integer, so most filesystems have to change very little.
(*) If one of the convenience function is not used, then get_sb() should
normally call simple_set_mnt() to instantiate the vfsmount. This will always return 0, and so can be tail-called from get_sb().
(*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
dcache upon superblock destruction rather than shrink_dcache_parent() and shrink_dcache_anon(). This is because, as far as I can tell, the current code assumes that all the dentries will be linked into a tree depending from sb->s_root, and that anonymous dentries won't have children.
However, with the way these patches implement NFS superblock sharing, these assumptions are violated: the root of the filesystem is simply a dummy dentry and inode (the real inode for '/' may well be inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries with child trees.
[*] Anonymous until discovered from another tree.
Further changes [try #3] that have been made:
(*) The patches are now against Trond's NFS git tree, so won't apply to
Linus's tree.
(*) Core documentation changes have been moved to the first patch.
Further changes [try #4]:
(*) shrink_dcache_parent() has been reintroduced to handle final cleanup of
filesystem types such as nfsd and binfmt_misc that have pinned dentries.
(*) get_sb_bdev() has been fixed to handle the superblock sharing case
correctly (it should not go down the error path).
Further changes [try #5]:
(*) Make futex_get_sb() static once again.
(*) Fold together the patch that changes the core and the patch that modifies
all the filesystems to cope with the core change as some people are unable to cope with two interdependent patches.
---
Documentation/filesystems/Locking | 7 + Documentation/filesystems/porting | 7 + Documentation/filesystems/vfs.txt | 4 - arch/ia64/kernel/perfmon.c | 7 + arch/powerpc/platforms/cell/spufs/inode.c | 6 + drivers/infiniband/core/uverbs_main.c | 7 + drivers/isdn/capi/capifs.c | 6 + drivers/misc/ibmasm/ibmasmfs.c | 7 + drivers/oprofile/oprofilefs.c | 6 + drivers/usb/core/inode.c | 6 + drivers/usb/gadget/inode.c | 6 + fs/9p/vfs_super.c | 21 ++-- fs/adfs/super.c | 7 + fs/affs/super.c | 7 + fs/afs/super.c | 24 +++-- fs/autofs/init.c | 6 + fs/autofs4/init.c | 6 + fs/befs/linuxvfs.c | 7 + fs/bfs/inode.c | 6 + fs/binfmt_misc.c | 6 + fs/block_dev.c | 6 + fs/cifs/cifsfs.c | 10 +- fs/coda/inode.c | 6 + fs/configfs/mount.c | 6 + fs/cramfs/inode.c | 7 + fs/debugfs/inode.c | 8 +- fs/devfs/base.c | 8 +- fs/devpts/inode.c | 6 + fs/efs/super.c | 6 + fs/eventpoll.c | 13 +-- fs/ext2/super.c | 6 + fs/ext3/super.c | 6 + fs/freevxfs/vxfs_super.c | 7 + fs/fuse/inode.c | 8 +- fs/hfs/super.c | 7 + fs/hfsplus/super.c | 8 +- fs/hostfs/hostfs_kern.c | 8 +- fs/hpfs/super.c | 7 + fs/hppfs/hppfs_kern.c | 8 +- fs/hugetlbfs/inode.c | 6 + fs/inotify.c | 6 + fs/isofs/inode.c | 7 + fs/jffs/inode-v23.c | 7 + fs/jffs2/super.c | 49 +++++----- fs/jfs/super.c | 7 + fs/libfs.c | 12 +- fs/minix/inode.c | 7 + fs/msdos/namei.c | 9 +- fs/namespace.c | 9 ++ fs/ncpfs/inode.c | 6 + fs/nfs/inode.c | 146 ++++++++++++++++++----------- fs/nfsd/nfsctl.c | 6 + fs/ntfs/super.c | 7 + fs/ocfs2/dlm/dlmfs.c | 6 + fs/ocfs2/super.c | 12 +- fs/openpromfs/inode.c | 6 + fs/pipe.c | 9 +- fs/proc/root.c | 6 + fs/qnx4/inode.c | 7 + fs/ramfs/inode.c | 13 +-- fs/reiserfs/super.c | 9 +- fs/romfs/inode.c | 7 + fs/smbfs/inode.c | 6 + fs/super.c | 97 +++++++++++-------- fs/sysfs/mount.c | 6 + fs/sysv/super.c | 13 +-- fs/udf/super.c | 6 + fs/ufs/super.c | 6 + fs/vfat/namei.c | 9 +- fs/xfs/linux-2.6/xfs_super.c | 8 +- include/linux/fs.h | 25 +++-- include/linux/ramfs.h | 4 - ipc/mqueue.c | 8 +- kernel/cpuset.c | 8 +- kernel/futex.c | 8 +- mm/shmem.c | 6 + net/socket.c | 7 + net/sunrpc/rpc_pipe.c | 6 + security/inode.c | 8 +- security/selinux/selinuxfs.c | 7 + 80 files changed, 498 insertions(+), 399 deletions(-)
Documentation/filesystems/Locking +4 -3
@@ -142,15 +142,16 @@ see also dquot_operations section. --------------------------- file_system_type --------------------------- prototypes: - struct super_block *(*get_sb) (struct file_system_type *, int, - const char *, void *); + struct int (*get_sb) (struct file_system_type *, int, + const char *, void *, struct vfsmount *); void (*kill_sb) (struct super_block *); locking rules: may block BKL get_sb yes yes kill_sb yes yes -->get_sb() returns error or a locked superblock (exclusive on ->s_umount). +->get_sb() returns error or 0 with locked superblock attached to the vfsmount +(exclusive on ->s_umount). ->kill_sb() takes a write-locked superblock, does all shutdown work on it, unlocks and drops the reference.
Documentation/filesystems/porting +4 -3
@@ -50,10 +50,11 @@ Turn your foo_read_super() into a functi success and negative number in case of error (-EINVAL unless you have more informative error value to report). Call it foo_fill_super(). Now declare -struct super_block foo_get_sb(struct file_system_type *fs_type, - int flags, const char *dev_name, void *data) +int foo_get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, void *data, struct vfsmount *mnt) { - return get_sb_bdev(fs_type, flags, dev_name, data, ext2_fill_super); + return get_sb_bdev(fs_type, flags, dev_name, data, ext2_fill_super, + mnt); } (or similar with s/bdev/nodev/ or s/bdev/single/, depending on the kind of
Documentation/filesystems/vfs.txt +2 -2
@@ -113,8 +113,8 @@ members are defined: struct file_system_type { const char *name; int fs_flags; - struct super_block *(*get_sb) (struct file_system_type *, int, - const char *, void *); + struct int (*get_sb) (struct file_system_type *, int, + const char *, void *, struct vfsmount *); void (*kill_sb) (struct super_block *); struct module *owner; struct file_system_type * next;
arch/ia64/kernel/perfmon.c +4 -3
@@ -595,10 +595,11 @@ pfm_get_unmapped_area(struct file *file, } -static struct super_block * -pfmfs_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *data) +static int +pfmfs_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *data, +struct vfsmount *mnt) { -return get_sb_pseudo (fs_type,"pfm:" ,NULL ,PFMFS_MAGIC ); +return get_sb_pseudo (fs_type,"pfm:" ,NULL ,PFMFS_MAGIC , mnt); }static struct file_system_type pfm_fs_type = {
arch/powerpc/platforms/cell/spufs/inode.c +3 -3
@@ -428,11 +428,11 @@ spufs_fill_super(struct super_block *sb,return spufs_create_root (sb, data); } -static struct super_block * +static int spufs_get_sb (struct file_system_type *fstype,int flags, -const char *name,void *data) +const char *name,void *data,struct vfsmount *mnt) { -return get_sb_single (fstype, flags, data, spufs_fill_super); +return get_sb_single (fstype, flags, data, spufs_fill_super, mnt); }static struct file_system_type spufs_type = {
drivers/infiniband/core/uverbs_main.c +4 -3
@@ -820,11 +820,12 @@ static void ib_uverbs_remove_one(structkref_put (&uverbs_dev->ref, ib_uverbs_release_dev); } -static struct super_block *uverbs_event_get_sb (struct file_system_type *fs_type,int flags, -const char *dev_name,void *data) +static int uverbs_event_get_sb (struct file_system_type *fs_type,int flags, +const char *dev_name,void *data, +struct vfsmount *mnt) {return get_sb_pseudo (fs_type,"infinibandevent:" ,NULL , -INFINIBANDEVENTFS_MAGIC ); +INFINIBANDEVENTFS_MAGIC , mnt); }static struct file_system_type uverbs_event_fs = {
drivers/isdn/capi/capifs.c +3 -3
@@ -121,10 +121,10 @@ fail:return -ENOMEM ; } -static struct super_block *capifs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int capifs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, capifs_fill_super); +return get_sb_single (fs_type, flags, data, capifs_fill_super, mnt); }static struct file_system_type capifs_fs_type = {
drivers/misc/ibmasm/ibmasmfs.c +4 -3
@@ -90,10 +90,11 @@ static void ibmasmfs_create_files (strucstatic int ibmasmfs_fill_super (struct super_block *sb,void *data,int silent); -static struct super_block *ibmasmfs_get_super (struct file_system_type *fst, -int flags,const char *name,void *data) +static int ibmasmfs_get_super (struct file_system_type *fst, +int flags,const char *name,void *data, +struct vfsmount *mnt) { -return get_sb_single (fst, flags, data, ibmasmfs_fill_super); +return get_sb_single (fst, flags, data, ibmasmfs_fill_super, mnt); }static struct super_operations ibmasmfs_s_ops = {
drivers/oprofile/oprofilefs.c +3 -3
@@ -272,10 +272,10 @@ static int oprofilefs_fill_super(struct } -static struct super_block *oprofilefs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int oprofilefs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, oprofilefs_fill_super); +return get_sb_single (fs_type, flags, data, oprofilefs_fill_super, mnt); }
drivers/usb/core/inode.c +3 -3
@@ -543,10 +543,10 @@ static void fs_remove_file (struct dentr/* --------------------------------------------------------------------- */ -static struct super_block *usb_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int usb_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, usbfs_fill_super); +return get_sb_single (fs_type, flags, data, usbfs_fill_super, mnt); }static struct file_system_type usb_fs_type = {
drivers/usb/gadget/inode.c +3 -3
@@ -2064,11 +2064,11 @@ gadgetfs_fill_super (struct super_block }/* "mount -t gadgetfs path /dev/gadget" ends up here */ -static struct super_block * +static int gadgetfs_get_sb (struct file_system_type *t,int flags, -const char *path,void *opts) +const char *path,void *opts,struct vfsmount *mnt) { -return get_sb_single (t, flags, opts, gadgetfs_fill_super); +return get_sb_single (t, flags, opts, gadgetfs_fill_super, mnt); } static void
fs/9p/vfs_super.c +12 -9
@@ -99,12 +99,13 @@ v9fs_fill_super(struct super_block *sb,* @flags: mount flags * @dev_name: device name that was mounted * @data: mount options +* @mnt: mountpoint record to be instantiated * */ -static struct super_block *v9fs_get_sb (struct file_system_type - *fs_type,int flags, -const char *dev_name,void *data) +static int v9fs_get_sb (struct file_system_type *fs_type,int flags, +const char *dev_name,void *data, +struct vfsmount *mnt) {struct super_block *sb =NULL ;struct v9fs_fcall *fcall =NULL ;
@@ -123,17 +124,19 @@ static struct super_block *v9fs_get_sb(s v9ses =kzalloc (sizeof (struct v9fs_session_info ),GFP_KERNEL );if (!v9ses) -return ERR_PTR (-ENOMEM ); +return -ENOMEM ;if ((newfid =v9fs_session_init (v9ses, dev_name, data)) <0 ) {dprintk (DEBUG_ERROR ,"problem initiating session\n" ); - sb =ERR_PTR (newfid); + retval = newfid; goto out_free_session; } sb =sget (fs_type,NULL , v9fs_set_super, v9ses); -if (IS_ERR (sb)) +if (IS_ERR (sb)) { + retval =PTR_ERR (sb); goto out_close_session; + }v9fs_fill_super (sb, v9ses, flags); inode =v9fs_get_inode (sb,S_IFDIR | mode);
@@ -184,19 +187,19 @@ static struct super_block *v9fs_get_sb(s goto put_back_sb; } -return sb; +return simple_set_mnt (mnt, sb); out_close_session:v9fs_session_close (v9ses); out_free_session:kfree (v9ses); -return sb; +return retval; put_back_sb:/* deactivate_super calls v9fs_kill_super which will frees the rest */ up_write (&sb->s_umount);deactivate_super (sb); -return ERR_PTR (retval); +return retval; }/**
fs/adfs/super.c +4 -3
@@ -470,10 +470,11 @@ error:return -EINVAL ; } -static struct super_block *adfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int adfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, adfs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, adfs_fill_super, + mnt); }static struct file_system_type adfs_fs_type = {
fs/affs/super.c +4 -3
@@ -524,10 +524,11 @@ affs_statfs(struct super_block *sb, strureturn 0 ; } -static struct super_block *affs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int affs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, affs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, affs_fill_super, + mnt); }static struct file_system_type affs_fs_type = {
fs/afs/super.c +13 -11
@@ -38,9 +38,9 @@ struct afs_mount_params {static void afs_i_init_once (void *foo,kmem_cache_t *cachep,unsigned long flags); -static struct super_block *afs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name, -void *data); +static int afs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name, +void *data,struct vfsmount *mnt);static struct inode *afs_alloc_inode (struct super_block *sb);
@@ -294,10 +294,11 @@ static int afs_fill_super(struct super_b* get an AFS superblock * - TODO: don't use get_sb_nodev(), but rather call sget() directly */ -static struct super_block *afs_get_sb (struct file_system_type *fs_type, -int flags, -const char *dev_name, -void *options) +static int afs_get_sb (struct file_system_type *fs_type, +int flags, +const char *dev_name, +void *options, +struct vfsmount *mnt) {struct afs_mount_params params;struct super_block *sb;
@@ -311,7 +312,7 @@ static struct super_block *afs_get_sb(st ret =afscm_start ();if (ret <0 ) {_leave (" = %d" , ret); -return ERR_PTR (ret); +return ret; }/* parse the options */
@@ -348,18 +349,19 @@ static struct super_block *afs_get_sb(st goto error; } sb->s_flags |=MS_ACTIVE ; +simple_set_mnt (mnt, sb);afs_put_volume (params.volume);afs_put_cell (params.default_cell); -_leave (" = %p" , sb); -return sb; +_leave (" = 0 [%p]" ,0 , sb); +return 0 ; error:afs_put_volume (params.volume);afs_put_cell (params.default_cell);afscm_stop ();_leave (" = %d" , ret); -return ERR_PTR (ret); +return ret; }/* end afs_get_sb() */ /*****************************************************************************/
fs/autofs/init.c +3 -3
@@ -14,10 +14,10 @@ #include <linux/module.h>#include <linux/init.h> #include "autofs_i.h" -static struct super_block *autofs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int autofs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, autofs_fill_super); +return get_sb_nodev (fs_type, flags, data, autofs_fill_super, mnt); }static struct file_system_type autofs_fs_type = {
fs/autofs4/init.c +3 -3
@@ -14,10 +14,10 @@ #include <linux/module.h>#include <linux/init.h> #include "autofs_i.h" -static struct super_block *autofs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int autofs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, autofs4_fill_super); +return get_sb_nodev (fs_type, flags, data, autofs4_fill_super, mnt); }static struct file_system_type autofs_fs_type = {
fs/befs/linuxvfs.c +4 -3
@@ -899,11 +899,12 @@ befs_statfs(struct super_block *sb, strureturn 0 ; } -static struct super_block * +static int befs_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name, -void *data) +void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, befs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, befs_fill_super, + mnt); }static struct file_system_type befs_fs_type = {
fs/bfs/inode.c +3 -3
@@ -410,10 +410,10 @@ out:return -EINVAL ; } -static struct super_block *bfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int bfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, bfs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, bfs_fill_super, mnt); }static struct file_system_type bfs_fs_type = {
fs/binfmt_misc.c +3 -3
@@ -741,10 +741,10 @@ static int bm_fill_super(struct super_blreturn err; } -static struct super_block *bm_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int bm_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, bm_fill_super); +return get_sb_single (fs_type, flags, data, bm_fill_super, mnt); }static struct linux_binfmt misc_format = {
fs/block_dev.c +3 -3
@@ -300,10 +300,10 @@ static struct super_operations bdev_sops .clear_inode = bdev_clear_inode, }; -static struct super_block *bd_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int bd_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_pseudo (fs_type,"bdev:" , &bdev_sops,0x62646576 ); +return get_sb_pseudo (fs_type,"bdev:" , &bdev_sops,0x62646576 , mnt); }static struct file_system_type bd_type = {
fs/cifs/cifsfs.c +5 -5
@@ -462,9 +462,9 @@ #endif .remount_fs = cifs_remount, }; -static struct super_block * +static int cifs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +int flags,const char *dev_name,void *data,struct vfsmount *mnt) {int rc;struct super_block *sb =sget (fs_type,NULL , set_anon_super,NULL );
@@ -472,7 +472,7 @@ cifs_get_sb(struct file_system_type *fs_cFYI (1 , ("Devname: %s flags: %d " , dev_name, flags));if (IS_ERR (sb)) -return sb; +return PTR_ERR (sb); sb->s_flags = flags;
@@ -480,10 +480,10 @@ cifs_get_sb(struct file_system_type *fs_if (rc) {up_write (&sb->s_umount);deactivate_super (sb); -return ERR_PTR (rc); +return rc; } sb->s_flags |=MS_ACTIVE ; -return sb; +return simple_set_mnt (mnt, sb); } static ssize_t cifs_file_writev(struct file *file, const struct iovec *iov,
fs/coda/inode.c +3 -3
@@ -307,10 +307,10 @@ static int coda_statfs(struct super_bloc/* init_coda: used by filesystems.c to register coda */ -static struct super_block *coda_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int coda_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, coda_fill_super); +return get_sb_nodev (fs_type, flags, data, coda_fill_super, mnt); }struct file_system_type coda_fs_type = {
fs/configfs/mount.c +3 -3
@@ -103,10 +103,10 @@ static int configfs_fill_super(struct sureturn 0 ; } -static struct super_block *configfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int configfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, configfs_fill_super); +return get_sb_single (fs_type, flags, data, configfs_fill_super, mnt); }static struct file_system_type configfs_fs_type = {
fs/cramfs/inode.c +4 -3
@@ -528,10 +528,11 @@ static struct super_operations cramfs_op .statfs = cramfs_statfs, }; -static struct super_block *cramfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int cramfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, cramfs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, cramfs_fill_super, + mnt); }static struct file_system_type cramfs_fs_type = {
fs/debugfs/inode.c +4 -4
@@ -110,11 +110,11 @@ static int debug_fill_super(struct superreturn simple_fill_super (sb,DEBUGFS_MAGIC , debug_files); } -static struct super_block *debug_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name, -void *data) +static int debug_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name, +void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, debug_fill_super); +return get_sb_single (fs_type, flags, data, debug_fill_super, mnt); }static struct file_system_type debug_fs_type = {
fs/devfs/base.c +4 -4
@@ -2549,11 +2549,11 @@ static int devfs_fill_super(struct superreturn -EINVAL ; }/* End Function devfs_fill_super */ -static struct super_block *devfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name, -void *data) +static int devfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name, +void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, devfs_fill_super); +return get_sb_single (fs_type, flags, data, devfs_fill_super, mnt); }static struct file_system_type devfs_fs_type = {
fs/devpts/inode.c +3 -3
@@ -130,10 +130,10 @@ fail:return -ENOMEM ; } -static struct super_block *devpts_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int devpts_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, devpts_fill_super); +return get_sb_single (fs_type, flags, data, devpts_fill_super, mnt); }static struct file_system_type devpts_fs_type = {
fs/efs/super.c +3 -3
@@ -18,10 +18,10 @@ #include <linux/vfs.h>static int efs_statfs (struct super_block *s,struct kstatfs *buf);static int efs_fill_super (struct super_block *s,void *d,int silent); -static struct super_block *efs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int efs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, efs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, efs_fill_super, mnt); }static struct file_system_type efs_fs_type = {
fs/eventpoll.c +7 -6
@@ -268,9 +268,9 @@ static int ep_poll(struct eventpoll *ep, int maxevents, long timeout);static int eventpollfs_delete_dentry (struct dentry *dentry);static struct inode *ep_eventpoll_inode (void ); -static struct super_block *eventpollfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name, -void *data); +static int eventpollfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name, +void *data,struct vfsmount *mnt);/* * This semaphore is used to serialize ep_free() and eventpoll_release_file().
@@ -1595,11 +1595,12 @@ eexit_1: } -static struct super_block * +static int eventpollfs_get_sb (struct file_system_type *fs_type,int flags, -const char *dev_name,void *data) +const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_pseudo (fs_type,"eventpoll:" ,NULL ,EVENTPOLLFS_MAGIC ); +return get_sb_pseudo (fs_type,"eventpoll:" ,NULL ,EVENTPOLLFS_MAGIC , + mnt); }
fs/ext2/super.c +3 -3
@@ -1087,10 +1087,10 @@ static int ext2_statfs (struct super_bloreturn 0 ; } -static struct super_block *ext2_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int ext2_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, ext2_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, ext2_fill_super, mnt); }#ifdef CONFIG_QUOTA
fs/ext3/super.c +3 -3
@@ -2646,10 +2646,10 @@ out:#endif -static struct super_block *ext3_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int ext3_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, ext3_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, ext3_fill_super, mnt); }static struct file_system_type ext3_fs_type = {
fs/freevxfs/vxfs_super.c +4 -3
@@ -241,10 +241,11 @@ out:/* * The usual module blurb. */ -static struct super_block *vxfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int vxfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, vxfs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, vxfs_fill_super, + mnt); }static struct file_system_type vxfs_fs_type = {
fs/fuse/inode.c +4 -4
@@ -570,11 +570,11 @@ static int fuse_fill_super(struct super_return err; } -static struct super_block *fuse_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name, -void *raw_data) +static int fuse_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name, +void *raw_data,struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, raw_data, fuse_fill_super); +return get_sb_nodev (fs_type, flags, raw_data, fuse_fill_super, mnt); }static struct file_system_type fuse_fs_type = {
fs/hfs/super.c +4 -3
@@ -413,10 +413,11 @@ bail:return res; } -static struct super_block *hfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int hfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data, +struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, hfs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, hfs_fill_super, mnt); }static struct file_system_type hfs_fs_type = {
fs/hfsplus/super.c +5 -3
@@ -450,10 +450,12 @@ static void hfsplus_destroy_inode(struct#define HFSPLUS_INODE_SIZE sizeof(struct hfsplus_inode_info) -static struct super_block *hfsplus_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int hfsplus_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data, +struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, hfsplus_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, hfsplus_fill_super, + mnt); }static struct file_system_type hfsplus_fs_type = {
fs/hostfs/hostfs_kern.c +4 -4
@@ -993,11 +993,11 @@ static int hostfs_fill_sb_common(structreturn (err); } -static struct super_block *hostfs_read_sb (struct file_system_type *type, -int flags,const char *dev_name, -void *data) +static int hostfs_read_sb (struct file_system_type *type, +int flags,const char *dev_name, +void *data,struct vfsmount *mnt) { -return (get_sb_nodev (type, flags, data, hostfs_fill_sb_common)); +return get_sb_nodev (type, flags, data, hostfs_fill_sb_common, mnt); }static struct file_system_type hostfs_type = {
fs/hpfs/super.c +4 -3
@@ -662,10 +662,11 @@ bail0:return -EINVAL ; } -static struct super_block *hpfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int hpfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, hpfs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, hpfs_fill_super, + mnt); }static struct file_system_type hpfs_fs_type = {
fs/hppfs/hppfs_kern.c +4 -4
@@ -769,11 +769,11 @@ static int hppfs_fill_super(struct superreturn (err); } -static struct super_block *hppfs_read_super (struct file_system_type *type, -int flags,const char *dev_name, -void *data) +static int hppfs_read_super (struct file_system_type *type, +int flags,const char *dev_name, +void *data,struct vfsmount *mnt) { -return (get_sb_nodev (type, flags, data, hppfs_fill_super)); +return get_sb_nodev (type, flags, data, hppfs_fill_super, mnt); }static struct file_system_type hppfs_type = {
fs/hugetlbfs/inode.c +3 -3
@@ -723,10 +723,10 @@ void hugetlb_put_quota(struct address_sp } } -static struct super_block *hugetlbfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int hugetlbfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, hugetlbfs_fill_super); +return get_sb_nodev (fs_type, flags, data, hugetlbfs_fill_super, mnt); }static struct file_system_type hugetlbfs_fs_type = {
fs/inotify.c +3 -3
@@ -1098,11 +1098,11 @@ out:return ret; } -static struct super_block * +static int inotify_get_sb (struct file_system_type *fs_type,int flags, -const char *dev_name,void *data) +const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_pseudo (fs_type,"inotify" ,NULL ,0xBAD1DEA ); +return get_sb_pseudo (fs_type,"inotify" ,NULL ,0xBAD1DEA , mnt); }static struct file_system_type inotify_fs_type = {
fs/isofs/inode.c +4 -3
@@ -1399,10 +1399,11 @@ struct inode *isofs_iget(struct super_blreturn inode; } -static struct super_block *isofs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int isofs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, isofs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, isofs_fill_super, + mnt); }static struct file_system_type iso9660_fs_type = {
fs/jffs/inode-v23.c +4 -3
@@ -1785,10 +1785,11 @@ static struct super_operations jffs_ops .remount_fs = jffs_remount, }; -static struct super_block *jffs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int jffs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, jffs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, jffs_fill_super, + mnt); }static struct file_system_type jffs_fs_type = {
fs/jffs2/super.c +27 -22
131 lines not on this page · raw message
fs/jfs/super.c +4 -3
@@ -565,10 +565,11 @@ static void jfs_unlockfs(struct super_bl } } -static struct super_block *jfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int jfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, jfs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, jfs_fill_super, + mnt); }static int jfs_sync_fs (struct super_block *sb,int wait)
fs/libfs.c +6 -6
@@ -196,9 +196,9 @@ struct inode_operations simple_dir_inode* Common helper for pseudo-filesystems (sockfs, pipefs, bdev - stuff that * will never be mountable) */ -struct super_block * -get_sb_pseudo (struct file_system_type *fs_type,char *name, -struct super_operations *ops,unsigned long magic) +int get_sb_pseudo (struct file_system_type *fs_type,char *name, +struct super_operations *ops,unsigned long magic, +struct vfsmount *mnt) {struct super_block *s =sget (fs_type,NULL , set_anon_super,NULL );static struct super_operations default_ops = {.statfs = simple_statfs};
@@ -207,7 +207,7 @@ get_sb_pseudo(struct file_system_type *fstruct qstr d_name = {.name = name, .len =strlen (name)};if (IS_ERR (s)) -return s; +return PTR_ERR (s); s->s_flags =MS_NOUSER ; s->s_maxbytes = ~0ULL ;
@@ -232,12 +232,12 @@ get_sb_pseudo(struct file_system_type *fd_instantiate (dentry, root); s->s_root = dentry; s->s_flags |=MS_ACTIVE ; -return s; +return simple_set_mnt (mnt, s); Enomem:up_write (&s->s_umount);deactivate_super (s); -return ERR_PTR (-ENOMEM ); +return -ENOMEM ; }int simple_link (struct dentry *old_dentry,struct inode *dir,struct dentry *dentry)
fs/minix/inode.c +4 -3
@@ -559,10 +559,11 @@ void minix_truncate(struct inode * inodeV2_minix_truncate (inode); } -static struct super_block *minix_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int minix_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, minix_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, minix_fill_super, + mnt); }static struct file_system_type minix_fs_type = {
fs/msdos/namei.c +5 -4
@@ -661,11 +661,12 @@ static int msdos_fill_super(struct superreturn 0 ; } -static struct super_block *msdos_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name, -void *data) +static int msdos_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name, +void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, msdos_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, msdos_fill_super, + mnt); }static struct file_system_type msdos_fs_type = {
fs/namespace.c +9 -0
@@ -86,6 +86,15 @@ struct vfsmount *alloc_vfsmnt(const charreturn mnt; } +int simple_set_mnt (struct vfsmount *mnt,struct super_block *sb) +{ + mnt->mnt_sb = sb; + mnt->mnt_root =dget (sb->s_root); +return 0 ; +} + +EXPORT_SYMBOL (simple_set_mnt); +void free_vfsmnt (struct vfsmount *mnt) {kfree (mnt->mnt_devname);
fs/ncpfs/inode.c +3 -3
@@ -957,10 +957,10 @@ out:return result; } -static struct super_block *ncp_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int ncp_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, ncp_fill_super); +return get_sb_nodev (fs_type, flags, data, ncp_fill_super, mnt); }static struct file_system_type ncp_fs_type = {
fs/nfs/inode.c +89 -57
324 lines not on this page · raw message
fs/nfsd/nfsctl.c +3 -3
@@ -494,10 +494,10 @@ #endifreturn simple_fill_super (sb,0x6e667364 , nfsd_files); } -static struct super_block *nfsd_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int nfsd_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, nfsd_fill_super); +return get_sb_single (fs_type, flags, data, nfsd_fill_super, mnt); }static struct file_system_type nfsd_fs_type = {
fs/ntfs/super.c +4 -3
@@ -3093,10 +3093,11 @@ struct kmem_cache *ntfs_index_ctx_cache;/* Driver wide mutex. */ DEFINE_MUTEX (ntfs_lock); -static struct super_block *ntfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int ntfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, ntfs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, ntfs_fill_super, + mnt); }static struct file_system_type ntfs_fs_type = {
fs/ocfs2/dlm/dlmfs.c +3 -3
@@ -574,10 +574,10 @@ static struct inode_operations dlmfs_fil .getattr = simple_getattr, }; -static struct super_block *dlmfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int dlmfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, dlmfs_fill_super); +return get_sb_nodev (fs_type, flags, data, dlmfs_fill_super, mnt); }static struct file_system_type dlmfs_fs_type = {
fs/ocfs2/super.c +7 -5
@@ -672,12 +672,14 @@ read_super_error:return status; } -static struct super_block *ocfs2_get_sb (struct file_system_type *fs_type, -int flags, -const char *dev_name, -void *data) +static int ocfs2_get_sb (struct file_system_type *fs_type, +int flags, +const char *dev_name, +void *data, +struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, ocfs2_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, ocfs2_fill_super, + mnt); }static struct file_system_type ocfs2_fs_type = {
fs/openpromfs/inode.c +3 -3
@@ -1054,10 +1054,10 @@ out_no_root:return -ENOMEM ; } -static struct super_block *openprom_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int openprom_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, openprom_fill_super); +return get_sb_single (fs_type, flags, data, openprom_fill_super, mnt); }static struct file_system_type openprom_fs_type = {
fs/pipe.c +4 -5
@@ -979,12 +979,11 @@ no_files:* any operations on the root directory. However, we need a non-trivial * d_name - pipe: will go nicely and kill the special-casing in procfs. */ - -static struct super_block * -pipefs_get_sb (struct file_system_type *fs_type,int flags, -const char *dev_name,void *data) +static int pipefs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data, +struct vfsmount *mnt) { -return get_sb_pseudo (fs_type,"pipe:" ,NULL ,PIPEFS_MAGIC ); +return get_sb_pseudo (fs_type,"pipe:" ,NULL ,PIPEFS_MAGIC , mnt); }static struct file_system_type pipe_fs_type = {
fs/proc/root.c +3 -3
@@ -26,10 +26,10 @@ #ifdef CONFIG_SYSCTLstruct proc_dir_entry *proc_sys_root;#endif -static struct super_block *proc_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int proc_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, proc_fill_super); +return get_sb_single (fs_type, flags, data, proc_fill_super, mnt); }static struct file_system_type proc_fs_type = {
fs/qnx4/inode.c +4 -3
@@ -561,10 +561,11 @@ static void destroy_inodecache(void) "qnx4_inode_cache: not all structures were freed\n"); } -static struct super_block *qnx4_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int qnx4_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, qnx4_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, qnx4_fill_super, + mnt); }static struct file_system_type qnx4_fs_type = {
fs/ramfs/inode.c +7 -6
@@ -185,16 +185,17 @@ static int ramfs_fill_super(struct superreturn 0 ; } -struct super_block *ramfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +int ramfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, ramfs_fill_super); +return get_sb_nodev (fs_type, flags, data, ramfs_fill_super, mnt); } -static struct super_block *rootfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int rootfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags|MS_NOUSER , data, ramfs_fill_super); +return get_sb_nodev (fs_type, flags|MS_NOUSER , data, ramfs_fill_super, + mnt); }static struct file_system_type ramfs_fs_type = {
fs/reiserfs/super.c +5 -4
@@ -2249,11 +2249,12 @@ static ssize_t reiserfs_quota_write(stru#endif -static struct super_block *get_super_block (struct file_system_type *fs_type, -int flags,const char *dev_name, -void *data) +static int get_super_block (struct file_system_type *fs_type, +int flags,const char *dev_name, +void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, reiserfs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, reiserfs_fill_super, + mnt); }static int __init init_reiserfs_fs (void )
fs/romfs/inode.c +4 -3
@@ -607,10 +607,11 @@ static struct super_operations romfs_ops .remount_fs = romfs_remount, }; -static struct super_block *romfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int romfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, romfs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, romfs_fill_super, + mnt); }static struct file_system_type romfs_fs_type = {
fs/smbfs/inode.c +3 -3
@@ -782,10 +782,10 @@ out:return error; } -static struct super_block *smb_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int smb_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, smb_fill_super); +return get_sb_nodev (fs_type, flags, data, smb_fill_super, mnt); }static struct file_system_type smb_fs_type = {
fs/super.c +54 -43
215 lines not on this page · raw message
fs/sysfs/mount.c +3 -3
@@ -66,10 +66,10 @@ static int sysfs_fill_super(struct superreturn 0 ; } -static struct super_block *sysfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int sysfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, sysfs_fill_super); +return get_sb_single (fs_type, flags, data, sysfs_fill_super, mnt); }static struct file_system_type sysfs_fs_type = {
fs/sysv/super.c +7 -6
@@ -506,16 +506,17 @@ failed:/* Every kernel module contains stuff like this. */ -static struct super_block *sysv_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int sysv_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, sysv_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, sysv_fill_super, + mnt); } -static struct super_block *v7_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int v7_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, v7_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, v7_fill_super, mnt); }static struct file_system_type sysv_fs_type = {
fs/udf/super.c +3 -3
@@ -94,10 +94,10 @@ static unsigned int udf_count_free(strucstatic int udf_statfs (struct super_block *,struct kstatfs *);/* UDF filesystem type */ -static struct super_block *udf_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int udf_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, udf_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, udf_fill_super, mnt); }static struct file_system_type udf_fstype = {
fs/ufs/super.c +3 -3
@@ -1311,10 +1311,10 @@ out:#endif -static struct super_block *ufs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int ufs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, ufs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, ufs_fill_super, mnt); }static struct file_system_type ufs_fs_type = {
fs/vfat/namei.c +5 -4
@@ -1023,11 +1023,12 @@ static int vfat_fill_super(struct super_return 0 ; } -static struct super_block *vfat_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name, -void *data) +static int vfat_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name, +void *data,struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, vfat_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, vfat_fill_super, + mnt); }static struct file_system_type vfat_fs_type = {
fs/xfs/linux-2.6/xfs_super.c +5 -3
@@ -900,14 +900,16 @@ fail_vfsop:return -error; } -STATIC struct super_block * +STATIC intxfs_fs_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name, -void *data) +void *data, +struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, xfs_fs_fill_super); +return get_sb_bdev (fs_type, flags, dev_name, data, xfs_fs_fill_super, + mnt); } STATIC struct super_operations xfs_super_operations = {
include/linux/fs.h +15 -10
@@ -1270,23 +1270,26 @@ find_exported_dentry(struct super_blockstruct file_system_type {const char *name;int fs_flags; -struct super_block *(*get_sb) (struct file_system_type *,int , -const char *,void *); +int (*get_sb) (struct file_system_type *,int , +const char *,void *,struct vfsmount *);void (*kill_sb) (struct super_block *);struct module *owner;struct file_system_type * next;struct list_head fs_supers; }; -struct super_block *get_sb_bdev (struct file_system_type *fs_type, +extern int get_sb_bdev (struct file_system_type *fs_type,int flags,const char *dev_name,void *data, -int (*fill_super)(struct super_block *,void *,int )); -struct super_block *get_sb_single (struct file_system_type *fs_type, +int (*fill_super)(struct super_block *,void *,int ), +struct vfsmount *mnt); +extern int get_sb_single (struct file_system_type *fs_type,int flags,void *data, -int (*fill_super)(struct super_block *,void *,int )); -struct super_block *get_sb_nodev (struct file_system_type *fs_type, +int (*fill_super)(struct super_block *,void *,int ), +struct vfsmount *mnt); +extern int get_sb_nodev (struct file_system_type *fs_type,int flags,void *data, -int (*fill_super)(struct super_block *,void *,int )); +int (*fill_super)(struct super_block *,void *,int ), +struct vfsmount *mnt);void generic_shutdown_super (struct super_block *sb);void kill_block_super (struct super_block *sb);void kill_anon_super (struct super_block *sb);
@@ -1297,8 +1300,10 @@ struct super_block *sget(struct file_sysint (*test)(struct super_block *,void *), int (*set)(struct super_block *,void *), void *data); -struct super_block *get_sb_pseudo (struct file_system_type *,char *, -struct super_operations *ops,unsigned long ); +extern int get_sb_pseudo (struct file_system_type *,char *, +struct super_operations *ops,unsigned long , +struct vfsmount *mnt); +extern int simple_set_mnt (struct vfsmount *mnt,struct super_block *sb);int __put_super (struct super_block *sb);int __put_super_and_need_restart (struct super_block *sb);void unnamed_dev_init (void );
include/linux/ramfs.h +2 -2
@@ -2,8 +2,8 @@ #ifndef _LINUX_RAMFS_H#define _LINUX_RAMFS_Hstruct inode *ramfs_get_inode (struct super_block *sb,int mode,dev_t dev); -struct super_block *ramfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data); +extern int ramfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt);#ifndef CONFIG_MMU extern unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
ipc/mqueue.c +4 -4
@@ -202,11 +202,11 @@ static int mqueue_fill_super(struct supereturn 0 ; } -static struct super_block *mqueue_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name, -void *data) +static int mqueue_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name, +void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, mqueue_fill_super); +return get_sb_single (fs_type, flags, data, mqueue_fill_super, mnt); }static void init_once (void *foo,kmem_cache_t * cachep,unsigned long flags)
kernel/cpuset.c +4 -4
@@ -392,11 +392,11 @@ static int cpuset_fill_super(struct supereturn 0 ; } -static struct super_block *cpuset_get_sb (struct file_system_type *fs_type, -int flags,const char *unused_dev_name, -void *data) +static int cpuset_get_sb (struct file_system_type *fs_type, +int flags,const char *unused_dev_name, +void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, cpuset_fill_super); +return get_sb_single (fs_type, flags, data, cpuset_fill_super, mnt); }static struct file_system_type cpuset_fs_type = {
kernel/futex.c +4 -4
@@ -1056,11 +1056,11 @@ asmlinkage long sys_futex(u32 __user *ua (unsigned long)uaddr2, val2, val3); } -static struct super_block * -futexfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int futexfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data, +struct vfsmount *mnt) { -return get_sb_pseudo (fs_type,"futex" ,NULL ,0xBAD1DEA ); +return get_sb_pseudo (fs_type,"futex" ,NULL ,0xBAD1DEA , mnt); }static struct file_system_type futex_fs_type = {
mm/shmem.c +3 -3
@@ -2231,10 +2231,10 @@ #endif }; -static struct super_block *shmem_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int shmem_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, shmem_fill_super); +return get_sb_nodev (fs_type, flags, data, shmem_fill_super, mnt); }static struct file_system_type tmpfs_fs_type = {
net/socket.c +4 -3
@@ -335,10 +335,11 @@ static struct super_operations sockfs_op .statfs = simple_statfs, }; -static struct super_block *sockfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int sockfs_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_pseudo (fs_type,"socket:" , &sockfs_ops,SOCKFS_MAGIC ); +return get_sb_pseudo (fs_type,"socket:" , &sockfs_ops,SOCKFS_MAGIC , + mnt); }static struct vfsmount *sock_mnt__read_mostly ;
net/sunrpc/rpc_pipe.c +3 -3
@@ -815,11 +815,11 @@ out:return -ENOMEM ; } -static struct super_block * +static int rpc_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, rpc_fill_super); +return get_sb_single (fs_type, flags, data, rpc_fill_super, mnt); }static struct file_system_type rpc_pipe_fs_type = {
security/inode.c +4 -4
@@ -135,11 +135,11 @@ static int fill_super(struct super_blockreturn simple_fill_super (sb,SECURITYFS_MAGIC , files); } -static struct super_block *get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name, -void *data) +static int get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name, +void *data,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, fill_super); +return get_sb_single (fs_type, flags, data, fill_super, mnt); }static struct file_system_type fs_type = {
security/selinux/selinuxfs.c +4 -3
@@ -1279,10 +1279,11 @@ err: goto out; } -static struct super_block *sel_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int sel_get_sb (struct file_system_type *fs_type, +int flags,const char *dev_name,void *data, +struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, sel_fill_super); +return get_sb_single (fs_type, flags, data, sel_fill_super, mnt); }static struct file_system_type sel_fs_type = {
Re: [PATCH 01/14] NFS: Permit filesystem to override root dentry on mount [try #10]
Documentation/filesystems/porting Turn your foo_read_super() into a functi · line 58
Quoted 11 lines · David Howells
informative error value to report). Call it
foo_fill_super(). Now declareDocumentation/filesystems/porting +4
-3-struct super_block foo_get_sb(struct file_system_type *fs_type, - int flags, const char *dev_name, void *data) +int foo_get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, void *data, struct vfsmount *mnt) { - return get_sb_bdev(fs_type, flags, dev_name, data, ext2_fill_super); + return get_sb_bdev(fs_type, flags, dev_name, data, ext2_fill_super, + mnt); }
BTW, s/ext2_fill_super/foo_fill_super/, while we are at it...
fs/super.c EXPORT_SYMBOL(get_sb_single); · line 841
Quoted 3 lines
fs/super.c +3
-0+BUG_ON (!mnt->mnt_sb); +BUG_ON (!mnt->mnt_sb->s_root); +BUG_ON (!mnt->mnt_root);
FWIW, I'm not sure it's needed. We do
Review
Quoted 1 line
(quoted diff) +1
-0+ up_write(&mnt->mnt_sb->s_umount);
soon enough and it will catch all likely breakage without cluttering the code with BUG_ON(). Other than that, no objections.
David Howells
maintainerPATCH 2/14 NFS: Permit filesystem to perform statfs with a known root dentry [try #10]
In reply to David HowellsThe attached patch gives the statfs superblock operation a vfsmount pointer rather than a superblock pointer.
This complements the get_sb() patch. That reduced the significance of sb->s_root, allowing NFS to place a fake root there. However, NFS does require a dentry to use as a target for the statfs operation. This permits the root in the vfsmount to be used instead.
Further changes [try #9] that have been made:
(*) Inclusions of linux/mount.h have been added where necessary to make
allyesconfig build successfully.
Further changes [try #10] that have been made:
(*) Pass a dentry rather than a vfsmount to the statfs() op as the key by
which to determine the filesystem.
---
Documentation/filesystems/Locking | 2 +- Documentation/filesystems/vfs.txt | 2 +- arch/alpha/kernel/osf_sys.c | 2 +- arch/mips/kernel/sysirix.c | 12 ++++++------ arch/parisc/hpux/sys_hpux.c | 10 +++++----- arch/sparc64/solaris/fs.c | 4 ++-- fs/adfs/super.c | 8 ++++---- fs/affs/super.c | 5 +++-- fs/befs/linuxvfs.c | 5 +++-- fs/bfs/inode.c | 3 ++- fs/cifs/cifsfs.c | 3 ++- fs/coda/inode.c | 6 +++--- fs/coda/upcall.c | 4 ++-- fs/compat.c | 8 ++++---- fs/cramfs/inode.c | 4 +++- fs/efs/super.c | 6 +++--- fs/ext2/super.c | 5 +++-- fs/ext3/super.c | 5 +++-- fs/fat/inode.c | 8 ++++---- fs/freevxfs/vxfs_super.c | 13 +++++++------ fs/fuse/inode.c | 3 ++- fs/hfs/super.c | 4 +++- fs/hfsplus/super.c | 4 +++- fs/hostfs/hostfs_kern.c | 4 ++-- fs/hpfs/super.c | 3 ++- fs/hppfs/hppfs_kern.c | 2 +- fs/hugetlbfs/inode.c | 4 ++-- fs/isofs/inode.c | 6 ++++-- fs/jffs/inode-v23.c | 4 ++-- fs/jffs2/fs.c | 4 ++-- fs/jffs2/os-linux.h | 2 +- fs/jfs/super.c | 4 ++-- fs/libfs.c | 4 ++-- fs/minix/inode.c | 10 +++++----- fs/ncpfs/inode.c | 5 +++-- fs/nfs/inode.c | 5 +++-- fs/nfsd/nfs4xdr.c | 2 +- fs/nfsd/vfs.c | 2 +- fs/ntfs/super.c | 7 ++++--- fs/ocfs2/super.c | 10 +++++----- fs/open.c | 26 +++++++++++++------------- fs/qnx4/inode.c | 6 ++++-- fs/reiserfs/super.c | 8 ++++---- fs/romfs/inode.c | 4 ++-- fs/smbfs/inode.c | 6 +++--- fs/smbfs/proc.c | 4 ++-- fs/smbfs/proto.h | 2 +- fs/super.c | 2 +- fs/sysv/inode.c | 3 ++- fs/udf/super.c | 6 ++++-- fs/ufs/super.c | 3 ++- fs/xfs/linux-2.6/xfs_super.c | 4 ++-- include/linux/coda_psdev.h | 2 +- include/linux/fs.h | 6 +++--- include/linux/mount.h | 5 +++++ include/linux/security.h | 14 +++++++------- kernel/acct.c | 2 +- mm/shmem.c | 4 ++-- security/dummy.c | 2 +- security/selinux/hooks.c | 6 +++--- 60 files changed, 175 insertions(+), 144 deletions(-)
Documentation/filesystems/Locking +1 -1
@@ -99,7 +99,7 @@ prototypes: int (*sync_fs)(struct super_block *sb, int wait); void (*write_super_lockfs) (struct super_block *); void (*unlockfs) (struct super_block *); - int (*statfs) (struct super_block *, struct kstatfs *); + int (*statfs) (struct dentry *, struct kstatfs *); int (*remount_fs) (struct super_block *, int *, char *); void (*clear_inode) (struct inode *); void (*umount_begin) (struct super_block *);
Documentation/filesystems/vfs.txt +1 -1
@@ -211,7 +211,7 @@ struct super_operations { int (*sync_fs)(struct super_block *sb, int wait); void (*write_super_lockfs) (struct super_block *); void (*unlockfs) (struct super_block *); - int (*statfs) (struct super_block *, struct kstatfs *); + int (*statfs) (struct dentry *, struct kstatfs *); int (*remount_fs) (struct super_block *, int *, char *); void (*clear_inode) (struct inode *); void (*umount_begin) (struct super_block *);
arch/alpha/kernel/osf_sys.c +1 -1
@@ -244,7 +244,7 @@ do_osf_statfs(struct dentry * dentry, st unsigned long bufsiz) {struct kstatfs linux_stat; -int error =vfs_statfs (dentry->d_inode->i_sb, &linux_stat); +int error =vfs_statfs (dentry, &linux_stat);if (!error) error =linux_to_osf_statfs (&linux_stat, buffer, bufsiz);return error;
arch/mips/kernel/sysirix.c +6 -6
@@ -694,7 +694,7 @@ asmlinkage int irix_statfs(const char __if (error) goto out; - error =vfs_statfs (nd.dentry->d_inode->i_sb, &kbuf); + error =vfs_statfs (nd.dentry, &kbuf);if (error) goto dput_and_out;
@@ -732,7 +732,7 @@ asmlinkage int irix_fstatfs(unsigned int goto out; } - error =vfs_statfs (file->f_dentry->d_inode->i_sb, &kbuf); + error =vfs_statfs (file->f_dentry, &kbuf);if (error) goto out_f;
@@ -1360,7 +1360,7 @@ asmlinkage int irix_statvfs(char __user error =user_path_walk (fname, &nd);if (error) goto out; - error =vfs_statfs (nd.dentry->d_inode->i_sb, &kbuf); + error =vfs_statfs (nd.dentry, &kbuf);if (error) goto dput_and_out;
@@ -1406,7 +1406,7 @@ asmlinkage int irix_fstatvfs(int fd, str error = -EBADF ; goto out; } - error =vfs_statfs (file->f_dentry->d_inode->i_sb, &kbuf); + error =vfs_statfs (file->f_dentry, &kbuf);if (error) goto out_f;
@@ -1611,7 +1611,7 @@ asmlinkage int irix_statvfs64(char __use error =user_path_walk (fname, &nd);if (error) goto out; - error =vfs_statfs (nd.dentry->d_inode->i_sb, &kbuf); + error =vfs_statfs (nd.dentry, &kbuf);if (error) goto dput_and_out;
@@ -1658,7 +1658,7 @@ asmlinkage int irix_fstatvfs64(int fd, s error = -EBADF ; goto out; } - error =vfs_statfs (file->f_dentry->d_inode->i_sb, &kbuf); + error =vfs_statfs (file->f_dentry, &kbuf);if (error) goto out_f;
arch/parisc/hpux/sys_hpux.c +5 -5
@@ -145,7 +145,7 @@ static int hpux_ustat(dev_t dev, struct s =user_get_super (dev);if (s ==NULL ) goto out; - err =vfs_statfs (s, &sbuf); + err =vfs_statfs (s->s_root, &sbuf);drop_super (s);if (err) goto out;
@@ -186,12 +186,12 @@ struct hpux_statfs {int16_t f_pad; }; -static int vfs_statfs_hpux (struct super_block *sb,struct hpux_statfs *buf) +static int vfs_statfs_hpux (struct dentry *dentry,struct hpux_statfs *buf) {struct kstatfs st;int retval; - retval =vfs_statfs (sb, &st); + retval =vfs_statfs (dentry, &st);if (retval)return retval;
@@ -219,7 +219,7 @@ asmlinkage long hpux_statfs(const char _ error =user_path_walk (path, &nd);if (!error) {struct hpux_statfs tmp; - error =vfs_statfs_hpux (nd.dentry->d_inode->i_sb, &tmp); + error =vfs_statfs_hpux (nd.dentry, &tmp);if (!error &©_to_user (buf, &tmp,sizeof (tmp))) error = -EFAULT ;path_release (&nd);
@@ -237,7 +237,7 @@ asmlinkage long hpux_fstatfs(unsigned in file =fget (fd);if (!file) goto out; - error =vfs_statfs_hpux (file->f_dentry->d_inode->i_sb, &tmp); + error =vfs_statfs_hpux (file->f_dentry, &tmp);if (!error &©_to_user (buf, &tmp,sizeof (tmp))) error = -EFAULT ;fput (file);
arch/sparc64/solaris/fs.c +2 -2
@@ -356,7 +356,7 @@ static int report_statvfs(struct vfsmounint error;struct sol_statvfs __user *ss =A (buf); - error =vfs_statfs (mnt->mnt_sb, &s); + error =vfs_statfs (mnt->mnt_root, &s);if (!error) {const char *p = mnt->mnt_sb->s_type->name;int i =0 ;
@@ -392,7 +392,7 @@ static int report_statvfs64(struct vfsmoint error;struct sol_statvfs64 __user *ss =A (buf); - error =vfs_statfs (mnt->mnt_sb, &s); + error =vfs_statfs (mnt->mnt_root, &s);if (!error) {const char *p = mnt->mnt_sb->s_type->name;int i =0 ;
fs/adfs/super.c +4 -4
@@ -196,17 +196,17 @@ static int adfs_remount(struct super_bloreturn parse_options (sb, data); } -static int adfs_statfs (struct super_block *sb,struct kstatfs *buf) +static int adfs_statfs (struct dentry *dentry,struct kstatfs *buf) { -struct adfs_sb_info *asb =ADFS_SB (sb); +struct adfs_sb_info *asb =ADFS_SB (dentry->d_sb); buf->f_type =ADFS_SUPER_MAGIC ; buf->f_namelen = asb->s_namelen; - buf->f_bsize = sb->s_blocksize; + buf->f_bsize = dentry->d_sb->s_blocksize; buf->f_blocks = asb->s_size; buf->f_files = asb->s_ids_per_zone * asb->s_map_size; buf->f_bavail = - buf->f_bfree =adfs_map_free (sb); + buf->f_bfree =adfs_map_free (dentry->d_sb); buf->f_ffree = (long )(buf->f_bfree * buf->f_files) / (long )buf->f_blocks;return 0 ;
fs/affs/super.c +3 -2
@@ -18,7 +18,7 @@ #include "affs.h"extern struct timezone sys_tz; -static int affs_statfs (struct super_block *sb,struct kstatfs *buf); +static int affs_statfs (struct dentry *dentry,struct kstatfs *buf);static int affs_remount (struct super_block *sb,int *flags,char *data); static void
@@ -508,8 +508,9 @@ affs_remount(struct super_block *sb, int }static int -affs_statfs (struct super_block *sb,struct kstatfs *buf) +affs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb;int free; pr_debug("AFFS: statfs() partsize=%d, reserved=%d\n",AFFS_SB(sb)->s_partition_size,
fs/befs/linuxvfs.c +3 -2
@@ -49,7 +49,7 @@ static int befs_nls2utf(struct super_blo char **out, int *out_len);static void befs_put_super (struct super_block *);static int befs_remount (struct super_block *,int *,char *); -static int befs_statfs (struct super_block *,struct kstatfs *); +static int befs_statfs (struct dentry *,struct kstatfs *);static int parse_options (char *,befs_mount_options *);static const struct super_operations befs_sops = {
@@ -880,8 +880,9 @@ befs_remount(struct super_block *sb, int }static int -befs_statfs (struct super_block *sb,struct kstatfs *buf) +befs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb;befs_debug (sb,"---> befs_statfs()" );
fs/bfs/inode.c +2 -1
@@ -203,8 +203,9 @@ static void bfs_put_super(struct super_b s->s_fs_info =NULL ; } -static int bfs_statfs (struct super_block *s,struct kstatfs *buf) +static int bfs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *s = dentry->d_sb;struct bfs_sb_info *info =BFS_SB (s);u64 id =huge_encode_dev (s->s_bdev->bd_dev); buf->f_type =BFS_MAGIC ;
fs/cifs/cifsfs.c +2 -1
@@ -166,8 +166,9 @@ cifs_put_super(struct super_block *sb) }static int -cifs_statfs (struct super_block *sb,struct kstatfs *buf) +cifs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb;int xid;int rc = -EOPNOTSUPP ;struct cifs_sb_info *cifs_sb;
fs/coda/inode.c +3 -3
@@ -36,7 +36,7 @@ #include "coda_int.h"/* VFS super_block ops */ static void coda_clear_inode (struct inode *);static void coda_put_super (struct super_block *); -static int coda_statfs (struct super_block *sb,struct kstatfs *buf); +static int coda_statfs (struct dentry *dentry,struct kstatfs *buf);static kmem_cache_t * coda_inode_cachep;
@@ -278,13 +278,13 @@ struct inode_operations coda_file_inode_ .setattr = coda_setattr, }; -static int coda_statfs (struct super_block *sb,struct kstatfs *buf) +static int coda_statfs (struct dentry *dentry,struct kstatfs *buf) {int error;lock_kernel (); - error =venus_statfs (sb, buf); + error =venus_statfs (dentry, buf);unlock_kernel ();
fs/coda/upcall.c +2 -2
@@ -611,7 +611,7 @@ int venus_pioctl(struct super_block *sb,return error; } -int venus_statfs (struct super_block *sb,struct kstatfs *sfs) +int venus_statfs (struct dentry *dentry,struct kstatfs *sfs) {union inputArgs *inp;union outputArgs *outp;
@@ -620,7 +620,7 @@ int venus_statfs(struct super_block *sb, insize = max_t(unsigned int, INSIZE(statfs), OUTSIZE(statfs));UPARG (CODA_STATFS ); - error =coda_upcall (coda_sbp (sb), insize, &outsize, inp); + error =coda_upcall (coda_sbp (dentry->d_sb), insize, &outsize, inp);if (!error) { sfs->f_blocks = outp->coda_statfs.stat.f_blocks;
fs/compat.c +4 -4
@@ -197,7 +197,7 @@ asmlinkage long compat_sys_statfs(const error =user_path_walk (path, &nd);if (!error) {struct kstatfs tmp; - error =vfs_statfs (nd.dentry->d_inode->i_sb, &tmp); + error =vfs_statfs (nd.dentry, &tmp);if (!error) error =put_compat_statfs (buf, &tmp);path_release (&nd);
@@ -215,7 +215,7 @@ asmlinkage long compat_sys_fstatfs(unsig file =fget (fd);if (!file) goto out; - error =vfs_statfs (file->f_dentry->d_inode->i_sb, &tmp); + error =vfs_statfs (file->f_dentry, &tmp);if (!error) error =put_compat_statfs (buf, &tmp);fput (file);
@@ -265,7 +265,7 @@ asmlinkage long compat_sys_statfs64(cons error =user_path_walk (path, &nd);if (!error) {struct kstatfs tmp; - error =vfs_statfs (nd.dentry->d_inode->i_sb, &tmp); + error =vfs_statfs (nd.dentry, &tmp);if (!error) error =put_compat_statfs64 (buf, &tmp);path_release (&nd);
@@ -286,7 +286,7 @@ asmlinkage long compat_sys_fstatfs64(uns file =fget (fd);if (!file) goto out; - error =vfs_statfs (file->f_dentry->d_inode->i_sb, &tmp); + error =vfs_statfs (file->f_dentry, &tmp);if (!error) error =put_compat_statfs64 (buf, &tmp);fput (file);
fs/cramfs/inode.c +3 -1
@@ -322,8 +322,10 @@ out:return -EINVAL ; } -static int cramfs_statfs (struct super_block *sb,struct kstatfs *buf) +static int cramfs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb; + buf->f_type =CRAMFS_MAGIC ; buf->f_bsize =PAGE_CACHE_SIZE ; buf->f_blocks =CRAMFS_SB (sb)->blocks;
fs/efs/super.c +3 -3
@@ -15,7 +15,7 @@ #include <linux/slab.h>#include <linux/buffer_head.h> #include <linux/vfs.h> -static int efs_statfs (struct super_block *s,struct kstatfs *buf); +static int efs_statfs (struct dentry *dentry,struct kstatfs *buf);static int efs_fill_super (struct super_block *s,void *d,int silent); static int efs_get_sb(struct file_system_type *fs_type,
@@ -322,8 +322,8 @@ out_no_fs:return -EINVAL ; } -static int efs_statfs (struct super_block *s,struct kstatfs *buf) { -struct efs_sb_info *sb =SUPER_INFO (s); +static int efs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct efs_sb_info *sb =SUPER_INFO (dentry->d_sb); buf->f_type =EFS_SUPER_MAGIC ;/* efs magic number */ buf->f_bsize =EFS_BLOCKSIZE ;/* blocksize */
fs/ext2/super.c +3 -2
@@ -39,7 +39,7 @@ #include "xip.h"static void ext2_sync_super (struct super_block *sb,struct ext2_super_block *es);static int ext2_remount (struct super_block * sb,int * flags,char * data); -static int ext2_statfs (struct super_block * sb,struct kstatfs * buf); +static int ext2_statfs (struct dentry * dentry,struct kstatfs * buf);void ext2_error (struct super_block * sb,const char * function,const char * fmt, ...)
@@ -1038,8 +1038,9 @@ restore_opts:return err; } -static int ext2_statfs (struct super_block * sb,struct kstatfs * buf) +static int ext2_statfs (struct dentry * dentry,struct kstatfs * buf) { +struct super_block *sb = dentry->d_sb;struct ext2_sb_info *sbi =EXT2_SB (sb);unsigned long overhead;int i;
fs/ext3/super.c +3 -2
@@ -58,7 +58,7 @@ static int ext3_sync_fs(struct super_blostatic const char *ext3_decode_error (struct super_block * sb,int errno,char nbuf[16 ]);static int ext3_remount (struct super_block * sb,int * flags,char * data); -static int ext3_statfs (struct super_block * sb,struct kstatfs * buf); +static int ext3_statfs (struct dentry * dentry,struct kstatfs * buf);static void ext3_unlockfs (struct super_block *sb);static void ext3_write_super (struct super_block * sb);static void ext3_write_super_lockfs (struct super_block *sb);
@@ -2318,8 +2318,9 @@ #endifreturn err; } -static int ext3_statfs (struct super_block * sb,struct kstatfs * buf) +static int ext3_statfs (struct dentry * dentry,struct kstatfs * buf) { +struct super_block *sb = dentry->d_sb;struct ext3_sb_info *sbi =EXT3_SB (sb);struct ext3_super_block *es = sbi->s_es;unsigned long overhead;
fs/fat/inode.c +4 -4
@@ -539,18 +539,18 @@ static int fat_remount(struct super_blocreturn 0 ; } -static int fat_statfs (struct super_block *sb,struct kstatfs *buf) +static int fat_statfs (struct dentry *dentry,struct kstatfs *buf) { -struct msdos_sb_info *sbi =MSDOS_SB (sb); +struct msdos_sb_info *sbi =MSDOS_SB (dentry->d_sb);/* If the count of free cluster is still unknown, counts it here. */ if (sbi->free_clusters ==-1 ) { -int err =fat_count_free_clusters (sb); +int err =fat_count_free_clusters (dentry->d_sb);if (err)return err; } - buf->f_type = sb->s_magic; + buf->f_type = dentry->d_sb->s_magic; buf->f_bsize = sbi->cluster_size; buf->f_blocks = sbi->max_cluster -FAT_START_ENT ; buf->f_bfree = sbi->free_clusters;
fs/freevxfs/vxfs_super.c +7 -6
@@ -40,6 +40,7 @@ #include <linux/kernel.h>#include <linux/slab.h> #include <linux/stat.h> #include <linux/vfs.h> +#include <linux/mount.h> #include "vxfs.h" #include "vxfs_extern.h"
@@ -55,7 +56,7 @@ MODULE_ALIAS("vxfs"); /* makes mount -tstatic void vxfs_put_super (struct super_block *); -static int vxfs_statfs (struct super_block *,struct kstatfs *); +static int vxfs_statfs (struct dentry *,struct kstatfs *);static int vxfs_remount (struct super_block *,int *,char *);static struct super_operations vxfs_super_ops = {
@@ -90,12 +91,12 @@ vxfs_put_super(struct super_block *sbp)/** * vxfs_statfs - get filesystem information -* @sbp: VFS superblock +* @dentry: VFS dentry to locate superblock * @bufp: output buffer * * Description: * vxfs_statfs fills the statfs buffer @bufp with information -* about the filesystem described by @sbp. +* about the filesystem described by @dentry. * * Returns: * Zero.
@@ -107,12 +108,12 @@ vxfs_put_super(struct super_block *sbp)* This is everything but complete... */ static int -vxfs_statfs (struct super_block *sbp,struct kstatfs *bufp) +vxfs_statfs (struct dentry *dentry,struct kstatfs *bufp) { -struct vxfs_sb_info *infp =VXFS_SBI (sbp); +struct vxfs_sb_info *infp =VXFS_SBI (dentry->d_sb); bufp->f_type =VXFS_SUPER_MAGIC ; - bufp->f_bsize = sbp->s_blocksize; + bufp->f_bsize = dentry->d_sb->s_blocksize; bufp->f_blocks = infp->vsi_raw->vs_dsize; bufp->f_bfree = infp->vsi_raw->vs_free; bufp->f_bavail =0 ;
fs/fuse/inode.c +2 -1
@@ -237,8 +237,9 @@ static void convert_fuse_statfs(struct k/* fsid is left zero */ } -static int fuse_statfs (struct super_block *sb,struct kstatfs *buf) +static int fuse_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb;struct fuse_conn *fc =get_fuse_conn_super (sb);struct fuse_req *req;struct fuse_statfs_out outarg;
fs/hfs/super.c +3 -1
@@ -80,8 +80,10 @@ static void hfs_put_super(struct super_b* * changed f_files/f_ffree to reflect the fs_ablock/free_ablocks. */ -static int hfs_statfs (struct super_block *sb,struct kstatfs *buf) +static int hfs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb; + buf->f_type =HFS_SUPER_MAGIC ; buf->f_bsize = sb->s_blocksize; buf->f_blocks = (u32 )HFS_SB (sb)->fs_ablocks *HFS_SB (sb)->fs_div;
fs/hfsplus/super.c +3 -1
@@ -212,8 +212,10 @@ static void hfsplus_put_super(struct sup sb->s_fs_info =NULL ; } -static int hfsplus_statfs (struct super_block *sb,struct kstatfs *buf) +static int hfsplus_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb; + buf->f_type =HFSPLUS_SUPER_MAGIC ; buf->f_bsize = sb->s_blocksize; buf->f_blocks =HFSPLUS_SB (sb).total_blocks <<HFSPLUS_SB (sb).fs_shift;
fs/hostfs/hostfs_kern.c +2 -2
@@ -239,7 +239,7 @@ static int read_inode(struct inode *ino)return (err); } -int hostfs_statfs (struct super_block *sb,struct kstatfs *sf) +int hostfs_statfs (struct dentry *dentry,struct kstatfs *sf) {/* do_statfs uses struct statfs64 internally, but the linux kernel * struct statfs still has 32-bit versions for most of these fields,
@@ -252,7 +252,7 @@ int hostfs_statfs(struct super_block *sblong long f_files;long long f_ffree; - err =do_statfs (HOSTFS_I (sb->s_root->d_inode)->host_filename, + err =do_statfs (HOSTFS_I (dentry->d_sb->s_root->d_inode)->host_filename, &sf->f_bsize, &f_blocks, &f_bfree, &f_bavail, &f_files, &f_ffree, &sf->f_fsid,sizeof (sf->f_fsid), &sf->f_namelen, sf->f_spare);
fs/hpfs/super.c +2 -1
@@ -135,8 +135,9 @@ static unsigned count_bitmaps(struct supreturn count; } -static int hpfs_statfs (struct super_block *s,struct kstatfs *buf) +static int hpfs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *s = dentry->d_sb;struct hpfs_sb_info *sbi =hpfs_sb (s);lock_kernel ();
fs/hppfs/hppfs_kern.c +1 -1
@@ -616,7 +616,7 @@ static const struct file_operations hppf .fsync = hppfs_fsync, }; -static int hppfs_statfs (struct super_block *sb,struct kstatfs *sf) +static int hppfs_statfs (struct dentry *dentry,struct kstatfs *sf) { sf->f_blocks =0 ; sf->f_bfree =0 ;
fs/hugetlbfs/inode.c +2 -2
@@ -467,9 +467,9 @@ static int hugetlbfs_set_page_dirty(strureturn 0 ; } -static int hugetlbfs_statfs (struct super_block *sb,struct kstatfs *buf) +static int hugetlbfs_statfs (struct dentry *dentry,struct kstatfs *buf) { -struct hugetlbfs_sb_info *sbinfo =HUGETLBFS_SB (sb); +struct hugetlbfs_sb_info *sbinfo =HUGETLBFS_SB (dentry->d_sb); buf->f_type =HUGETLBFS_MAGIC ; buf->f_bsize =HPAGE_SIZE ;
fs/isofs/inode.c +4 -2
@@ -56,7 +56,7 @@ #endif }static void isofs_read_inode (struct inode *); -static int isofs_statfs (struct super_block *,struct kstatfs *); +static int isofs_statfs (struct dentry *,struct kstatfs *);static kmem_cache_t *isofs_inode_cachep;
@@ -901,8 +901,10 @@ out_freesbi:return -EINVAL ; } -static int isofs_statfs (struct super_block *sb,struct kstatfs *buf) +static int isofs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb; + buf->f_type =ISOFS_SUPER_MAGIC ; buf->f_bsize = sb->s_blocksize; buf->f_blocks = (ISOFS_SB(sb)->s_nzones
fs/jffs/inode-v23.c +2 -2
@@ -377,9 +377,9 @@ jffs_new_inode(const struct inode * dir,/* Get statistics of the file system. */ static int -jffs_statfs (struct super_block *sb,struct kstatfs *buf) +jffs_statfs (struct dentry *dentry,struct kstatfs *buf) { -struct jffs_control *c = (struct jffs_control *) sb->s_fs_info; +struct jffs_control *c = (struct jffs_control *) dentry->d_sb->s_fs_info;struct jffs_fmcontrol *fmc;lock_kernel ();
fs/jffs2/fs.c +2 -2
@@ -183,9 +183,9 @@ int jffs2_setattr(struct dentry *dentry,return jffs2_do_setattr (dentry->d_inode, iattr); } -int jffs2_statfs (struct super_block *sb,struct kstatfs *buf) +int jffs2_statfs (struct dentry *dentry,struct kstatfs *buf) { -struct jffs2_sb_info *c =JFFS2_SB_INFO (sb); +struct jffs2_sb_info *c =JFFS2_SB_INFO (dentry->d_sb);unsigned long avail; buf->f_type =JFFS2_SUPER_MAGIC ;
fs/jffs2/os-linux.h +1 -1
@@ -182,7 +182,7 @@ void jffs2_clear_inode (struct inode *);void jffs2_dirty_inode (struct inode *inode);struct inode *jffs2_new_inode (struct inode *dir_i,int mode,struct jffs2_raw_inode *ri); -int jffs2_statfs (struct super_block *,struct kstatfs *); +int jffs2_statfs (struct dentry *,struct kstatfs *);void jffs2_write_super (struct super_block *);int jffs2_remount_fs (struct super_block *,int *,char *);int jffs2_do_fill_super (struct super_block *sb,void *data,int silent);
fs/jfs/super.c +2 -2
@@ -139,9 +139,9 @@ #endifkmem_cache_free (jfs_inode_cachep, ji); } -static int jfs_statfs (struct super_block *sb,struct kstatfs *buf) +static int jfs_statfs (struct dentry *dentry,struct kstatfs *buf) { -struct jfs_sb_info *sbi =JFS_SBI (sb); +struct jfs_sb_info *sbi =JFS_SBI (dentry->d_sb);s64 maxinodes;struct inomap *imap =JFS_IP (sbi->ipimap)->i_imap;
fs/libfs.c +2 -2
@@ -20,9 +20,9 @@ int simple_getattr(struct vfsmount *mnt,return 0 ; } -int simple_statfs (struct super_block *sb,struct kstatfs *buf) +int simple_statfs (struct dentry *dentry,struct kstatfs *buf) { - buf->f_type = sb->s_magic; + buf->f_type = dentry->d_sb->s_magic; buf->f_bsize =PAGE_CACHE_SIZE ; buf->f_namelen =NAME_MAX ;return 0 ;
fs/minix/inode.c +5 -5
@@ -19,7 +19,7 @@ #include <linux/vfs.h>static void minix_read_inode (struct inode * inode);static int minix_write_inode (struct inode * inode,int wait); -static int minix_statfs (struct super_block *sb,struct kstatfs *buf); +static int minix_statfs (struct dentry *dentry,struct kstatfs *buf);static int minix_remount (struct super_block * sb,int * flags,char * data);static void minix_delete_inode (struct inode *inode)
@@ -296,11 +296,11 @@ out_bad_sb:return -EINVAL ; } -static int minix_statfs (struct super_block *sb,struct kstatfs *buf) +static int minix_statfs (struct dentry *dentry,struct kstatfs *buf) { -struct minix_sb_info *sbi =minix_sb (sb); - buf->f_type = sb->s_magic; - buf->f_bsize = sb->s_blocksize; +struct minix_sb_info *sbi =minix_sb (dentry->d_sb); + buf->f_type = dentry->d_sb->s_magic; + buf->f_bsize = dentry->d_sb->s_blocksize; buf->f_blocks = (sbi->s_nzones - sbi->s_firstdatazone) << sbi->s_log_zone_size; buf->f_bfree =minix_count_free_blocks (sbi); buf->f_bavail = buf->f_bfree;
fs/ncpfs/inode.c +3 -2
@@ -39,7 +39,7 @@ #include "getopt.h"static void ncp_delete_inode (struct inode *);static void ncp_put_super (struct super_block *); -static int ncp_statfs (struct super_block *,struct kstatfs *); +static int ncp_statfs (struct dentry *,struct kstatfs *);static kmem_cache_t * ncp_inode_cachep;
@@ -724,13 +724,14 @@ #endif /* CONFIG_NCPFS_NLS */kfree (server); } -static int ncp_statfs (struct super_block *sb,struct kstatfs *buf) +static int ncp_statfs (struct dentry *dentry,struct kstatfs *buf) {struct dentry * d;struct inode * i;struct ncp_inode_info * ni;struct ncp_server * s;struct ncp_volume_info vi; +struct super_block *sb = dentry->d_sb;int err;__u8 dh;
fs/nfs/inode.c +3 -2
@@ -67,7 +67,7 @@ static int nfs_write_inode(struct inodestatic void nfs_delete_inode (struct inode *);static void nfs_clear_inode (struct inode *);static void nfs_umount_begin (struct vfsmount *,int ); -static int nfs_statfs (struct super_block *,struct kstatfs *); +static int nfs_statfs (struct dentry *,struct kstatfs *);static int nfs_show_options (struct seq_file *,struct vfsmount *);static int nfs_show_stats (struct seq_file *,struct vfsmount *);static void nfs_zap_acl_cache (struct inode *);
@@ -548,8 +548,9 @@ #endif /* CONFIG_NFS_V3_ACL */ }static int -nfs_statfs (struct super_block *sb,struct kstatfs *buf) +nfs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb;struct nfs_server *server =NFS_SB (sb);unsigned char blockbits;unsigned long blockres;
fs/nfsd/nfs4xdr.c +1 -1
@@ -1310,7 +1310,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, sif ((bmval0 & (FATTR4_WORD0_FILES_FREE |FATTR4_WORD0_FILES_TOTAL )) || (bmval1 & (FATTR4_WORD1_SPACE_AVAIL |FATTR4_WORD1_SPACE_FREE |FATTR4_WORD1_SPACE_TOTAL ))) { - status =vfs_statfs (dentry->d_inode->i_sb, &statfs); + status =vfs_statfs (dentry, &statfs);if (status) goto out_nfserr; }
fs/nfsd/vfs.c +1 -1
@@ -1737,7 +1737,7 @@ int nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat) { int err = fh_verify(rqstp, fhp, 0, MAY_NOP); -if (!err &&vfs_statfs (fhp->fh_dentry->d_inode->i_sb,stat)) +if (!err &&vfs_statfs (fhp->fh_dentry,stat)) err = nfserr_io;return err; }
fs/ntfs/super.c +4 -3
@@ -2601,10 +2601,10 @@ static unsigned long __get_nr_free_mft_r/** * ntfs_statfs - return information about mounted NTFS volume -* @sb: super block of mounted volume +* @dentry: dentry from mounted volume * @sfs: statfs structure in which to return the information * -* Return information about the mounted NTFS volume @sb in the statfs structure +* Return information about the mounted NTFS volume @dentry in the statfs structure * pointed to by @sfs (this is initialized with zeros before ntfs_statfs is * called). We interpret the values to be correct of the moment in time at * which we are called. Most values are variable otherwise and this isn't just
@@ -2617,8 +2617,9 @@ static unsigned long __get_nr_free_mft_r* * Return 0 on success or -errno on error. */ -static int ntfs_statfs (struct super_block *sb,struct kstatfs *sfs) +static int ntfs_statfs (struct dentry *dentry,struct kstatfs *sfs) { +struct super_block *sb = dentry->d_sb;s64 size;ntfs_volume *vol =NTFS_SB (sb);ntfs_inode *mft_ni =NTFS_I (vol->mft_ino);
fs/ocfs2/super.c +5 -5
@@ -100,7 +100,7 @@ static int ocfs2_initialize_mem_caches(vstatic void ocfs2_free_mem_caches (void );static void ocfs2_delete_osb (struct ocfs2_super *osb); -static int ocfs2_statfs (struct super_block *sb,struct kstatfs *buf); +static int ocfs2_statfs (struct dentry *dentry,struct kstatfs *buf);static int ocfs2_sync_fs (struct super_block *sb,int wait);
@@ -857,7 +857,7 @@ static void ocfs2_put_super(struct supermlog_exit_void (); } -static int ocfs2_statfs (struct super_block *sb,struct kstatfs *buf) +static int ocfs2_statfs (struct dentry *dentry,struct kstatfs *buf) {struct ocfs2_super *osb;u32 numbits, freebits;
@@ -866,9 +866,9 @@ static int ocfs2_statfs(struct super_blostruct buffer_head *bh =NULL ;struct inode *inode =NULL ; -mlog_entry ("(%p, %p)\n" , sb, buf); +mlog_entry ("(%p, %p)\n" , dentry->d_sb, buf); - osb =OCFS2_SB (sb); + osb =OCFS2_SB (dentry->d_sb); inode = ocfs2_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE,
@@ -891,7 +891,7 @@ static int ocfs2_statfs(struct super_blo freebits = numbits -le32_to_cpu (bm_lock->id1.bitmap1.i_used); buf->f_type =OCFS2_SUPER_MAGIC ; - buf->f_bsize = sb->s_blocksize; + buf->f_bsize = dentry->d_sb->s_blocksize; buf->f_namelen =OCFS2_MAX_FILENAME_LEN ; buf->f_blocks = ((sector_t ) numbits) * (osb->s_clustersize >> osb->sb->s_blocksize_bits);
fs/open.c +13 -13
@@ -31,18 +31,18 @@ #include <linux/audit.h>#include <asm/unistd.h> -int vfs_statfs (struct super_block *sb,struct kstatfs *buf) +int vfs_statfs (struct dentry *dentry,struct kstatfs *buf) {int retval = -ENODEV ; -if (sb) { +if (dentry) { retval = -ENOSYS ; -if (sb->s_op->statfs) { +if (dentry->d_sb->s_op->statfs) {memset (buf,0 ,sizeof (*buf)); - retval =security_sb_statfs (sb); + retval =security_sb_statfs (dentry);if (retval)return retval; - retval = sb->s_op->statfs (sb, buf); + retval = dentry->d_sb->s_op->statfs (dentry, buf);if (retval ==0 && buf->f_frsize ==0 ) buf->f_frsize = buf->f_bsize; }
@@ -52,12 +52,12 @@ int vfs_statfs(struct super_block *sb, sEXPORT_SYMBOL (vfs_statfs); -static int vfs_statfs_native (struct super_block *sb,struct statfs *buf) +static int vfs_statfs_native (struct dentry *dentry,struct statfs *buf) {struct kstatfs st;int retval; - retval =vfs_statfs (sb, &st); + retval =vfs_statfs (dentry, &st);if (retval)return retval;
@@ -95,12 +95,12 @@ static int vfs_statfs_native(struct supereturn 0 ; } -static int vfs_statfs64 (struct super_block *sb,struct statfs64 *buf) +static int vfs_statfs64 (struct dentry *dentry,struct statfs64 *buf) {struct kstatfs st;int retval; - retval =vfs_statfs (sb, &st); + retval =vfs_statfs (dentry, &st);if (retval)return retval;
@@ -130,7 +130,7 @@ asmlinkage long sys_statfs(const char __ error =user_path_walk (path, &nd);if (!error) {struct statfs tmp; - error =vfs_statfs_native (nd.dentry->d_inode->i_sb, &tmp); + error =vfs_statfs_native (nd.dentry, &tmp);if (!error &©_to_user (buf, &tmp,sizeof (tmp))) error = -EFAULT ;path_release (&nd);
@@ -149,7 +149,7 @@ asmlinkage long sys_statfs64(const char error =user_path_walk (path, &nd);if (!error) {struct statfs64 tmp; - error =vfs_statfs64 (nd.dentry->d_inode->i_sb, &tmp); + error =vfs_statfs64 (nd.dentry, &tmp);if (!error &©_to_user (buf, &tmp,sizeof (tmp))) error = -EFAULT ;path_release (&nd);
@@ -168,7 +168,7 @@ asmlinkage long sys_fstatfs(unsigned int file =fget (fd);if (!file) goto out; - error =vfs_statfs_native (file->f_dentry->d_inode->i_sb, &tmp); + error =vfs_statfs_native (file->f_dentry, &tmp);if (!error &©_to_user (buf, &tmp,sizeof (tmp))) error = -EFAULT ;fput (file);
@@ -189,7 +189,7 @@ asmlinkage long sys_fstatfs64(unsigned i file =fget (fd);if (!file) goto out; - error =vfs_statfs64 (file->f_dentry->d_inode->i_sb, &tmp); + error =vfs_statfs64 (file->f_dentry, &tmp);if (!error &©_to_user (buf, &tmp,sizeof (tmp))) error = -EFAULT ;fput (file);
fs/qnx4/inode.c +4 -2
@@ -128,7 +128,7 @@ static struct inode *qnx4_alloc_inode(ststatic void qnx4_destroy_inode (struct inode *inode);static void qnx4_read_inode (struct inode *);static int qnx4_remount (struct super_block *sb,int *flags,char *data); -static int qnx4_statfs (struct super_block *,struct kstatfs *); +static int qnx4_statfs (struct dentry *,struct kstatfs *);static struct super_operations qnx4_sops = {
@@ -282,8 +282,10 @@ unsigned long qnx4_block_map( struct inoreturn block; } -static int qnx4_statfs (struct super_block *sb,struct kstatfs *buf) +static int qnx4_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb; +lock_kernel (); buf->f_type = sb->s_magic;
fs/reiserfs/super.c +4 -4
@@ -60,7 +60,7 @@ static int is_any_reiserfs_magic_string( }static int reiserfs_remount (struct super_block *s,int *flags,char *data); -static int reiserfs_statfs (struct super_block *s,struct kstatfs *buf); +static int reiserfs_statfs (struct dentry *dentry,struct kstatfs *buf);static int reiserfs_sync_fs (struct super_block *s,int wait) {
@@ -1938,15 +1938,15 @@ #endifreturn errval; } -static int reiserfs_statfs (struct super_block *s,struct kstatfs *buf) +static int reiserfs_statfs (struct dentry *dentry,struct kstatfs *buf) { -struct reiserfs_super_block *rs =SB_DISK_SUPER_BLOCK (s); +struct reiserfs_super_block *rs =SB_DISK_SUPER_BLOCK (dentry->d_sb); buf->f_namelen = (REISERFS_MAX_NAME (s->s_blocksize)); buf->f_bfree =sb_free_blocks (rs); buf->f_bavail = buf->f_bfree; buf->f_blocks =sb_block_count (rs) -sb_bmap_nr (rs) -1 ; - buf->f_bsize = s->s_blocksize; + buf->f_bsize = dentry->d_sb->s_blocksize;/* changed to accommodate gcc folks. */ buf->f_type =REISERFS_SUPER_MAGIC ;return 0 ;
fs/romfs/inode.c +2 -2
@@ -179,12 +179,12 @@ outnobh:/* That's simple too. */ static int -romfs_statfs (struct super_block *sb,struct kstatfs *buf) +romfs_statfs (struct dentry *dentry,struct kstatfs *buf) { buf->f_type =ROMFS_MAGIC ; buf->f_bsize =ROMBSIZE ; buf->f_bfree = buf->f_bavail = buf->f_ffree; - buf->f_blocks = (romfs_maxsize (sb)+ROMBSIZE -1 )>>ROMBSBITS ; + buf->f_blocks = (romfs_maxsize (dentry->d_sb)+ROMBSIZE -1 )>>ROMBSBITS ; buf->f_namelen =ROMFS_MAXFN ;return 0 ; }
fs/smbfs/inode.c +3 -3
@@ -48,7 +48,7 @@ #define SMB_TTL_DEFAULT 1000static void smb_delete_inode (struct inode *);static void smb_put_super (struct super_block *); -static int smb_statfs (struct super_block *,struct kstatfs *); +static int smb_statfs (struct dentry *,struct kstatfs *);static int smb_show_options (struct seq_file *,struct vfsmount *);static kmem_cache_t *smb_inode_cachep;
@@ -641,13 +641,13 @@ out_no_server: }static int -smb_statfs (struct super_block *sb,struct kstatfs *buf) +smb_statfs (struct dentry *dentry,struct kstatfs *buf) {int result;lock_kernel (); - result =smb_proc_dskattr (sb, buf); + result =smb_proc_dskattr (dentry, buf);unlock_kernel ();
fs/smbfs/proc.c +2 -2
@@ -3226,9 +3226,9 @@ smb_proc_settime(struct dentry *dentry, }int -smb_proc_dskattr (struct super_block *sb,struct kstatfs *attr) +smb_proc_dskattr (struct dentry *dentry,struct kstatfs *attr) { -struct smb_sb_info *server =SMB_SB (sb); +struct smb_sb_info *server =SMB_SB (dentry->d_sb);int result;char *p;long unit;
fs/smbfs/proto.h +1 -1
@@ -29,7 +29,7 @@ extern int smb_proc_getattr(struct dentrextern int smb_proc_setattr (struct dentry *dir,struct smb_fattr *fattr);extern int smb_proc_setattr_unix (struct dentry *d,struct iattr *attr,unsigned int major,unsigned int minor);extern int smb_proc_settime (struct dentry *dentry,struct smb_fattr *fattr); -extern int smb_proc_dskattr (struct super_block *sb,struct kstatfs *attr); +extern int smb_proc_dskattr (struct dentry *dentry,struct kstatfs *attr);extern int smb_proc_read_link (struct smb_sb_info *server,struct dentry *d,char *buffer,int len);extern int smb_proc_symlink (struct smb_sb_info *server,struct dentry *d,const char *oldpath);extern int smb_proc_link (struct smb_sb_info *server,struct dentry *dentry,struct dentry *new_dentry);
fs/super.c +1 -1
@@ -486,7 +486,7 @@ asmlinkage long sys_ustat(unsigned dev, s =user_get_super (new_decode_dev (dev));if (s ==NULL ) goto out; - err =vfs_statfs (s, &sbuf); + err =vfs_statfs (s->s_root, &sbuf);drop_super (s);if (err) goto out;
fs/sysv/inode.c +2 -1
@@ -85,8 +85,9 @@ static void sysv_put_super(struct super_kfree (sbi); } -static int sysv_statfs (struct super_block *sb,struct kstatfs *buf) +static int sysv_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb;struct sysv_sb_info *sbi =SYSV_SB (sb); buf->f_type = sb->s_magic;
fs/udf/super.c +4 -2
@@ -91,7 +91,7 @@ static void udf_load_partdesc(struct supstatic void udf_open_lvid (struct super_block *);static void udf_close_lvid (struct super_block *);static unsigned int udf_count_free (struct super_block *); -static int udf_statfs (struct super_block *,struct kstatfs *); +static int udf_statfs (struct dentry *,struct kstatfs *);/* UDF filesystem type */ static int udf_get_sb(struct file_system_type *fs_type,
@@ -1779,8 +1779,10 @@ #endif* Written, tested, and released. */ static int -udf_statfs (struct super_block *sb,struct kstatfs *buf) +udf_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb; + buf->f_type =UDF_SUPER_MAGIC ; buf->f_bsize = sb->s_blocksize; buf->f_blocks =UDF_SB_PARTLEN (sb,UDF_SB_PARTITION (sb));
fs/ufs/super.c +2 -1
@@ -1113,8 +1113,9 @@ #endifreturn 0 ; } -static int ufs_statfs (struct super_block *sb,struct kstatfs *buf) +static int ufs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct super_block *sb = dentry->d_sb;struct ufs_sb_private_info * uspi;struct ufs_super_block_first * usb1;struct ufs_super_block * usb;
fs/xfs/linux-2.6/xfs_super.c +2 -2
@@ -703,10 +703,10 @@ xfs_fs_sync_super( STATIC intxfs_fs_statfs ( -struct super_block *sb, +struct dentry *dentry,struct kstatfs *statp) { -vfs_t *vfsp =vfs_from_sb (sb); +vfs_t *vfsp =vfs_from_sb (dentry->d_sb);int error;VFS_STATVFS (vfsp, statp,NULL , error);
include/linux/coda_psdev.h +1 -1
@@ -70,7 +70,7 @@ int venus_pioctl(struct super_block *sb, unsigned int cmd, struct PioctlData *data);int coda_downcall (int opcode,union outputArgs *out,struct super_block *sb);int venus_fsync (struct super_block *sb,struct CodaFid *fid); -int venus_statfs (struct super_block *sb,struct kstatfs *sfs); +int venus_statfs (struct dentry *dentry,struct kstatfs *sfs);/* messages between coda filesystem in kernel and Venus */
include/linux/fs.h +3 -3
@@ -1097,7 +1097,7 @@ struct super_operations {int (*sync_fs)(struct super_block *sb,int wait);void (*write_super_lockfs) (struct super_block *);void (*unlockfs) (struct super_block *); -int (*statfs) (struct super_block *,struct kstatfs *); +int (*statfs) (struct dentry *,struct kstatfs *);int (*remount_fs) (struct super_block *,int *,char *);void (*clear_inode) (struct inode *);void (*umount_begin) (struct vfsmount *,int );
@@ -1326,7 +1326,7 @@ extern struct vfsmount *copy_tree(structextern void mnt_set_mountpoint (struct vfsmount *,struct dentry *,struct vfsmount *); -extern int vfs_statfs (struct super_block *,struct kstatfs *); +extern int vfs_statfs (struct dentry *,struct kstatfs *);/* /sys/fs */ extern struct subsystem fs_subsys;
@@ -1747,7 +1747,7 @@ extern int dcache_dir_close(struct inodeextern loff_t dcache_dir_lseek (struct file *,loff_t ,int );extern int dcache_readdir (struct file *,void *,filldir_t );extern int simple_getattr (struct vfsmount *,struct dentry *,struct kstat *); -extern int simple_statfs (struct super_block *,struct kstatfs *); +extern int simple_statfs (struct dentry *,struct kstatfs *);extern int simple_link (struct dentry *,struct inode *,struct dentry *);extern int simple_unlink (struct inode *,struct dentry *);extern int simple_rmdir (struct inode *,struct dentry *);
include/linux/mount.h +5 -0
@@ -17,6 +17,11 @@ #include <linux/list.h>#include <linux/spinlock.h> #include <asm/atomic.h> +struct super_block ; +struct vfsmount ; +struct dentry ; +struct namespace ; +#define MNT_NOSUID 0x01#define MNT_NODEV 0x02#define MNT_NOEXEC 0x04
include/linux/security.h +7 -7
@@ -171,9 +171,9 @@ #ifdef CONFIG_SECURITY* Deallocate and clear the sb->s_security field. * @sb contains the super_block structure to be modified. * @sb_statfs: -* Check permission before obtaining filesystem statistics for the @sb -* filesystem. -* @sb contains the super_block structure for the filesystem. +* Check permission before obtaining filesystem statistics for the @mnt +* mountpoint. +* @dentry is a handle on the superblock for the filesystem. * Return 0 if permission is granted. * @sb_mount: * Check permission before an object specified by @dev_name is mounted on
@@ -1121,7 +1121,7 @@ struct security_operations {int (*sb_copy_data)(struct file_system_type *type,void *orig,void *copy);int (*sb_kern_mount) (struct super_block *sb,void *data); -int (*sb_statfs) (struct super_block * sb); +int (*sb_statfs) (struct dentry *dentry);int (*sb_mount) (char *dev_name,struct nameidata * nd,char *type,unsigned long flags,void *data);int (*sb_check_sb) (struct vfsmount * mnt,struct nameidata * nd);
@@ -1442,9 +1442,9 @@ static inline int security_sb_kern_mountreturn security_ops->sb_kern_mount (sb, data); } -static inline int security_sb_statfs (struct super_block *sb) +static inline int security_sb_statfs (struct dentry *dentry) { -return security_ops->sb_statfs (sb); +return security_ops->sb_statfs (dentry); } static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
@@ -2154,7 +2154,7 @@ static inline int security_sb_kern_mountreturn 0 ; } -static inline int security_sb_statfs (struct super_block *sb) +static inline int security_sb_statfs (struct dentry *dentry) {return 0 ; }
kernel/acct.c +1 -1
@@ -118,7 +118,7 @@ static int check_free_space(struct filespin_unlock (&acct_globals.lock);/* May block */ -if (vfs_statfs (file->f_dentry->d_inode->i_sb, &sbuf)) +if (vfs_statfs (file->f_dentry, &sbuf))return res; suspend = sbuf.f_blocks *SUSPEND ; resume = sbuf.f_blocks *RESUME ;
mm/shmem.c +2 -2
@@ -1654,9 +1654,9 @@ static ssize_t shmem_file_sendfile(strucreturn desc.error; } -static int shmem_statfs (struct super_block *sb,struct kstatfs *buf) +static int shmem_statfs (struct dentry *dentry,struct kstatfs *buf) { -struct shmem_sb_info *sbinfo =SHMEM_SB (sb); +struct shmem_sb_info *sbinfo =SHMEM_SB (dentry->d_sb); buf->f_type =TMPFS_MAGIC ; buf->f_bsize =PAGE_CACHE_SIZE ;
security/dummy.c +1 -1
@@ -191,7 +191,7 @@ static int dummy_sb_kern_mount (struct sreturn 0 ; } -static int dummy_sb_statfs (struct super_block *sb) +static int dummy_sb_statfs (struct dentry *dentry) {return 0 ; }
security/selinux/hooks.c +3 -3
@@ -1900,13 +1900,13 @@ static int selinux_sb_kern_mount(structreturn superblock_has_perm (current, sb,FILESYSTEM__MOUNT , &ad); } -static int selinux_sb_statfs (struct super_block *sb) +static int selinux_sb_statfs (struct dentry *dentry) {struct avc_audit_data ad;AVC_AUDIT_DATA_INIT (&ad,FS ); - ad.u.fs.dentry = sb->s_root; -return superblock_has_perm (current, sb,FILESYSTEM__GETATTR , &ad); + ad.u.fs.dentry = dentry->d_sb->s_root; +return superblock_has_perm (current, dentry->d_sb,FILESYSTEM__GETATTR , &ad); } static int selinux_mount(char * dev_name,
David Howells
maintainerPATCH 3/14 NFS: Abstract out namespace initialisation [try #10]
In reply to David HowellsThe attached patch abstracts out the namespace initialisation so that temporary namespaces can be set up elsewhere.
The following changes were made in [try #8]:
(*) init_namespace() has been made out-of-line.
---
fs/namespace.c | 28 +++++++++++++++++++++------- include/linux/namespace.h | 1 + 2 files changed, 22 insertions(+), 7 deletions(-)
fs/namespace.c +21 -7
@@ -1790,6 +1790,26 @@ out3: goto out2; } +/* +* initialise a namespace, rooting it at the given specified mountpoint if one +* is given +*/ +void init_namespace (struct namespace *namespace,struct vfsmount *mnt) +{ +atomic_set (&namespace->count,1 ); +INIT_LIST_HEAD (&namespace->list); +init_waitqueue_head (&namespace->poll); + namespace->event =0 ; + namespace->root = mnt; + +if (mnt) { +list_add (&mnt->mnt_list, &namespace->list); + mnt->mnt_namespace = namespace; + } +} + +EXPORT_SYMBOL_GPL (init_namespace); +static void __init init_mount_tree (void ) {struct vfsmount *mnt;
@@ -1802,13 +1822,7 @@ static void __init init_mount_tree(void) namespace =kmalloc (sizeof (*namespace),GFP_KERNEL );if (!namespace)panic ("Can't allocate initial namespace" ); -atomic_set (&namespace->count,1 ); -INIT_LIST_HEAD (&namespace->list); -init_waitqueue_head (&namespace->poll); - namespace->event =0 ; -list_add (&mnt->mnt_list, &namespace->list); - namespace->root = mnt; - mnt->mnt_namespace = namespace; +init_namespace (namespace, mnt); init_task.namespace = namespace;read_lock (&tasklist_lock);
include/linux/namespace.h +1 -0
@@ -16,6 +16,7 @@ struct namespace {extern int copy_namespace (int ,struct task_struct *);extern void __put_namespace (struct namespace *namespace);extern struct namespace *dup_namespace (struct task_struct *,struct fs_struct *); +extern void init_namespace (struct namespace *,struct vfsmount *);static inline void put_namespace (struct namespace *namespace) {
Re: [PATCH 03/14] NFS: Abstract out namespace initialisation [try #10]
Quoted 2 lines · David Howells
The attached patch abstracts out the namespace initialisation so that temporary namespaces can be set up elsewhere.
IDGI... Where does your patchset use it?
David Howells
maintainerRe: [PATCH 03/14] NFS: Abstract out namespace initialisation [try #10]
Quoted 4 lines · Al Viro
Quoted 2 lines
The attached patch abstracts out the namespace initialisation so that temporary namespaces can be set up elsewhere.
IDGI... Where does your patchset use it?
Hmmm... That's a good point. It doesn't any more. This patch is obsolete and can be dropped.
It used to be used to set up a separate namespace in which to do NFSv4 path traversal during mount so that we could walk from '/' to the nominated directory on the NFS4 server using link_path_walk(), but the patches don't do that now.
David
David Howells
maintainerPATCH 4/14 NFS: Add dentry materialisation op [try #10]
In reply to David HowellsThe attached patch adds a new directory cache management function that prepares a disconnected anonymous function to be connected into the dentry tree. The anonymous dentry is transferred the name and parentage from another dentry.
The following changes were made in [try #2]:
(*) d_materialise_dentry() now switches the parentage of the two nodes around
correctly when one or other of them is self-referential.
The following changes were made in [try #7]:
(*) d_instantiate_unique() has had the interior part split out as function
__d_instantiate_unique(). Callers of this latter function must be holding the appropriate locks.
(*) _d_rehash() has been added as a wrapper around __d_rehash() to call it
with the most obvious hash list (the one from the name). d_rehash() now calls _d_rehash().
(*) d_materialise_dentry() is now __d_materialise_dentry() and is static.
(*) d_materialise_unique() added to perform the combination of d_find_alias(),
d_materialise_dentry() and d_add_unique() that the NFS client was doing twice, all within a single dcache_lock critical section. This reduces the number of times two different spinlocks were being accessed.
---
fs/dcache.c | 152 ++++++++++++++++++++++++++++++++++++++++++++---- include/linux/dcache.h | 1 2 files changed, 139 insertions(+), 14 deletions(-)
fs/dcache.c +138 -14
@@ -815,17 +815,19 @@ void d_instantiate(struct dentry *entry,* (or otherwise set) by the caller to indicate that it is now * in use by the dcache. */ -struct dentry *d_instantiate_unique (struct dentry *entry,struct inode *inode) +static struct dentry *__d_instantiate_unique (struct dentry *entry, +struct inode *inode) {struct dentry *alias;int len = entry->d_name.len;const char *name = entry->d_name.name;unsigned int hash = entry->d_name.hash; -BUG_ON (!list_empty (&entry->d_alias)); -spin_lock (&dcache_lock); -if (!inode) - goto do_negative; +if (!inode) { + entry->d_inode =NULL ; +return NULL ; + } +list_for_each_entry (alias, &inode->i_dentry, d_alias) {struct qstr *qstr = &alias->d_name;
@@ -838,19 +840,35 @@ struct dentry *d_instantiate_unique(struif (memcmp (qstr->name, name, len))continue ;dget_locked (alias); -spin_unlock (&dcache_lock); -BUG_ON (!d_unhashed (alias)); -iput (inode);return alias; } +list_add (&entry->d_alias, &inode->i_dentry); -do_negative: entry->d_inode = inode;fsnotify_d_instantiate (entry, inode); -spin_unlock (&dcache_lock); -security_d_instantiate (entry, inode);return NULL ; } + +struct dentry *d_instantiate_unique (struct dentry *entry,struct inode *inode) +{ +struct dentry *result; + +BUG_ON (!list_empty (&entry->d_alias)); + +spin_lock (&dcache_lock); + result =__d_instantiate_unique (entry, inode); +spin_unlock (&dcache_lock); + +if (!result) { +security_d_instantiate (entry, inode); +return NULL ; + } + +BUG_ON (!d_unhashed (result)); +iput (inode); +return result; +} +EXPORT_SYMBOL (d_instantiate_unique);/**
@@ -1222,6 +1240,11 @@ static void __d_rehash(struct dentry * ehlist_add_head_rcu (&entry->d_hash, list); } +static void _d_rehash (struct dentry * entry) +{ +__d_rehash (entry,d_hash (entry->d_parent, entry->d_name.hash)); +} +/** * d_rehash - add an entry back to the hash * @entry: dentry to add to the hash
@@ -1231,11 +1254,9 @@ static void __d_rehash(struct dentry * evoid d_rehash (struct dentry * entry) { -struct hlist_head *list =d_hash (entry->d_parent, entry->d_name.hash); -spin_lock (&dcache_lock);spin_lock (&entry->d_lock); -__d_rehash (entry, list); +_d_rehash (entry);spin_unlock (&entry->d_lock);spin_unlock (&dcache_lock); }
@@ -1373,6 +1394,108 @@ already_unhashed:spin_unlock (&dcache_lock); } +/* +* Prepare an anonymous dentry for life in the superblock's dentry tree as a +* named dentry in place of the dentry to be replaced. +*/ +static void __d_materialise_dentry (struct dentry *dentry,struct dentry *anon) +{ +struct dentry *dparent, *aparent; + +switch_names (dentry, anon); +do_switch (dentry->d_name.len, anon->d_name.len); +do_switch (dentry->d_name.hash, anon->d_name.hash); + + dparent = dentry->d_parent; + aparent = anon->d_parent; + dentry->d_parent = (aparent == anon) ? dentry : aparent; + anon->d_parent = (dparent == dentry) ? anon : dparent; + + anon->d_flags &= ~DCACHE_DISCONNECTED ; +} + +/** +* d_materialise_unique - introduce an inode into the tree +* @dentry: candidate dentry +* @inode: inode to bind to the dentry, to which aliases may be attached +* +* Introduces an dentry into the tree, substituting an extant disconnected +* root directory alias in its place if there is one +*/ +struct dentry *d_materialise_unique (struct dentry *dentry,struct inode *inode) +{ +struct dentry *alias, *actual; + +BUG_ON (!d_unhashed (dentry)); + +spin_lock (&dcache_lock); + +if (!inode) { + actual = dentry; + dentry->d_inode =NULL ; + goto found_lock; + } + +/* See if a disconnected directory already exists as an anonymous root +* that we should splice into the tree instead */ +if (S_ISDIR (inode->i_mode) && (alias =__d_find_alias (inode,1 ))) { +spin_lock (&alias->d_lock); + +/* Is this a mountpoint that we could splice into our tree? */ +if (IS_ROOT (alias)) + goto connect_mountpoint; + +if (alias->d_name.len == dentry->d_name.len && + alias->d_parent == dentry->d_parent && +memcmp (alias->d_name.name, + dentry->d_name.name, + dentry->d_name.len) ==0 ) + goto replace_with_alias; + +spin_unlock (&alias->d_lock); + +/* Doh! Seem to be aliasing directories for some reason... */ +dput (alias); + } + +/* Add a unique reference */ + actual =__d_instantiate_unique (dentry, inode); +if (!actual) + actual = dentry; +else if (unlikely (!d_unhashed (actual))) + goto shouldnt_be_hashed; + +found_lock: +spin_lock (&actual->d_lock); +found: +_d_rehash (actual); +spin_unlock (&actual->d_lock); +spin_unlock (&dcache_lock); + +if (actual == dentry) { +security_d_instantiate (dentry, inode); +return NULL ; + } + +iput (inode); +return actual; + +/* Convert the anonymous/root alias into an ordinary dentry */ +connect_mountpoint: +__d_materialise_dentry (dentry, alias); + +/* Replace the candidate dentry with the alias in the tree */ +replace_with_alias: +__d_drop (alias); + actual = alias; + goto found; + +shouldnt_be_hashed: +spin_unlock (&dcache_lock); +BUG (); + goto shouldnt_be_hashed; +} +/** * d_path - return the path of a dentry * @dentry: dentry to report
@@ -1771,6 +1894,7 @@ EXPORT_SYMBOL(d_instantiate);EXPORT_SYMBOL (d_invalidate);EXPORT_SYMBOL (d_lookup);EXPORT_SYMBOL (d_move); +EXPORT_SYMBOL_GPL (d_materialise_unique);EXPORT_SYMBOL (d_path);EXPORT_SYMBOL (d_prune_aliases);EXPORT_SYMBOL (d_rehash);
include/linux/dcache.h +1 -0
@@ -209,6 +209,7 @@ static inline int dname_external(struct*/ extern void d_instantiate (struct dentry *,struct inode *);extern struct dentry *d_instantiate_unique (struct dentry *,struct inode *); +extern struct dentry *d_materialise_unique (struct dentry *,struct inode *);extern void d_delete (struct dentry *);/* allocate/de-allocate */
David Howells
maintainerPATCH 5/14 NFS: Split fs/nfs/inode.c into inode, superblock and namespace bits [try #10]
In reply to David HowellsThis patch splits superblock and namespace related stuff out of fs/nfs/inode.c into super.c, namespace.c and nfs4namespace.c in that directory.
fs/nfs/internal.h is also created to hold the common definitions and all the extern references in fs/nfs/*.c have been moved into it.
---
fs/nfs/Makefile | 5 fs/nfs/callback.c | 5 fs/nfs/direct.c | 6 fs/nfs/idmap.c | 3 fs/nfs/inode.c | 1837 +----------------------------------------------- fs/nfs/internal.h | 184 +++++ fs/nfs/namespace.c | 112 +++ fs/nfs/nfs2xdr.c | 3 fs/nfs/nfs3proc.c | 5 fs/nfs/nfs3xdr.c | 3 fs/nfs/nfs4namespace.c | 201 +++++ fs/nfs/nfs4proc.c | 2 fs/nfs/pagelist.c | 4 fs/nfs/proc.c | 5 fs/nfs/read.c | 4 fs/nfs/super.c | 1510 +++++++++++++++++++++++++++++++++++++++ fs/nfs/write.c | 4 include/linux/nfs_fs.h | 2 18 files changed, 2046 insertions(+), 1849 deletions(-)
fs/nfs/Makefile +3 -2
@@ -4,7 +4,7 @@ # obj-$(CONFIG_NFS_FS) += nfs.o -nfs-y := dir.o file.o inode.o nfs2xdr.o pagelist.o \ +nfs-y := dir.o file.o inode.o super.o nfs2xdr.o pagelist.o \ proc.o read.o symlink.o unlink.o write.o \ namespace.o nfs-$(CONFIG_ROOT_NFS) += nfsroot.o mount_clnt.o
@@ -12,7 +12,8 @@ nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3x nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \ delegation.o idmap.o \ - callback.o callback_xdr.o callback_proc.o + callback.o callback_xdr.o callback_proc.o \ + nfs4namespace.o nfs-$(CONFIG_NFS_DIRECTIO) += direct.o nfs-$(CONFIG_SYSCTL) += sysctl.o nfs-objs := $(nfs-y)
fs/nfs/callback.c +0 -5
@@ -35,9 +35,6 @@ static struct nfs_callback_data nfs_callstatic DEFINE_MUTEX (nfs_callback_mutex);static struct svc_program nfs4_callback_program; -unsigned int nfs_callback_set_tcpport; -unsigned short nfs_callback_tcpport; -/* * This is the callback kernel thread. */
@@ -182,8 +179,6 @@ static int nfs_callback_authenticate(str/* * Define NFS4 callback program */ -extern struct svc_version nfs4_callback_version1; -static struct svc_version *nfs4_callback_version[] = { [1 ] = &nfs4_callback_version1, };
fs/nfs/direct.c +3 -3
@@ -892,7 +892,7 @@ out:* nfs_init_directcache - create a slab cache for nfs_direct_req structures * */ -int nfs_init_directcache (void ) +int __init nfs_init_directcache (void ) { nfs_direct_cachep = kmem_cache_create("nfs_direct_cache", sizeof(struct nfs_direct_req),
@@ -906,10 +906,10 @@ int nfs_init_directcache(void) }/** -* nfs_init_directcache - destroy the slab cache for nfs_direct_req structures +* nfs_destroy_directcache - destroy the slab cache for nfs_direct_req structures * */ -void nfs_destroy_directcache (void ) +void __exit nfs_destroy_directcache(void) {if (kmem_cache_destroy (nfs_direct_cachep))printk (KERN_INFO "nfs_direct_cache: not all structures were freed\n" );
fs/nfs/idmap.c +0 -3
@@ -54,9 +54,6 @@ #include "nfs4_fs.h"#define IDMAP_HASH_SZ 128 -/* Default cache timeout is 10 minutes */ -unsigned int nfs_idmap_cache_timeout =600 *HZ ; -struct idmap_hashent {unsigned long ih_expires;__u32 ih_id;
fs/nfs/inode.c +24 -1813
1,954 lines not on this page · raw message
fs/nfs/internal.h new file +184 -0
184 lines not on this page · raw message
fs/nfs/namespace.c +111 -1
129 lines not on this page · raw message
fs/nfs/nfs2xdr.c +1 -2
@@ -23,12 +23,11 @@ #include <linux/sunrpc/clnt.h>#include <linux/nfs.h> #include <linux/nfs2.h> #include <linux/nfs_fs.h> +#include "internal.h" #define NFSDBG_FACILITY NFSDBG_XDR/* #define NFS_PARANOIA 1 */ -extern int nfs_stat_to_errno (int stat); -/* Mapping from NFS error code to "errno" error code. */ #define errno_NFSERR_IO EIO
fs/nfs/nfs3proc.c +1 -4
@@ -20,11 +20,10 @@ #include <linux/smp_lock.h>#include <linux/nfs_mount.h> #include "iostat.h" +#include "internal.h" #define NFSDBG_FACILITY NFSDBG_PROC -extern struct rpc_procinfo nfs3_procedures[]; -/* A wrapper to handle the EJUKEBOX error message */ static int nfs3_rpc_wrapper (struct rpc_clnt *clnt,struct rpc_message *msg,int flags)
@@ -809,8 +808,6 @@ nfs3_proc_pathconf(struct nfs_server *sereturn status; } -extern u32 *nfs3_decode_dirent (u32 *,struct nfs_entry *,int ); -static int nfs3_read_done (struct rpc_task *task,struct nfs_read_data *data) {if (nfs3_async_handle_jukebox (task, data->inode))
fs/nfs/nfs3xdr.c +1 -2
@@ -22,14 +22,13 @@ #include <linux/nfs.h>#include <linux/nfs3.h> #include <linux/nfs_fs.h> #include <linux/nfsacl.h> +#include "internal.h" #define NFSDBG_FACILITY NFSDBG_XDR/* Mapping from NFS error code to "errno" error code. */ #define errno_NFSERR_IO EIO -extern int nfs_stat_to_errno (int ); -/* * Declare the space requirements for NFS arguments and replies as * number of 32bit-words
fs/nfs/nfs4namespace.c new file +201 -0
201 lines not on this page · raw message
fs/nfs/nfs4proc.c +0 -2
@@ -65,8 +65,6 @@ static int nfs4_async_handle_error(strucstatic int _nfs4_proc_access (struct inode *inode,struct nfs_access_entry *entry);static int nfs4_handle_exception (const struct nfs_server *server,int errorcode,struct nfs4_exception *exception);static int nfs4_wait_clnt_recover (struct rpc_clnt *clnt,struct nfs4_client *clp); -extern u32 *nfs4_decode_dirent (u32 *p,struct nfs_entry *entry,int plus); -extern struct rpc_procinfo nfs4_procedures[];/* Prevent leaks of NFSv4 errors into userland */ int nfs4_map_errors (int err)
fs/nfs/pagelist.c +2 -2
@@ -369,7 +369,7 @@ nfs_scan_list(struct list_head *head, streturn res; } -int nfs_init_nfspagecache (void ) +int __init nfs_init_nfspagecache (void ) { nfs_page_cachep = kmem_cache_create("nfs_page", sizeof(struct nfs_page),
@@ -381,7 +381,7 @@ int nfs_init_nfspagecache(void)return 0 ; } -void nfs_destroy_nfspagecache (void ) +void __exit nfs_destroy_nfspagecache(void) {if (kmem_cache_destroy (nfs_page_cachep))printk (KERN_INFO "nfs_page: not all structures were freed\n" );
fs/nfs/proc.c +1 -4
@@ -44,11 +44,10 @@ #include <linux/nfs_fs.h>#include <linux/nfs_page.h> #include <linux/lockd/bind.h> #include <linux/smp_lock.h> +#include "internal.h" #define NFSDBG_FACILITY NFSDBG_PROC -extern struct rpc_procinfo nfs_procedures[]; -/* * Bare-bones access to getattr: this is for nfs_read_super. */
@@ -611,8 +610,6 @@ nfs_proc_pathconf(struct nfs_server *serreturn 0 ; } -extern u32 *nfs_decode_dirent (u32 *,struct nfs_entry *,int ); -static int nfs_read_done (struct rpc_task *task,struct nfs_read_data *data) {if (task->tk_status >=0 ) {
fs/nfs/read.c +2 -2
@@ -651,7 +651,7 @@ int nfs_readpages(struct file *filp, strreturn ret; } -int nfs_init_readpagecache (void ) +int __init nfs_init_readpagecache (void ) { nfs_rdata_cachep = kmem_cache_create("nfs_read_data", sizeof(struct nfs_read_data),
@@ -668,7 +668,7 @@ int nfs_init_readpagecache(void)return 0 ; } -void nfs_destroy_readpagecache (void ) +void __exit nfs_destroy_readpagecache(void) {mempool_destroy (nfs_rdata_mempool);if (kmem_cache_destroy (nfs_rdata_cachep))
fs/nfs/super.c new file +1510 -0
361 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
David Howells
maintainerPATCH 6/14 NFS: Share NFS superblocks per-protocol per-server per-FSID [try #10]
In reply to David HowellsThe attached patch makes NFS share superblocks between mounts from the same server and FSID over the same protocol.
It does this by creating each superblock with a false root and returning the real root dentry through the new argument added to get_sb() in patch 1/5. The root dentry returned starts off as an anonymous dentry if we don't already have the dentry for its inode, otherwise it simply returns the dentry we already have.
We may thus end up with several trees of dentries in the superblock, and if at some later point one of anonymous tree roots is discovered by normal filesystem activity to be located in another tree within the superblock, the anonymous root is named and materialises attached to the second tree at the appropriate point.
Why modify get_sb() in this way? Why not pass an extra argument to the mount() syscall to indicate the subpath and then pathwalk from the server root to the desired directory? You can't guarantee this will work for two reasons:
(1) The root and intervening nodes may not be accessible to the client.
With NFS2 and NFS3, for instance, mountd is called on the server to get the filehandle for the tip of a path. mountd won't give us handles for anything we don't have permission to access, and so we can't set up NFS inodes for such nodes, and so can't easily set up dentries (we'd have to have ghost inodes or something).
With this patch we don't actually create dentries until we get handles from the server that we can use to set up their inodes, and we don't actually bind them into the tree until we know for sure where they go.
(2) Inaccessible symbolic links.
If we're asked to mount two exports from the server, eg:
mount warthog:/warthog/aaa/xxx /mmm
mount warthog:/warthog/bbb/yyy /nnn
We may not be able to access anything nearer the root than xxx and yyy, but we may find out later that /mmm/www/yyy, say, is actually the same directory as the one mounted on /nnn. What we might then find out, for example, is that /warthog/bbb was actually a symbolic link to /warthog/aaa/xxx/www, but we can't actually determine that by talking to the server until /warthog is made available by NFS.
This would lead to having constructed an errneous dentry tree which we can't easily fix. We can end up with a dentry marked as a directory when it should actually be a symlink, or we could end up with an apparently hardlinked directory.
With this patch we need not make assumptions about the type of a dentry for which we can't retrieve information, nor need we assume we know its place in the grand scheme of things until we actually see that place.
This patch reduces the possibility of aliasing in the inode and page caches for inodes that may be accessed by more than one NFS export. It also reduces the number of superblocks required for NFS where there are many NFS exports being used from a server (home directory server + autofs for example).
This in turn makes it simpler to do local caching of network filesystems, as it can then be guaranteed that there won't be links from multiple inodes in separate superblocks to the same cache file.
Obviously, cache aliasing between different levels of NFS protocol is still a problem, but at least that gives us another key to use when indexing the cache.
This patch also cleans up the error handling to make sure the NFS iostats are released correctly upon error. The server construction and destruction have been abstracted into functions as the first is done twice and the second four times.
And finally, the patch exports some functions required from the core kernel.
The following changes were made in [try #2]:
(*) Whilst invoking link_path_walk(), the nfs4_get_root() routine now
temporarily overrides the FS settings of the process to prevent absolute symbolic links from walking into the wrong namespace.
(*) nfs*_get_sb() instantiate the supplied vfsmount directly by assigning to
its mnt_root and mnt_sb members.
(*) nfs_readdir_lookup() creates dentries for each of the entries readdir()
returns; this function now attaches disconnected trees from alternate roots that happen to be discovered attached to a directory being read (in the same way nfs_lookup() is made to do for lookup ops).
Further changes [try #3] that have been made:
(*) The patches are now against Trond's NFS git tree, so won't apply to
Linus's tree.
(*) The server record construction/destruction has been abstracted out into
its own pair of functions to make things easier to get right.
Further changes [try #7] that have been made:
(*) The new d_materialise_unique() function is now used in place of the
combination of d_find_alias(), d_materialise_dentry() and d_add_unique() in nfs_lookup() and nfs_readdir_lookup().
This permits the combination to be done under one set of locks, thus avoiding any race between mount and lookup operations on the same directory.
Further changes [try #8] that have been made:
(*) The NFS server specific information has been taken from struct nfs_server
and placed in struct nfs_client. nfs_client structs are then shared between nfs_server structs where possible.
(*) struct nfs4_client has been merged into nfs_client.
(*) The client management code has been moved to fs/nfs/client.c.
(*) The client management code uses a new debug facility: NFSDBG_CLIENT which
is set by echoing 1024 to /proc/net/sunrpc/nfs_debug.
(*) More of the NFS2/3 and NFS4 code is now shared.
(*) The initial NFS superblock construction (get_sb) is now performed in the
following order:
(a) A volume representation (struct nfs_server) is allocated.
(b) A client representation (struct nfs_client) is acquired. This may be allocated or shared, keyed on server address, port and NFS version.
(c) If allocated, the client representation is initialised. The state member variable of nfs_client is used to prevent a race during initialisation from two mounts.
(d) For NFS4 a simple pathwalk is performed, walking from FH to FH to find the root filehandle for the mount (fs/nfs/getroot.c).
(e) The volume FSID is probed for on the root filehandle.
(f) The volume representation is initialised.
(g) sget() is called to acquire a superblock. This may be allocated or shared, keyed on client pointer and FSID.
(h) If allocated, the superblock is initialised.
(i) If the superblock is shared, then the new nfs_server record is discarded.
(*) Two new proc files have been made available:
/proc/fs/nfsfs/clients
/proc/fs/nfsfs/volumes
The first lists the servers for which we have clients allocated (struct nfs_client), and the second lists the volumes we have on those servers (struct nfs_server).
(*) Clone mounts are now called xdev mounts.
Further changes [try #9] that have been made:
(*) The exports from fs/namespace.c and fs/namei.c are no longer required.
Further changes [try #10] that have been made:
(*) nfs4_pathname_string() needed an extra const.
---
fs/nfs/Makefile | 6 fs/nfs/callback.c | 17 - fs/nfs/callback.h | 7 fs/nfs/callback_proc.c | 13 fs/nfs/client.c | 1392 +++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/delegation.c | 35 + fs/nfs/delegation.h | 10 fs/nfs/dir.c | 28 + fs/nfs/direct.c | 8 fs/nfs/file.c | 10 fs/nfs/getroot.c | 306 ++++++++++ fs/nfs/idmap.c | 25 - fs/nfs/inode.c | 15 fs/nfs/internal.h | 101 ++- fs/nfs/namespace.c | 33 + fs/nfs/nfs3acl.c | 8 fs/nfs/nfs3proc.c | 16 - fs/nfs/nfs4_fs.h | 27 - fs/nfs/nfs4namespace.c | 120 +++- fs/nfs/nfs4proc.c | 212 +++---- fs/nfs/nfs4renewd.c | 21 - fs/nfs/nfs4state.c | 176 +----- fs/nfs/nfs4xdr.c | 42 + fs/nfs/pagelist.c | 2 fs/nfs/proc.c | 10 fs/nfs/read.c | 12 fs/nfs/super.c | 1393 +++++++++++++++------------------------------ fs/nfs/write.c | 16 - include/linux/nfs_fs.h | 14 include/linux/nfs_fs_sb.h | 80 ++- include/linux/nfs_idmap.h | 14 include/linux/nfs_xdr.h | 3 32 files changed, 2736 insertions(+), 1436 deletions(-)
fs/nfs/Makefile +3 -3
@@ -4,9 +4,9 @@ # obj-$(CONFIG_NFS_FS) += nfs.o -nfs-y := dir.o file.o inode.o super.o nfs2xdr.o pagelist.o \ - proc.o read.o symlink.o unlink.o write.o \ - namespace.o +nfs-y := client.o dir.o file.o getroot.o inode.o super.o nfs2xdr.o \ + pagelist.o proc.o read.o symlink.o unlink.o \ + write.o namespace.o nfs-$(CONFIG_ROOT_NFS) += nfsroot.o mount_clnt.o nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o
fs/nfs/callback.c +8 -9
@@ -20,6 +20,7 @@ #include <net/inet_sock.h>#include "nfs4_fs.h" #include "callback.h" +#include "internal.h" #define NFSDBG_FACILITY NFSDBG_CALLBACK
@@ -132,10 +133,8 @@ out_err:/* * Kill the server process if it is not already up. */ -int nfs_callback_down (void ) +void nfs_callback_down (void ) { -int ret =0 ; -lock_kernel ();mutex_lock (&nfs_callback_mutex); nfs_callback_info.users--;
@@ -147,20 +146,20 @@ int nfs_callback_down(void) }while (wait_for_completion_timeout (&nfs_callback_info.stopped,5 *HZ ) ==0 );mutex_unlock (&nfs_callback_mutex);unlock_kernel (); -return ret; }static int nfs_callback_authenticate (struct svc_rqst *rqstp) { -struct in_addr *addr = &rqstp->rq_addr.sin_addr; -struct nfs4_client *clp; +struct sockaddr_in *addr = &rqstp->rq_addr; +struct nfs_client *clp;/* Don't talk to strangers */ - clp =nfs4_find_client (addr); + clp =nfs_find_client (addr,4 );if (clp ==NULL )return SVC_DROP ; -dprintk ("%s: %u.%u.%u.%u NFSv4 callback!\n" , __FUNCTION__,NIPQUAD (addr)); -nfs4_put_client (clp); +dprintk ("%s: %u.%u.%u.%u NFSv4 callback!\n" , + __FUNCTION__,NIPQUAD (addr->sin_addr)); +nfs_put_client (clp);switch (rqstp->rq_authop->flavour) {case RPC_AUTH_NULL :if (rqstp->rq_proc !=CB_NULL )
fs/nfs/callback.h +6 -1
@@ -62,8 +62,13 @@ struct cb_recallargs {extern unsigned nfs4_callback_getattr (struct cb_getattrargs *args,struct cb_getattrres *res);extern unsigned nfs4_callback_recall (struct cb_recallargs *args,void *dummy); +#ifdef CONFIG_NFS_V4 extern int nfs_callback_up (void ); -extern int nfs_callback_down (void ); +extern void nfs_callback_down (void ); +#else +#define nfs_callback_up () (0) +#define nfs_callback_down () do {} while(0) +#endif extern unsigned int nfs_callback_set_tcpport;extern unsigned short nfs_callback_tcpport;
fs/nfs/callback_proc.c +7 -6
@@ -11,19 +11,20 @@ #include <linux/nfs_fs.h>#include "nfs4_fs.h" #include "callback.h" #include "delegation.h" +#include "internal.h" #define NFSDBG_FACILITY NFSDBG_CALLBACKunsigned nfs4_callback_getattr (struct cb_getattrargs *args,struct cb_getattrres *res) { -struct nfs4_client *clp; +struct nfs_client *clp;struct nfs_delegation *delegation;struct nfs_inode *nfsi;struct inode *inode; res->bitmap[0 ] = res->bitmap[1 ] =0 ; res->status =htonl (NFS4ERR_BADHANDLE ); - clp =nfs4_find_client (&args->addr->sin_addr); + clp =nfs_find_client (args->addr,4 );if (clp ==NULL ) goto out; inode =nfs_delegation_find_inode (clp, &args->fh);
@@ -49,7 +50,7 @@ out_iput:up_read (&nfsi->rwsem);iput (inode); out_putclient: -nfs4_put_client (clp); +nfs_put_client (clp); out:dprintk ("%s: exit with status = %d\n" , __FUNCTION__,ntohl (res->status));return res->status;
@@ -57,12 +58,12 @@ out:unsigned nfs4_callback_recall (struct cb_recallargs *args,void *dummy) { -struct nfs4_client *clp; +struct nfs_client *clp;struct inode *inode;unsigned res; res =htonl (NFS4ERR_BADHANDLE ); - clp =nfs4_find_client (&args->addr->sin_addr); + clp =nfs_find_client (args->addr,4 );if (clp ==NULL ) goto out; inode =nfs_delegation_find_inode (clp, &args->fh);
@@ -81,7 +82,7 @@ unsigned nfs4_callback_recall(struct cb_ }iput (inode); out_putclient: -nfs4_put_client (clp); +nfs_put_client (clp); out:dprintk ("%s: exit with status = %d\n" , __FUNCTION__,ntohl (res));return res;
fs/nfs/client.c new file +1392 -0
1,392 lines not on this page · raw message
fs/nfs/delegation.c +18 -17
@@ -19,6 +19,7 @@ #include <linux/nfs_xdr.h>#include "nfs4_fs.h" #include "delegation.h" +#include "internal.h" static struct nfs_delegation *nfs_alloc_delegation (void ) {
@@ -53,7 +54,7 @@ static int nfs_delegation_claim_locks(stcase -NFS4ERR_EXPIRED :/* kill_proc(fl->fl_pid, SIGLOST, 1); */ case -NFS4ERR_STALE_CLIENTID : -nfs4_schedule_state_recovery (NFS_SERVER (inode)->nfs4_state); +nfs4_schedule_state_recovery (NFS_SCLIENT (inode)); goto out_err; } }
@@ -115,7 +116,7 @@ void nfs_inode_reclaim_delegation(struct*/ int nfs_inode_set_delegation (struct inode *inode,struct rpc_cred *cred,struct nfs_openres *res) { -struct nfs4_client *clp =NFS_SERVER (inode)->nfs4_state; +struct nfs_client *clp =NFS_SCLIENT (inode);struct nfs_inode *nfsi =NFS_I (inode);struct nfs_delegation *delegation;int status =0 ;
@@ -146,7 +147,7 @@ int nfs_inode_set_delegation(struct inod sizeof(delegation->stateid)) != 0 || delegation->type != nfsi->delegation->type) {printk ("%s: server %u.%u.%u.%u, handed out a duplicate delegation!\n" , - __FUNCTION__,NIPQUAD (clp->cl_addr)); + __FUNCTION__,NIPQUAD (clp->addr.sin_addr)); status = -EIO ; } }
@@ -177,7 +178,7 @@ static void nfs_msync_inode(struct inode*/ int __nfs_inode_return_delegation (struct inode *inode) { -struct nfs4_client *clp =NFS_SERVER (inode)->nfs4_state; +struct nfs_client *clp =NFS_SCLIENT (inode);struct nfs_inode *nfsi =NFS_I (inode);struct nfs_delegation *delegation;int res =0 ;
@@ -209,7 +210,7 @@ int __nfs_inode_return_delegation(struct*/ void nfs_return_all_delegations (struct super_block *sb) { -struct nfs4_client *clp =NFS_SB (sb)->nfs4_state; +struct nfs_client *clp =NFS_SB (sb)->nfs_client;struct nfs_delegation *delegation;struct inode *inode;
@@ -233,7 +234,7 @@ restart:int nfs_do_expire_all_delegations (void *ptr) { -struct nfs4_client *clp = ptr; +struct nfs_client *clp = ptr;struct nfs_delegation *delegation;struct inode *inode;
@@ -255,11 +256,11 @@ restart: } out:spin_unlock (&clp->cl_lock); -nfs4_put_client (clp); +nfs_put_client (clp);module_put_and_exit (0 ); } -void nfs_expire_all_delegations (struct nfs4_client *clp) +void nfs_expire_all_delegations (struct nfs_client *clp) {struct task_struct *task;
@@ -267,17 +268,17 @@ void nfs_expire_all_delegations(struct natomic_inc (&clp->cl_count); task =kthread_run (nfs_do_expire_all_delegations, clp,"%u.%u.%u.%u-delegreturn" , -NIPQUAD (clp->cl_addr)); +NIPQUAD (clp->addr.sin_addr));if (!IS_ERR (task))return ; -nfs4_put_client (clp); +nfs_put_client (clp);module_put (THIS_MODULE ); }/* * Return all delegations following an NFS4ERR_CB_PATH_DOWN error. */ -void nfs_handle_cb_pathdown (struct nfs4_client *clp) +void nfs_handle_cb_pathdown (struct nfs_client *clp) {struct nfs_delegation *delegation;struct inode *inode;
@@ -300,7 +301,7 @@ restart:struct recall_threadargs {struct inode *inode; -struct nfs4_client *clp; +struct nfs_client *clp;const nfs4_stateid *stateid;struct completion started;
@@ -311,7 +312,7 @@ static int recall_thread(void *data) {struct recall_threadargs *args = (struct recall_threadargs *)data;struct inode *inode =igrab (args->inode); -struct nfs4_client *clp =NFS_SERVER (inode)->nfs4_state; +struct nfs_client *clp =NFS_SCLIENT (inode);struct nfs_inode *nfsi =NFS_I (inode);struct nfs_delegation *delegation;
@@ -372,7 +373,7 @@ out_module_put:/* * Retrieve the inode associated with a delegation */ -struct inode *nfs_delegation_find_inode (struct nfs4_client *clp,const struct nfs_fh *fhandle) +struct inode *nfs_delegation_find_inode (struct nfs_client *clp,const struct nfs_fh *fhandle) {struct nfs_delegation *delegation;struct inode *res =NULL ;
@@ -390,7 +391,7 @@ struct inode *nfs_delegation_find_inode(/* * Mark all delegations as needing to be reclaimed */ -void nfs_delegation_mark_reclaim (struct nfs4_client *clp) +void nfs_delegation_mark_reclaim (struct nfs_client *clp) {struct nfs_delegation *delegation;spin_lock (&clp->cl_lock);
@@ -402,7 +403,7 @@ void nfs_delegation_mark_reclaim(struct/* * Reap all unclaimed delegations after reboot recovery is done */ -void nfs_delegation_reap_unclaimed (struct nfs4_client *clp) +void nfs_delegation_reap_unclaimed (struct nfs_client *clp) {struct nfs_delegation *delegation, *n;LIST_HEAD (head);
@@ -424,7 +425,7 @@ void nfs_delegation_reap_unclaimed(strucint nfs4_copy_delegation_stateid (nfs4_stateid *dst,struct inode *inode) { -struct nfs4_client *clp =NFS_SERVER (inode)->nfs4_state; +struct nfs_client *clp =NFS_SCLIENT (inode);struct nfs_inode *nfsi =NFS_I (inode);struct nfs_delegation *delegation;int res =0 ;
fs/nfs/delegation.h +5 -5
@@ -29,13 +29,13 @@ void nfs_inode_reclaim_delegation(structint __nfs_inode_return_delegation (struct inode *inode);int nfs_async_inode_return_delegation (struct inode *inode,const nfs4_stateid *stateid); -struct inode *nfs_delegation_find_inode (struct nfs4_client *clp,const struct nfs_fh *fhandle); +struct inode *nfs_delegation_find_inode (struct nfs_client *clp,const struct nfs_fh *fhandle);void nfs_return_all_delegations (struct super_block *sb); -void nfs_expire_all_delegations (struct nfs4_client *clp); -void nfs_handle_cb_pathdown (struct nfs4_client *clp); +void nfs_expire_all_delegations (struct nfs_client *clp); +void nfs_handle_cb_pathdown (struct nfs_client *clp); -void nfs_delegation_mark_reclaim (struct nfs4_client *clp); -void nfs_delegation_reap_unclaimed (struct nfs4_client *clp); +void nfs_delegation_mark_reclaim (struct nfs_client *clp); +void nfs_delegation_reap_unclaimed (struct nfs_client *clp);/* NFSv4 delegation-related procedures */ int nfs4_proc_delegreturn (struct inode *inode,struct rpc_cred *cred,const nfs4_stateid *stateid);
fs/nfs/dir.c +16 -12
@@ -31,6 +31,7 @@ #include <linux/nfs_mount.h>#include <linux/pagemap.h> #include <linux/smp_lock.h> #include <linux/namei.h> +#include <linux/mount.h> #include "nfs4_fs.h" #include "delegation.h"
@@ -182,7 +183,7 @@ int nfs_readdir_filler(nfs_readdir_descr again: timestamp = jiffies; error =NFS_PROTO (inode)->readdir (file->f_dentry, cred, desc->entry->cookie, page, -NFS_SERVER (inode)->dtsize, desc->plus); +NFS_SCLIENT (inode)->dtsize, desc->plus);if (error <0 ) {/* We requested READDIRPLUS, but the server doesn't grok it */ if (error == -ENOTSUPP && desc->plus) {
@@ -475,7 +476,7 @@ int uncached_readdir(nfs_readdir_descrip } desc->error =NFS_PROTO (inode)->readdir (file->f_dentry, cred, *desc->dir_cookie, page, -NFS_SERVER (inode)->dtsize, +NFS_SCLIENT (inode)->dtsize, desc->plus);spin_lock (&inode->i_lock);NFS_I (inode)->cache_validity |=NFS_INO_INVALID_ATIME ;
@@ -690,7 +691,7 @@ int nfs_lookup_verify_inode(struct inode goto out_force;/* This is an open(2) */ if (nfs_lookup_check_intent (nd,LOOKUP_OPEN ) !=0 && - !(server->flags &NFS_MOUNT_NOCTO )) + !(server->nfs_client->flags &NFS_MOUNT_NOCTO )) goto out_force; }return nfs_revalidate_inode (server, inode);
@@ -868,14 +869,14 @@ int nfs_is_exclusive_create(struct inodereturn (nd->intent.open.flags &O_EXCL ) !=0 ; } -static inline int nfs_reval_fsid (struct inode *dir, -struct nfs_fh *fh,struct nfs_fattr *fattr) +static inline int nfs_reval_fsid (struct vfsmount *mnt,struct inode *dir, +struct nfs_fh *fh,struct nfs_fattr *fattr) {struct nfs_server *server =NFS_SERVER (dir);if (!nfs_fsid_equal (&server->fsid, &fattr->fsid))/* Revalidate fsid on root dir */ -return __nfs_revalidate_inode (server, dir->i_sb->s_root->d_inode); +return __nfs_revalidate_inode (server, mnt->mnt_root->d_inode);return 0 ; }
@@ -892,7 +893,7 @@ static struct dentry *nfs_lookup(structnfs_inc_stats (dir,NFSIOS_VFSLOOKUP ); res =ERR_PTR (-ENAMETOOLONG ); -if (dentry->d_name.len >NFS_SERVER (dir)->namelen) +if (dentry->d_name.len >NFS_SCLIENT (dir)->namelen) goto out; res =ERR_PTR (-ENOMEM );
@@ -911,7 +912,7 @@ static struct dentry *nfs_lookup(struct res =ERR_PTR (error); goto out_unlock; } - error =nfs_reval_fsid (dir, &fhandle, &fattr); + error =nfs_reval_fsid (nd->mnt, dir, &fhandle, &fattr);if (error <0 ) { res =ERR_PTR (error); goto out_unlock;
@@ -920,8 +921,9 @@ static struct dentry *nfs_lookup(struct res = (struct dentry *)inode;if (IS_ERR (res)) goto out_unlock; + no_entry: - res =d_add_unique (dentry, inode); + res =d_materialise_unique (dentry, inode);if (res !=NULL ) dentry = res;nfs_renew_times (dentry);
@@ -970,7 +972,7 @@ static struct dentry *nfs_atomic_lookup(if (!is_atomic_open (dir, nd)) goto no_open; -if (dentry->d_name.len >NFS_SERVER (dir)->namelen) { +if (dentry->d_name.len >NFS_SCLIENT (dir)->namelen) { res =ERR_PTR (-ENAMETOOLONG ); goto out; }
@@ -1115,11 +1117,13 @@ static struct dentry *nfs_readdir_lookupdput (dentry);return NULL ; } - alias =d_add_unique (dentry, inode); + + alias =d_materialise_unique (dentry, inode);if (alias !=NULL ) {dput (dentry); dentry = alias; } +nfs_renew_times (dentry);nfs_set_verifier (dentry,nfs_save_change_attribute (dir));return dentry;
@@ -1145,7 +1149,7 @@ int nfs_instantiate(struct dentry *dentr }if (!(fattr->valid &NFS_ATTR_FATTR )) {struct nfs_server *server =NFS_SB (dentry->d_sb); - error = server->rpc_ops->getattr (server, fhandle, fattr); + error = server->nfs_client->rpc_ops->getattr (server, fhandle, fattr);if (error <0 ) goto out_err; }
fs/nfs/direct.c +4 -4
@@ -328,7 +328,7 @@ static void nfs_direct_read_schedule(strstruct page **pages = dreq->pages;size_t count = dreq->user_count;loff_t pos = dreq->pos; -size_t rsize =NFS_SERVER (inode)->rsize; +size_t rsize =NFS_SCLIENT (inode)->rsize;unsigned int curpage, pgbase; curpage =0 ;
@@ -392,7 +392,7 @@ static ssize_t nfs_direct_read(struct kistruct rpc_clnt *clnt =NFS_CLIENT (inode);struct nfs_direct_req *dreq; - dreq =nfs_direct_read_alloc (count,NFS_SERVER (inode)->rsize); + dreq =nfs_direct_read_alloc (count,NFS_SCLIENT (inode)->rsize);if (!dreq)return -ENOMEM ;
@@ -647,7 +647,7 @@ static void nfs_direct_write_schedule(ststruct page **pages = dreq->pages;size_t count = dreq->user_count;loff_t pos = dreq->pos; -size_t wsize =NFS_SERVER (inode)->wsize; +size_t wsize =NFS_SCLIENT (inode)->wsize;unsigned int curpage, pgbase; curpage =0 ;
@@ -711,7 +711,7 @@ static ssize_t nfs_direct_write(struct kstruct inode *inode = iocb->ki_filp->f_mapping->host;struct rpc_clnt *clnt =NFS_CLIENT (inode);struct nfs_direct_req *dreq; -size_t wsize =NFS_SERVER (inode)->wsize; +size_t wsize =NFS_SCLIENT (inode)->wsize;int sync =0 ; dreq =nfs_direct_write_alloc (count, wsize);
fs/nfs/file.c +5 -5
@@ -111,7 +111,7 @@ nfs_file_open(struct inode *inode, strucnfs_inc_stats (inode,NFSIOS_VFSOPEN );lock_kernel (); - res =NFS_SERVER (inode)->rpc_ops->file_open (inode, filp); + res =NFS_SCLIENT (inode)->rpc_ops->file_open (inode, filp);unlock_kernel ();return res; }
@@ -159,7 +159,7 @@ static int nfs_revalidate_file_size(strustruct nfs_server *server =NFS_SERVER (inode);struct nfs_inode *nfsi =NFS_I (inode); -if (server->flags &NFS_MOUNT_NOAC ) +if (server->nfs_client->flags &NFS_MOUNT_NOAC ) goto force_reval;if (filp->f_flags &O_DIRECT ) goto force_reval;
@@ -408,7 +408,7 @@ static int do_getlk(struct file *filp, iif (nfs_have_delegation (inode,FMODE_READ )) goto out_noconflict; -if (NFS_SERVER (inode)->flags &NFS_MOUNT_NONLM ) +if (NFS_SCLIENT (inode)->flags &NFS_MOUNT_NONLM ) goto out_noconflict; status =NFS_PROTO (inode)->lock (filp, cmd, fl);
@@ -456,7 +456,7 @@ static int do_unlk(struct file *filp, in*/ lock_kernel ();/* Use local locking if mounted with "-onolock" */ -if (!(NFS_SERVER (inode)->flags &NFS_MOUNT_NONLM )) +if (!(NFS_SCLIENT (inode)->flags &NFS_MOUNT_NONLM )) status =NFS_PROTO (inode)->lock (filp, cmd, fl);else status =do_vfs_lock (filp, fl);
@@ -479,7 +479,7 @@ static int do_setlk(struct file *filp, ilock_kernel ();/* Use local locking if mounted with "-onolock" */ -if (!(NFS_SERVER (inode)->flags &NFS_MOUNT_NONLM )) { +if (!(NFS_SCLIENT (inode)->flags &NFS_MOUNT_NONLM )) { status =NFS_PROTO (inode)->lock (filp, cmd, fl);/* If we were signalled we still need to ensure that * we clean up any state on the server. We therefore
fs/nfs/getroot.c new file +306 -0
306 lines not on this page · raw message
fs/nfs/idmap.c +14 -11
@@ -91,15 +91,16 @@ static struct rpc_pipe_ops idmap_upcall_ .destroy_msg = idmap_pipe_destroy_msg, }; -void -nfs_idmap_new (struct nfs4_client *clp) +int +nfs_idmap_new (struct nfs_client *clp) {struct idmap *idmap; +int error; + +BUG_ON (clp->cl_idmap !=NULL ); -if (clp->cl_idmap !=NULL ) -return ;if ((idmap =kzalloc (sizeof (*idmap),GFP_KERNEL )) ==NULL ) -return ; +return -ENOMEM ;snprintf (idmap->idmap_path,sizeof (idmap->idmap_path),"%s/idmap" , clp->cl_rpcclient->cl_pathname);
@@ -107,8 +108,9 @@ nfs_idmap_new(struct nfs4_client *clp) idmap->idmap_dentry =rpc_mkpipe (idmap->idmap_path, idmap, &idmap_upcall_ops,0 );if (IS_ERR (idmap->idmap_dentry)) { + error =PTR_ERR (idmap->idmap_dentry);kfree (idmap); -return ; +return error; }mutex_init (&idmap->idmap_lock);
@@ -118,10 +120,11 @@ nfs_idmap_new(struct nfs4_client *clp) idmap->idmap_group_hash.h_type =IDMAP_TYPE_GROUP ; clp->cl_idmap = idmap; +return 0 ; }void -nfs_idmap_delete (struct nfs4_client *clp) +nfs_idmap_delete (struct nfs_client *clp) {struct idmap *idmap = clp->cl_idmap;
@@ -476,27 +479,27 @@ static unsigned int fnvhash32(const voidreturn (hash); } -int nfs_map_name_to_uid (struct nfs4_client *clp,const char *name,size_t namelen,__u32 *uid) +int nfs_map_name_to_uid (struct nfs_client *clp,const char *name,size_t namelen,__u32 *uid) {struct idmap *idmap = clp->cl_idmap;return nfs_idmap_id (idmap, &idmap->idmap_user_hash, name, namelen, uid); } -int nfs_map_group_to_gid (struct nfs4_client *clp,const char *name,size_t namelen,__u32 *uid) +int nfs_map_group_to_gid (struct nfs_client *clp,const char *name,size_t namelen,__u32 *uid) {struct idmap *idmap = clp->cl_idmap;return nfs_idmap_id (idmap, &idmap->idmap_group_hash, name, namelen, uid); } -int nfs_map_uid_to_name (struct nfs4_client *clp,__u32 uid,char *buf) +int nfs_map_uid_to_name (struct nfs_client *clp,__u32 uid,char *buf) {struct idmap *idmap = clp->cl_idmap;return nfs_idmap_name (idmap, &idmap->idmap_user_hash, uid, buf); } -int nfs_map_gid_to_group (struct nfs4_client *clp,__u32 uid,char *buf) +int nfs_map_gid_to_group (struct nfs_client *clp,__u32 uid,char *buf) {struct idmap *idmap = clp->cl_idmap;
fs/nfs/inode.c +11 -4
@@ -257,13 +257,13 @@ nfs_fhget(struct super_block *sb, struct/* Why so? Because we want revalidate for devices/FIFOs, and * that's precisely what we have in nfs_file_inode_operations. */ - inode->i_op =NFS_SB (sb)->rpc_ops->file_inode_ops; + inode->i_op =NFS_SB (sb)->nfs_client->rpc_ops->file_inode_ops;if (S_ISREG (inode->i_mode)) { inode->i_fop = &nfs_file_operations; inode->i_data.a_ops = &nfs_file_aops; - inode->i_data.backing_dev_info = &NFS_SB (sb)->backing_dev_info; + inode->i_data.backing_dev_info = &NFS_SB (sb)->nfs_client->backing_dev_info; }else if (S_ISDIR (inode->i_mode)) { - inode->i_op =NFS_SB (sb)->rpc_ops->dir_inode_ops; + inode->i_op =NFS_SB (sb)->nfs_client->rpc_ops->dir_inode_ops; inode->i_fop = &nfs_dir_operations;if (nfs_server_capable (inode,NFS_CAP_READDIRPLUS ) && fattr->size <=NFS_LIMIT_READDIRPLUS )
@@ -1041,7 +1041,7 @@ #endif out_fileid:printk (KERN_ERR "NFS: server %s error: fileid changed\n" "fsid %s: expected fileid 0x%Lx, got 0x%Lx\n" , -NFS_SERVER (inode)->hostname, inode->i_sb->s_id, +NFS_SCLIENT (inode)->hostname, inode->i_sb->s_id, (long long )nfsi->fileid, (long long )fattr->fileid); goto out_err; }
@@ -1162,6 +1162,10 @@ static int __init init_nfs_fs(void) {int err; + err =nfs_fs_proc_init (); +if (err) + goto out5; + err =nfs_init_nfspagecache ();if (err) goto out4;
@@ -1202,6 +1206,8 @@ out2: out3:nfs_destroy_nfspagecache (); out4: +nfs_fs_proc_exit (); +out5:return err; }
@@ -1216,6 +1222,7 @@ #ifdef CONFIG_PROC_FSrpc_proc_unregister ("nfs" );#endif unregister_nfs_fs (); +nfs_fs_proc_exit (); }/* Not quite true; I just maintain it */
fs/nfs/internal.h +68 -33
156 lines not on this page · raw message
fs/nfs/namespace.c +23 -10
@@ -2,6 +2,7 @@* linux/fs/nfs/namespace.c * * Copyright (C) 2005 Trond Myklebust <[email protected]> +* - Modified by David Howells <[email protected]> * * NFS namespace */
@@ -28,6 +29,7 @@ int nfs_mountpoint_expiry_timeout = 500/* * nfs_path - reconstruct the path given an arbitrary dentry * @base - arbitrary string to prepend to the path +* @droot - pointer to root dentry for mountpoint * @dentry - pointer to dentry * @buffer - result buffer * @buflen - length of buffer
@@ -38,7 +40,9 @@ int nfs_mountpoint_expiry_timeout = 500* This is mainly for use in figuring out the path on the * server side when automounting on top of an existing partition. */ -char *nfs_path (const char *base,const struct dentry *dentry, +char *nfs_path (const char *base, +const struct dentry *droot, +const struct dentry *dentry,char *buffer,ssize_t buflen) {char *end = buffer+buflen;
@@ -47,7 +51,7 @@ char *nfs_path(const char *base, const s *--end ='\0' ; buflen--;spin_lock (&dcache_lock); -while (!IS_ROOT (dentry)) { +while (!IS_ROOT (dentry) && dentry != droot) { namelen = dentry->d_name.len; buflen -= namelen +1 ;if (buflen <0 )
@@ -94,15 +98,17 @@ static void * nfs_follow_mountpoint(strustruct nfs_fattr fattr;int err; +dprintk ("--> nfs_follow_mountpoint()\n" ); +BUG_ON (IS_ROOT (dentry));dprintk ("%s: enter\n" , __FUNCTION__);dput (nd->dentry); nd->dentry =dget (dentry); -if (d_mountpoint (nd->dentry)) - goto out_follow; +/* Look it up again */ parent =dget_parent (nd->dentry); - err = server->rpc_ops->lookup (parent->d_inode, &nd->dentry->d_name, &fh, &fattr); + err = server->nfs_client->rpc_ops->lookup (parent->d_inode, &nd->dentry->d_name, + &fh, &fattr);dput (parent);if (err !=0 ) goto out_err;
@@ -130,6 +136,8 @@ static void * nfs_follow_mountpoint(struschedule_delayed_work (&nfs_automount_task, nfs_mountpoint_expiry_timeout); out:dprintk ("%s: done, returned %d\n" , __FUNCTION__, err); + +dprintk ("<-- nfs_follow_mountpoint() = %d\n" , err);return ERR_PTR (err); out_err:path_release (nd);
@@ -170,22 +178,23 @@ void nfs_release_automount_timer(void)/* * Clone a mountpoint of the appropriate type */ -static struct vfsmount *nfs_do_clone_mount (struct nfs_server *server,char *devname, +static struct vfsmount *nfs_do_clone_mount (struct nfs_server *server, +const char *devname,struct nfs_clone_mount *mountdata) {#ifdef CONFIG_NFS_V4 struct vfsmount *mnt =NULL ; -switch (server->rpc_ops->version) { +switch (server->nfs_client->rpc_ops->version) {case 2 :case 3 : - mnt =vfs_kern_mount (&clone_nfs_fs_type,0 , devname, mountdata); + mnt =vfs_kern_mount (&nfs_xdev_fs_type,0 , devname, mountdata);break ;case 4 : - mnt =vfs_kern_mount (&clone_nfs4_fs_type,0 , devname, mountdata); + mnt =vfs_kern_mount (&nfs4_xdev_fs_type,0 , devname, mountdata); }return mnt;#else -return vfs_kern_mount (&clone_nfs_fs_type,0 , devname, mountdata); +return vfs_kern_mount (&nfs_xdev_fs_type,0 , devname, mountdata);#endif }
@@ -211,6 +220,8 @@ struct vfsmount *nfs_do_submount(const schar *page = (char *)__get_free_page (GFP_USER );char *devname; +dprintk ("--> nfs_do_submount()\n" ); +dprintk ("%s: submounting on %s/%s\n" , __FUNCTION__, dentry->d_parent->d_name.name, dentry->d_name.name);
@@ -225,5 +236,7 @@ free_page:free_page ((unsigned long )page); out:dprintk ("%s: done\n" , __FUNCTION__); + +dprintk ("<-- nfs_do_submount() = %p\n" , mnt);return mnt; }
fs/nfs/nfs3acl.c +4 -4
@@ -222,8 +222,8 @@ struct posix_acl *nfs3_proc_getacl(strucreturn NULL ;dprintk ("NFS call getacl\n" ); - msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_GETACL ]; - status =rpc_call_sync (server->client_acl, &msg,0 ); + msg.rpc_proc = &server->nfs_client->client_acl->cl_procinfo[ACLPROC3_GETACL ]; + status =rpc_call_sync (server->nfs_client->client_acl, &msg,0 );dprintk ("NFS reply getacl: %d\n" , status);/* pages may have been allocated at the xdr layer. */
@@ -314,8 +314,8 @@ static int nfs3_proc_setacls(struct inoddprintk ("NFS call setacl\n" );nfs_begin_data_update (inode); - msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL ]; - status =rpc_call_sync (server->client_acl, &msg,0 ); + msg.rpc_proc = &server->nfs_client->client_acl->cl_procinfo[ACLPROC3_SETACL ]; + status =rpc_call_sync (server->nfs_client->client_acl, &msg,0 );spin_lock (&inode->i_lock);NFS_I (inode)->cache_validity |=NFS_INO_INVALID_ACCESS ;spin_unlock (&inode->i_lock);
fs/nfs/nfs3proc.c +8 -8
@@ -81,7 +81,7 @@ do_proc_get_root(struct rpc_clnt *client }/* -* Bare-bones access to getattr: this is for nfs_read_super. +* Bare-bones access to getattr: this is for nfs_get_root/nfs_get_sb */ static int nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
@@ -89,9 +89,9 @@ nfs3_proc_get_root(struct nfs_server *se {int status; - status =do_proc_get_root (server->client, fhandle, info); -if (status && server->client_sys != server->client) - status =do_proc_get_root (server->client_sys, fhandle, info); + status =do_proc_get_root (server->nfs_client->client, fhandle, info); +if (status && server->nfs_client->client_sys != server->nfs_client->client) + status =do_proc_get_root (server->nfs_client->client_sys, fhandle, info);return status; }
@@ -111,7 +111,7 @@ nfs3_proc_getattr(struct nfs_server *serdprintk ("NFS call getattr\n" );nfs_fattr_init (fattr); - status =rpc_call_sync (server->client, &msg,0 ); + status =rpc_call_sync (server->nfs_client->client, &msg,0 );dprintk ("NFS reply getattr: %d\n" , status);return status; }
@@ -767,7 +767,7 @@ nfs3_proc_statfs(struct nfs_server *servdprintk ("NFS call fsstat\n" );nfs_fattr_init (stat->fattr); - status =rpc_call_sync (server->client, &msg,0 ); + status =rpc_call_sync (server->nfs_client->client, &msg,0 );dprintk ("NFS reply statfs: %d\n" , status);return status; }
@@ -785,7 +785,7 @@ nfs3_proc_fsinfo(struct nfs_server *servdprintk ("NFS call fsinfo\n" );nfs_fattr_init (info->fattr); - status =rpc_call_sync (server->client_sys, &msg,0 ); + status =rpc_call_sync (server->nfs_client->client_sys, &msg,0 );dprintk ("NFS reply fsinfo: %d\n" , status);return status; }
@@ -803,7 +803,7 @@ nfs3_proc_pathconf(struct nfs_server *sedprintk ("NFS call pathconf\n" );nfs_fattr_init (info->fattr); - status =rpc_call_sync (server->client, &msg,0 ); + status =rpc_call_sync (server->nfs_client->client, &msg,0 );dprintk ("NFS reply pathconf: %d\n" , status);return status; }
fs/nfs/nfs4_fs.h +12 -15
@@ -42,6 +42,7 @@ enum nfs4_client_state { NFS4CLNT_LEASE_EXPIRED, }; +#if 0 /* * The nfs4_client identifies our client state to the server. */
@@ -90,6 +91,7 @@ struct nfs4_client {char cl_ipaddr[16 ]; unsigned char cl_id_uniquifier; }; +#endif /* * struct rpc_sequence ensures that RPC calls are sent in the exact
@@ -127,7 +129,7 @@ static inline void nfs_confirm_seqid(strstruct nfs4_state_owner {spinlock_t so_lock;struct list_head so_list;/* per-clientid list of state_owners */ -struct nfs4_client *so_client; +struct nfs_client *so_client;u32 so_id;/* 32-bit identifier, unique */ atomic_t so_count;
@@ -210,10 +212,10 @@ extern ssize_t nfs4_listxattr(struct den/* nfs4proc.c */ extern int nfs4_map_errors (int err); -extern int nfs4_proc_setclientid (struct nfs4_client *,u32 ,unsigned short ,struct rpc_cred *); -extern int nfs4_proc_setclientid_confirm (struct nfs4_client *,struct rpc_cred *); -extern int nfs4_proc_async_renew (struct nfs4_client *,struct rpc_cred *); -extern int nfs4_proc_renew (struct nfs4_client *,struct rpc_cred *); +extern int nfs4_proc_setclientid (struct nfs_client *,u32 ,unsigned short ,struct rpc_cred *); +extern int nfs4_proc_setclientid_confirm (struct nfs_client *,struct rpc_cred *); +extern int nfs4_proc_async_renew (struct nfs_client *,struct rpc_cred *); +extern int nfs4_proc_renew (struct nfs_client *,struct rpc_cred *);extern int nfs4_do_close (struct inode *inode,struct nfs4_state *state);extern struct dentry *nfs4_atomic_open (struct inode *,struct dentry *,struct nameidata *);extern int nfs4_open_revalidate (struct inode *,struct dentry *,int ,struct nameidata *);
@@ -231,19 +233,14 @@ extern const u32 nfs4_fsinfo_bitmap[2];extern const u32 nfs4_fs_locations_bitmap[2 ];/* nfs4renewd.c */ -extern void nfs4_schedule_state_renewal (struct nfs4_client *); +extern void nfs4_schedule_state_renewal (struct nfs_client *);extern void nfs4_renewd_prepare_shutdown (struct nfs_server *); -extern void nfs4_kill_renewd (struct nfs4_client *); +extern void nfs4_kill_renewd (struct nfs_client *);extern void nfs4_renew_state (void *);/* nfs4state.c */ -extern void init_nfsv4_state (struct nfs_server *); -extern void destroy_nfsv4_state (struct nfs_server *); -extern struct nfs4_client *nfs4_get_client (struct in_addr *); -extern void nfs4_put_client (struct nfs4_client *clp); -extern struct nfs4_client *nfs4_find_client (struct in_addr *); -struct rpc_cred *nfs4_get_renew_cred (struct nfs4_client *clp); -extern u32 nfs4_alloc_lockowner_id (struct nfs4_client *); +struct rpc_cred *nfs4_get_renew_cred (struct nfs_client *clp); +extern u32 nfs4_alloc_lockowner_id (struct nfs_client *);extern struct nfs4_state_owner *nfs4_get_state_owner (struct nfs_server *,struct rpc_cred *);extern void nfs4_put_state_owner (struct nfs4_state_owner *);
@@ -252,7 +249,7 @@ extern struct nfs4_state * nfs4_get_openextern void nfs4_put_open_state (struct nfs4_state *);extern void nfs4_close_state (struct nfs4_state *,mode_t );extern void nfs4_state_set_mode_locked (struct nfs4_state *,mode_t ); -extern void nfs4_schedule_state_recovery (struct nfs4_client *); +extern void nfs4_schedule_state_recovery (struct nfs_client *);extern void nfs4_put_lock_state (struct nfs4_lock_state *lsp);extern int nfs4_set_lock_state (struct nfs4_state *state,struct file_lock *fl);extern void nfs4_copy_stateid (nfs4_stateid *,struct nfs4_state *,fl_owner_t );
fs/nfs/nfs4namespace.c +90 -30
205 lines not on this page · raw message
fs/nfs/nfs4proc.c +106 -106
124 lines not on this page · raw message
fs/nfs/nfs4state.c +21 -155
176 lines not on this page · raw message
fs/nfs/nfs4xdr.c +21 -21
42 lines not on this page · raw message
fs/nfs/super.c +477 -916
1,393 lines not on this page · raw message
include/linux/nfs_fs_sb.h +69 -11
80 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
David Howells
maintainerPATCH 7/14 FS-Cache: Provide a filesystem-specific sync'able page bit [try #10]
In reply to David HowellsThe attached patch provides a filesystem-specific page bit that a filesystem can synchronise upon. This can be used, for example, by a netfs to synchronise with CacheFS writing its pages to disk.
The PG_checked bit is replaced with PG_fs_misc, and various operations are provided based upon that. The *PageChecked() macros still exist, though now they just convert to *PageFsMisc() macros. The name of the "checked" macros seems appropriate as they're used for metadata page validation by various filesystems.
---
fs/afs/dir.c | 5 +---- fs/ext2/dir.c | 6 +++--- fs/ext3/inode.c | 10 +++++----- fs/freevxfs/vxfs_subr.c | 2 +- fs/reiserfs/inode.c | 10 +++++----- include/linux/page-flags.h | 15 ++++++++++----- include/linux/pagemap.h | 11 +++++++++++ mm/filemap.c | 17 +++++++++++++++++ mm/migrate.c | 4 ++-- mm/page_alloc.c | 2 +- 10 files changed, 56 insertions(+), 26 deletions(-)
fs/afs/dir.c +1 -4
@@ -155,11 +155,9 @@ #endif } } -SetPageChecked (page);return ; error: -SetPageChecked (page);SetPageError (page); }/* end afs_dir_check_page() */
@@ -193,8 +191,7 @@ static struct page *afs_dir_get_page(strkmap (page);if (!PageUptodate (page)) goto fail; -if (!PageChecked (page)) -afs_dir_check_page (dir, page); +afs_dir_check_page (dir, page);if (PageError (page)) goto fail; }
fs/ext2/dir.c +3 -3
@@ -112,7 +112,7 @@ static void ext2_check_page(struct pageif (offs != limit) goto Eend; out: -SetPageChecked (page); +SetPageFsMisc (page);return ;/* Too bad, we had an error */
@@ -152,7 +152,7 @@ Eend: dir->i_ino, (page->index<<PAGE_CACHE_SHIFT )+offs, (unsigned long) le32_to_cpu(p->inode)); fail: -SetPageChecked (page); +SetPageFsMisc (page);SetPageError (page); }
@@ -166,7 +166,7 @@ static struct page * ext2_get_page(struckmap (page);if (!PageUptodate (page)) goto fail; -if (!PageChecked (page)) +if (!PageFsMisc (page))ext2_check_page (page);if (PageError (page)) goto fail;
fs/ext3/inode.c +5 -5
@@ -1528,12 +1528,12 @@ static int ext3_journalled_writepage(str goto no_write; } -if (!page_has_buffers (page) ||PageChecked (page)) { +if (!page_has_buffers (page) ||PageFsMisc (page)) {/* * It's mmapped pagecache. Add buffers and journal it. There * doesn't seem much point in redirtying the page here. */ -ClearPageChecked (page); +ClearPageFsMisc (page); ret =block_prepare_write (page,0 ,PAGE_CACHE_SIZE , ext3_get_block);if (ret !=0 ) {
@@ -1590,7 +1590,7 @@ static void ext3_invalidatepage(struct p* If it's a full truncate we just forget about the pending dirtying */ if (offset ==0 ) -ClearPageChecked (page); +ClearPageFsMisc (page);journal_invalidatepage (journal, page, offset); }
@@ -1599,7 +1599,7 @@ static int ext3_releasepage(struct page {journal_t *journal =EXT3_JOURNAL (page->mapping->host); -WARN_ON (PageChecked (page)); +WARN_ON (PageFsMisc (page));if (!page_has_buffers (page))return 0 ;return journal_try_to_free_buffers (journal, page, wait);
@@ -1695,7 +1695,7 @@ out:*/ static int ext3_journalled_set_page_dirty (struct page *page) { -SetPageChecked (page); +SetPageFsMisc (page);return __set_page_dirty_nobuffers (page); }
fs/freevxfs/vxfs_subr.c +1 -1
@@ -79,7 +79,7 @@ vxfs_get_page(struct address_space *mappkmap (pp);if (!PageUptodate (pp)) goto fail; -/** if (!PageChecked(pp)) **/ +/** if (!PageFsMisc(pp)) **/ /** vxfs_check_page(pp); **/ if (PageError (pp)) goto fail;
fs/reiserfs/inode.c +5 -5
@@ -2352,7 +2352,7 @@ static int reiserfs_write_full_page(strustruct buffer_head *head, *bh;int partial =0 ;int nr =0 ; -int checked =PageChecked (page); +int checked =PageFsMisc (page);struct reiserfs_transaction_handle th;struct super_block *s = inode->i_sb;int bh_per_page =PAGE_CACHE_SIZE / s->s_blocksize;
@@ -2421,7 +2421,7 @@ static int reiserfs_write_full_page(stru* blocks we're going to log */ if (checked) { -ClearPageChecked (page); +ClearPageFsMisc (page);reiserfs_write_lock (s); error =journal_begin (&th, s, bh_per_page +1 );if (error) {
@@ -2802,7 +2802,7 @@ static void reiserfs_invalidatepage(struBUG_ON (!PageLocked (page));if (offset ==0 ) -ClearPageChecked (page); +ClearPageFsMisc (page);if (!page_has_buffers (page)) goto out;
@@ -2843,7 +2843,7 @@ static int reiserfs_set_page_dirty(struc {struct inode *inode = page->mapping->host;if (reiserfs_file_data_log (inode)) { -SetPageChecked (page); +SetPageFsMisc (page);return __set_page_dirty_nobuffers (page); }return __set_page_dirty_buffers (page);
@@ -2866,7 +2866,7 @@ static int reiserfs_releasepage(struct pstruct buffer_head *bh;int ret =1 ; -WARN_ON (PageChecked (page)); +WARN_ON (PageFsMisc (page));spin_lock (&j->j_dirty_buffers_lock); head =page_buffers (page); bh = head;
include/linux/page-flags.h +10 -5
@@ -73,7 +73,7 @@ #define PG_lru 5#define PG_active 6#define PG_slab 7/* slab debug (Suparna wants this) */ -#define PG_checked 8/* kill me in 2.5.<early>. */ +#define PG_fs_misc 8#define PG_arch_1 9#define PG_reserved 10#define PG_private 11/* Has something at ->private */
@@ -274,10 +274,6 @@ #else#define PageHighMem (page) 0/* needed to optimize away at compile time */ #endif -#define PageChecked (page) test_bit(PG_checked, &(page)->flags) -#define SetPageChecked (page) set_bit(PG_checked, &(page)->flags) -#define ClearPageChecked (page) clear_bit(PG_checked, &(page)->flags) -#define PageReserved (page) test_bit(PG_reserved, &(page)->flags)#define SetPageReserved (page) set_bit(PG_reserved, &(page)->flags)#define ClearPageReserved (page) clear_bit(PG_reserved, &(page)->flags)
@@ -376,4 +372,13 @@ static inline void set_page_writeback(st test_set_page_writeback(page); } +/* +* Filesystem-specific page bit testing +*/ +#define PageFsMisc (page) test_bit(PG_fs_misc, &(page)->flags) +#define SetPageFsMisc (page) set_bit(PG_fs_misc, &(page)->flags) +#define TestSetPageFsMisc (page) test_and_set_bit(PG_fs_misc, &(page)->flags) +#define ClearPageFsMisc (page) clear_bit(PG_fs_misc, &(page)->flags) +#define TestClearPageFsMisc (page) test_and_clear_bit(PG_fs_misc, &(page)->flags) +#endif /* PAGE_FLAGS_H */
include/linux/pagemap.h +11 -0
@@ -208,6 +208,17 @@ static inline void wait_on_page_writebacextern void end_page_writeback (struct page *page);/* +* Wait for filesystem-specific page synchronisation to complete +*/ +static inline void wait_on_page_fs_misc (struct page *page) +{ +if (PageFsMisc (page)) +wait_on_page_bit (page, PG_fs_misc); +} + +extern void fastcall end_page_fs_misc(struct page *page); + +/* * Fault a userspace page into pagetables. Return non-zero on a fault. * * This assumes that two userspace pages are always sufficient. That's
mm/filemap.c +17 -0
@@ -545,6 +545,23 @@ void fastcall __lock_page(struct page *pEXPORT_SYMBOL (__lock_page);/* +* Note completion of filesystem specific page synchronisation +* +* This is used to allow a page to be written to a filesystem cache in the +* background without holding up the completion of readpage +*/ +void fastcall end_page_fs_misc(struct page *page) +{ +smp_mb__before_clear_bit (); +if (!TestClearPageFsMisc (page)) +BUG (); +smp_mb__after_clear_bit (); +__wake_up_bit (page_waitqueue (page), &page->flags, PG_fs_misc); +} + +EXPORT_SYMBOL (end_page_fs_misc); + +/* * a rather lightweight function, finding and getting a reference to a * hashed page atomically. */
mm/migrate.c +2 -2
@@ -272,8 +272,8 @@ void migrate_page_copy(struct page *newpSetPageUptodate (newpage);if (PageActive (page))SetPageActive (newpage); -if (PageChecked (page)) -SetPageChecked (newpage); +if (PageFsMisc (page)) +SetPageFsMisc (newpage);if (PageMappedToDisk (page))SetPageMappedToDisk (newpage);
mm/page_alloc.c +1 -1
@@ -544,7 +544,7 @@ static int prep_new_page(struct page *pa page->flags &= ~(1 << PG_uptodate |1 << PG_error |1 << PG_referenced |1 << PG_arch_1 | -1 << PG_checked |1 << PG_mappedtodisk); +1 << PG_fs_misc |1 << PG_mappedtodisk);set_page_private (page,0 );set_page_refcounted (page);kernel_map_pages (page,1 << order,1 );
David Howells
maintainerPATCH 8/14 FS-Cache: Add notification of page becoming writable to VMA ops [try #10]
In reply to David HowellsThe attached patch adds a new VMA operation to notify a filesystem or other driver about the MMU generating a fault because userspace attempted to write to a page mapped through a read-only PTE.
This facility permits the filesystem or driver to:
(*) Implement storage allocation/reservation on attempted write, and so to
deal with problems such as ENOSPC more gracefully (perhaps by generating SIGBUS).
(*) Delay making the page writable until the contents have been written to a
backing cache. This is useful for NFS/AFS when using FS-Cache/CacheFS. It permits the filesystem to have some guarantee about the state of the cache.
(*) Account and limit number of dirty pages. This is one piece of the puzzle
needed to make shared writable mapping work safely in FUSE.
---
include/linux/mm.h | 4 ++ mm/memory.c | 99 +++++++++++++++++++++++++++++++++++++++------------- mm/mmap.c | 12 +++++- mm/mprotect.c | 11 +++++- 4 files changed, 98 insertions(+), 28 deletions(-)
include/linux/mm.h +4 -0
@@ -200,6 +200,10 @@ struct vm_operations_struct {void (*close)(struct vm_area_struct * area);struct page * (*nopage)(struct vm_area_struct * area,unsigned long address,int *type);int (*populate)(struct vm_area_struct * area,unsigned long address,unsigned long len,pgprot_t prot,unsigned long pgoff,int nonblock); + +/* notification that a previously read-only page is about to become +* writable, if an error is returned it will cause a SIGBUS */ +int (*page_mkwrite)(struct vm_area_struct *vma,struct page *page);#ifdef CONFIG_NUMA int (*set_policy)(struct vm_area_struct *vma,struct mempolicy *new); struct mempolicy *(*get_policy)(struct vm_area_struct *vma,
mm/memory.c +75 -24
124 lines not on this page · raw message
mm/mmap.c +10 -2
@@ -1065,7 +1065,8 @@ munmap_back: vma->vm_start = addr; vma->vm_end = addr + len; vma->vm_flags = vm_flags; - vma->vm_page_prot = protection_map[vm_flags &0x0f ]; + vma->vm_page_prot = protection_map[vm_flags & + (VM_READ |VM_WRITE |VM_EXEC |VM_SHARED )]; vma->vm_pgoff = pgoff;if (file) {
@@ -1089,6 +1090,12 @@ munmap_back: goto free_vma; } +/* Don't make the VMA automatically writable if it's shared, but the +* backer wishes to know when pages are first written to */ +if (vma->vm_ops && vma->vm_ops->page_mkwrite) + vma->vm_page_prot = + protection_map[vm_flags & (VM_READ |VM_WRITE |VM_EXEC )]; +/* We set VM_ACCOUNT in a shared mapping's vm_flags, to inform * shmem_zero_setup (perhaps called through /dev/zero's ->mmap) * that memory reservation must be checked; but that reservation
@@ -1921,7 +1928,8 @@ unsigned long do_brk(unsigned long addr, vma->vm_end = addr + len; vma->vm_pgoff = pgoff; vma->vm_flags = flags; - vma->vm_page_prot = protection_map[flags &0x0f ]; + vma->vm_page_prot = protection_map[flags & + (VM_READ |VM_WRITE |VM_EXEC |VM_SHARED )];vma_link (mm, vma, prev, rb_link, rb_parent); out: mm->total_vm += len >>PAGE_SHIFT ;
mm/mprotect.c +9 -2
@@ -106,6 +106,7 @@ mprotect_fixup(struct vm_area_struct *vmunsigned long oldflags = vma->vm_flags;long nrpages = (end - start) >>PAGE_SHIFT ;unsigned long charged =0 ; +unsigned int mask;pgprot_t newprot;pgoff_t pgoff;int error;
@@ -132,8 +133,6 @@ mprotect_fixup(struct vm_area_struct *vm } } - newprot = protection_map[newflags &0xf ]; -/* * First try to merge with previous and/or next vma. */
@@ -160,6 +159,14 @@ mprotect_fixup(struct vm_area_struct *vm } success: +/* Don't make the VMA automatically writable if it's shared, but the +* backer wishes to know when pages are first written to */ + mask =VM_READ |VM_WRITE |VM_EXEC |VM_SHARED ; +if (vma->vm_ops && vma->vm_ops->page_mkwrite) + mask &= ~VM_SHARED ; + + newprot = protection_map[newflags & mask]; +/* * vm_flags and vm_page_prot are protected by the mmap_sem * held in write mode.
David Howells
maintainerPATCH 9/14 FS-Cache: Avoid ENFILE checking for kernel-specific open files [try #10]
In reply to David HowellsMake it possible to avoid ENFILE checking for kernel specific open files, such as are used by the CacheFiles module.
After, for example, tarring up a kernel source tree over the network, the CacheFiles module may easily have 20000+ files open in the backing filesystem, thus causing all non-root processes to be given error ENFILE when they try to open a file, socket, pipe, etc..
---
Documentation/sysctl/fs.txt | 6 ++++- fs/file_table.c | 48 +++++++++++++++++++++++++++++++++++-------- fs/open.c | 20 ++++++++++++++++++ include/linux/file.h | 1 - include/linux/fs.h | 10 +++++++++ include/linux/sysctl.h | 1 + kernel/sysctl.c | 11 ++++++++++ 7 files changed, 86 insertions(+), 11 deletions(-)
Documentation/sysctl/fs.txt +5 -1
@@ -71,7 +71,7 @@ you might want to raise the limit. ============================================================== -file-max & file-nr: +file-max, file-nr & file-kernel: The kernel allocates file handles dynamically, but as yet it doesn't free them again.
@@ -88,6 +88,10 @@ close to the maximum, but the number of significantly greater than 0, you've encountered a peak in your usage of file handles and you don't need to increase the maximum. +The value in file-kernel denotes the number of internal file handles +that the kernel has open. These do not contribute to ENFILE +accounting. + ============================================================== inode-max, inode-nr & inode-state:
fs/file_table.c +39 -9
107 lines not on this page · raw message
fs/open.c +20 -0
@@ -974,6 +974,26 @@ struct file *dentry_open(struct dentry *EXPORT_SYMBOL (dentry_open);/* +* open a specifically in-kernel file +*/ +struct file *dentry_open_kernel (struct dentry *dentry,struct vfsmount *mnt,int flags) +{ +int error; +struct file *f; + + error = -ENFILE ; + f =get_empty_kernel_filp (FKFLAGS_NO_ENFILE ); +if (f ==NULL ) { +dput (dentry); +mntput (mnt); +return ERR_PTR (error); + } + +return __dentry_open (dentry, mnt, flags, f,NULL ); +} +EXPORT_SYMBOL_GPL (dentry_open_kernel); + +/* * Find an empty file descriptor entry, and mark it busy. */ int get_unused_fd (void )
include/linux/file.h +0 -1
@@ -79,7 +79,6 @@ extern void FASTCALL(set_close_on_exec(uextern void put_filp (struct file *);extern int get_unused_fd (void );extern void FASTCALL (put_unused_fd (unsigned int fd)); -struct kmem_cache ;extern struct file **alloc_fd_array (int );extern void free_fd_array (struct file **,int );
include/linux/fs.h +10 -0
@@ -34,7 +34,11 @@ struct files_stat_struct {int nr_free_files;/* read only */ int max_files;/* tunable */ }; +struct files_kernel_stat_struct { +int nr_kernel_files;/* read only */ +};extern struct files_stat_struct files_stat; +extern struct files_kernel_stat_struct files_kernel_stat;extern int get_max_files (void );struct inodes_stat_t {
@@ -70,6 +74,8 @@ #define FMODE_PWRITE FMODE_PREAD /* Thesbehavior for cross-node execution/opening_for_writing of files */ #define FMODE_EXEC 16 +#define FKFLAGS_NO_ENFILE 1/* kernel internal file (ignored for ENFILE accounting) */ +#define RW_MASK 1#define RWA_MASK 2#define READ 0
@@ -640,6 +646,7 @@ struct file {atomic_t f_count;unsigned int f_flags;mode_t f_mode; +unsigned short f_kernel_flags;loff_t f_pos;struct fown_struct f_owner;unsigned int f_uid, f_gid;
@@ -1382,6 +1389,7 @@ extern long do_sys_open(int fdf, const c int mode);extern struct file *filp_open (const char *,int ,int );extern struct file *dentry_open (struct dentry *,struct vfsmount *,int ); +extern struct file *dentry_open_kernel (struct dentry *,struct vfsmount *,int );extern int filp_close (struct file *,fl_owner_t id);extern char *getname (const char __user *);
@@ -1583,6 +1591,7 @@ static inline void insert_inode_hash(str }extern struct file *get_empty_filp (void ); +extern struct file *get_empty_kernel_filp (unsigned short fkflags);extern void file_move (struct file *f,struct list_head *list);extern void file_kill (struct file *f);struct bio ;
@@ -1608,6 +1617,7 @@ extern ssize_t generic_file_direct_write unsigned long *, loff_t, loff_t *, size_t, size_t);extern ssize_t generic_file_buffered_write (struct kiocb *,const struct iovec *,unsigned long ,loff_t ,loff_t *,size_t ,ssize_t ); +extern int generic_file_buffered_write_one_kernel_page (struct file *,pgoff_t ,struct page *);extern ssize_t do_sync_read (struct file *filp,char __user *buf,size_t len,loff_t *ppos);extern ssize_t do_sync_write (struct file *filp,const char __user *buf,size_t len,loff_t *ppos); ssize_t generic_file_write_nolock(struct file *file, const struct iovec *iov,
include/linux/sysctl.h +1 -0
@@ -787,6 +787,7 @@ enumFS_AIO_NR =18 ,/* current system-wide number of aio requests */ FS_AIO_MAX_NR =19 ,/* system-wide maximum number of aio requests */ FS_INOTIFY =20 ,/* inotify submenu */ + FS_FILE_KERNEL=21, /* int: number of internal kernel files */ };/* /proc/sys/fs/quota/ */
kernel/sysctl.c +11 -0
@@ -53,6 +53,9 @@ #include <asm/processor.h>extern int proc_nr_files (ctl_table *table,int write,struct file *filp,void __user *buffer,size_t *lenp,loff_t *ppos); +extern int proc_files_kernel (ctl_table *table,int write,struct file *filp, +void __user *buffer,size_t *lenp,loff_t *ppos); +#if defined(CONFIG_SYSCTL )/* External variables not in a header file. */
@@ -956,6 +959,14 @@ static ctl_table fs_table[] = { .proc_handler = &proc_dointvec, }, { + .ctl_name = FS_FILE_KERNEL, + .procname = "file-kernel", + .data = &files_stat, + .maxlen = 1*sizeof(int), + .mode = 0444, + .proc_handler = &proc_files_kernel, + }, + { .ctl_name = FS_DENTRY, .procname = "dentry-state", .data = &dentry_stat,
David Howells
maintainerPATCH 10/14 FS-Cache: Generic filesystem caching facility [try #10]
In reply to David HowellsThe attached patch adds a generic intermediary (FS-Cache) by which filesystems may call on local caching capabilities, and by which local caching backends may make caches available:
+---------+ | | +--------------+ | NFS |--+ | | | | | +-->| CacheFS | +---------+ | +----------+ | | /dev/hda5 | | | | | +--------------+ +---------+ +-->| | | | | | |--+ | AFS |----->| FS-Cache | | | | |--+ +---------+ +-->| | | | | | | +--------------+ +---------+ | +----------+ | | | | | | +-->| CacheFiles | | ISOFS |--+ | /var/cache | | | +--------------+ +---------+
The patch also documents the netfs interface and the cache backend interface provided by the facility.
There are a number of reasons why I'm not using i_mapping to do this. These have been discussed a lot on the LKML and CacheFS mailing lists, but to summarise the basics:
(1) Most filesystems don't do hole reportage. Holes in files are treated as blocks of zeros and can't be distinguished otherwise, making it difficult to distinguish blocks that have been read from the network and cached from those that haven't.
(2) The backing inode must be fully populated before being exposed to userspace through the main inode because the VM/VFS goes directly to the backing inode and does not interrogate the front inode on VM ops.
Therefore:
(a) The backing inode must fit entirely within the cache.
(b) All backed files currently open must fit entirely within the cache at the same time.
(c) A working set of files in total larger than the cache may not be cached.
(d) A file may not grow larger than the available space in the cache.
(e) A file that's open and cached, and remotely grows larger than the cache is potentially stuffed.
(3) Writes go to the backing filesystem, and can only be transferred to the network when the file is closed.
(4) There's no record of what changes have been made, so the whole file must be written back.
(5) The pages belong to the backing filesystem, and all metadata associated with that page are relevant only to the backing filesystem, and not anything stacked atop it.
The attached patch adds a generic core to which both networking filesystems and caches may bind. It transfers requests from networking filesystems to appropriate caches if possible, or else gracefully denies them.
If this facility is disabled in the kernel configuration, then all its operations will be trivially reducible to nothing by the compiler.
FS-Cache provides the following facilities:
(1) Caches can be added / removed at any time, even whilst in use.
(2) Adds a facility by which tags can be used to refer to caches, even if they're not mounted yet.
(3) More than one cache can be used at once. Caches can be selected explicitly by use of tags.
(4) The netfs is provided with an interface that allows either party to withdraw caching facilities from a file (required for (1)).
(5) A netfs may annotate cache objects that belongs to it.
(6) Cache objects can be pinned and reservations made.
(7) The interface to the netfs returns as few errors as possible, preferring rather to let the netfs remain oblivious.
(8) Cookies are used to represent indices, files and other objects to the netfs. The simplest cookie is just a NULL pointer - indicating nothing cached there.
(9) The netfs is allowed to propose - dynamically - any index hierarchy it desires, though it must be aware that the index search function is recursive, stack space is limited, and indices can only be children of indices.
(10) Indices can be used to group files together to reduce key size and to make group invalidation easier. The use of indices may make lookup quicker, but that's cache dependent.
(11) Data I/O is effectively done directly to and from the netfs's pages. The netfs indicates that page A is at index B of the data-file represented by cookie C, and that it should be read or written. The cache backend may or may not start I/O on that page, but if it does, a netfs callback will be invoked to indicate completion. The I/O may be either synchronous or asynchronous.
(12) Cookies can be "retired" upon release. At this point FS-Cache will mark them as obsolete and the index hierarchy rooted at that point will get recycled.
(13) The netfs provides a "match" function for index searches. In addition to saying whether a match was made or not, this can also specify that an entry should be updated or deleted.
FS-Cache maintains a virtual indexing tree in which all indices, files, objects and pages are kept. Bits of this tree may actually reside in one or more caches.
FSDEF
|
+------------------------------------+
| |
NFS AFS
| |
+--------------------------+ +-----------+
| | | |
homedir mirror afs.org redhat.com
| | |
+------------+ +---------------+ +----------+
| | | | | |
00001 00002 00007 00125 vol00001 vol00002
| | | | |
+---+---+ +-----+ +---+ +------+------+ +-----+----+
| | | | | | | | | | | | |
PG0 PG1 PG2 PG0 XATTR PG0 PG1 DIRENT DIRENT DIRENT R/W R/O Bak
| |
PG0 +-------+
| |
00001 00003
|
+---+---+
| | |
PG0 PG1 PG2In the example above, you can see two netfs's being backed: NFS and AFS. These have different index hierarchies:
(*) The NFS primary index will probably contain per-server indices. Each
server index is indexed by NFS file handles to get data file objects. Each data file objects can have an array of pages, but may also have further child objects, such as extended attributes and directory entries. Extended attribute objects themselves have page-array contents.
(*) The AFS primary index contains per-cell indices. Each cell index contains
per-logical-volume indices. Each of volume index contains up to three indices for the read-write, read-only and backup mirrors of those volumes. Each of these contains vnode data file objects, each of which contains an array of pages.
The very top index is the FS-Cache master index in which individual netfs's have entries.
Any index object may reside in more than one cache, provided it only has index children. Any index with non-index object children will be assumed to only reside in one cache.
The FS-Cache overview can be found in:
Documentation/filesystems/caching/fscache.txt
The netfs API to FS-Cache can be found in:
Documentation/filesystems/caching/netfs-api.txt
The cache backend API to FS-Cache can be found in:
Documentation/filesystems/caching/backend-api.txt
---
Documentation/filesystems/caching/backend-api.txt | 345 +++++++ Documentation/filesystems/caching/fscache.txt | 151 +++ Documentation/filesystems/caching/netfs-api.txt | 726 ++++++++++++++ fs/Kconfig | 15 fs/Makefile | 1 fs/fscache/Makefile | 11 fs/fscache/cookie.c | 1063 +++++++++++++++++++++ fs/fscache/fscache-int.h | 93 ++ fs/fscache/fsdef.c | 113 ++ fs/fscache/main.c | 105 ++ fs/fscache/page.c | 548 +++++++++++ include/linux/fscache-cache.h | 226 ++++ include/linux/fscache.h | 486 ++++++++++ 13 files changed, 3883 insertions(+), 0 deletions(-)
Documentation/filesystems/caching/backend-api.txt new file +345 -0
@@ -0,0 +1,345 @@ + ========================== + FS-CACHE CACHE BACKEND API + ========================== + +The FS-Cache system provides an API by which actual caches can be supplied to +FS-Cache for it to then serve out to network filesystems and other interested +parties. + +This API is declared in <linux/fscache-cache.h>. + + +==================================== +INITIALISING AND REGISTERING A CACHE +==================================== + +To start off, a cache definition must be initialised and registered for each +cache the backend wants to make available. For instance, CacheFS does this in +the fill_super() operation on mounting. + +The cache definition (struct fscache_cache) should be initialised by calling: + + void fscache_init_cache(struct fscache_cache *cache, + struct fscache_cache_ops *ops, + const char *idfmt, + ...) + +Where: + + (*) "cache" is a pointer to the cache definition; + + (*) "ops" is a pointer to the table of operations that the backend supports on + this cache; + + (*) and a format and printf-style arguments for constructing a label for the + cache. + + +The cache should then be registered with FS-Cache by passing a pointer to the +previously initialised cache definition to: + + int fscache_add_cache(struct fscache_cache *cache, + struct fscache_object *fsdef, + const char *tagname); + +Two extra arguments should also be supplied: + + (*) "fsdef" which should point to the object representation for the FS-Cache + master index in this cache. Netfs primary index entries will be created + here. + + (*) "tagname" which, if given, should be a text string naming this cache. If + this is NULL, the identifier will be used instead. For CacheFS, the + identifier is set to name the underlying block device and the tag can be + supplied by mount. + +This function may return -ENOMEM if it ran out of memory or -EEXIST if the tag +is already in use. 0 will be returned on success. + + +===================== +UNREGISTERING A CACHE +===================== + +A cache can be withdrawn from the system by calling this function with a +pointer to the cache definition: + + void fscache_withdraw_cache(struct fscache_cache *cache) + +In CacheFS's case, this is called by put_super(). + + +================== +FS-CACHE UTILITIES +================== + +FS-Cache provides some utilities that a cache backend may make use of: + + (*) Find the parent of an object: + + struct fscache_object * + fscache_find_parent_object(struct fscache_object *object) + + This allows a backend to find the logical parent of an index or data file + in the cache hierarchy. + + (*) Note occurrence of an I/O error in a cache: + + void fscache_io_error(struct fscache_cache *cache) + + This tells FS-Cache that an I/O error occurred in the cache. After this + has been called, only resource dissociation operations (object and page + release) will be passed from the netfs to the cache backend for the + specified cache. + + This does not actually withdraw the cache. That must be done separately. + + +======================== +RELEVANT DATA STRUCTURES +======================== + + (*) Index/Data file FS-Cache representation cookie: + + struct fscache_cookie { + struct fscache_object_def *def; + struct fscache_netfs *netfs; + void *netfs_data; + ... + }; + + The fields that might be of use to the backend describe the object + definition, the netfs definition and the netfs's data for this cookie. + The object definition contain functions supplied by the netfs for loading + and matching index entries; these are required to provide some of the + cache operations. + + (*) In-cache object representation: + + struct fscache_object { + struct fscache_cache *cache; + struct fscache_cookie *cookie; + unsigned long flags; + #define FSCACHE_OBJECT_RECYCLING 1 + ... + }; + + Structures of this type should be allocated by the cache backend and + passed to FS-Cache when requested by the appropriate cache operation. In + the case of CacheFS, they're embedded in CacheFS's internal object + structures. + + Each object contains a pointer to the cookie that represents the object it + is backing. It also contains a flag that indicates whether the object is + being retired when put_object() is called. This should be initialised by + calling fscache_object_init(object). + + +================ +CACHE OPERATIONS +================ + +The cache backend provides FS-Cache with a table of operations that can be +performed on the denizens of the cache. These are held in a structure of type: + + struct fscache_cache_ops + + (*) Name of cache provider [mandatory]: + + const char *name + + This isn't strictly an operation, but should be pointed at a string naming + the backend. + + (*) Object lookup [mandatory]: + + struct fscache_object *(*lookup_object)(struct fscache_cache *cache, + struct fscache_object *parent, + struct fscache_cookie *cookie) + + This method is used to look up an object in the specified cache, given a + pointer to the parent object and the cookie to which the object will be + attached. This should instantiate that object in the cache if it can, or + return -ENOBUFS or -ENOMEM if it can't. + + (*) Increment object refcount [mandatory]: + + struct fscache_object *(*grab_object)(struct fscache_object *object) + + This method is called to increment the reference count on an object. It + may fail (for instance if the cache is being withdrawn) by returning NULL. + It should return the object pointer if successful. + + (*) Lock/Unlock object [mandatory]: + + void (*lock_object)(struct fscache_object *object) + void (*unlock_object)(struct fscache_object *object) + + These methods are used to exclusively lock an object. It must be possible + to schedule with the lock held, so a spinlock isn't sufficient. + + (*) Pin/Unpin object [optional]: + + int (*pin_object)(struct fscache_object *object) + void (*unpin_object)(struct fscache_object *object) + + These methods are used to pin an object into the cache. Once pinned an + object cannot be reclaimed to make space. Return -ENOSPC if there's not + enough space in the cache to permit this. + + (*) Update object [mandatory]: + + int (*update_object)(struct fscache_object *object) + + This is called to update the index entry for the specified object. The + new information should be in object->cookie->netfs_data. This can be + obtained by calling object->cookie->def->get_aux()/get_attr(). + + (*) Release object reference [mandatory]: + + void (*put_object)(struct fscache_object *object) + + This method is used to discard a reference to an object. The object may + be destroyed when all the references held by FS-Cache are released. + + (*) Synchronise a cache [mandatory]: + + void (*sync)(struct fscache_cache *cache) + + This is called to ask the backend to synchronise a cache with its backing + device. + + (*) Dissociate a cache [mandatory]: + + void (*dissociate_pages)(struct fscache_cache *cache) + + This is called to ask a cache to perform any page dissociations as part of + cache withdrawal. + + (*) Set the data size on a cache file [mandatory]: + + int (*set_i_size)(struct fscache_object *object, loff_t i_size); + + This is called to indicate to the cache the maximum size a file may reach. + The cache may use this to reserve space on the cache. It may also return + -ENOBUFS to indicate that insufficient space is available to expand the + metadata used to track the data. It should return 0 if successful or + -ENOMEM or -EIO on error. + + (*) Reserve cache space for an object's data [optional]: + + int (*reserve_space)(struct fscache_object *object, loff_t size); + + This is called to request that cache space be reserved to hold the data + for an object and the metadata used to track it. Zero size should be + taken as request to cancel a reservation. + + This should return 0 if successful, -ENOSPC if there isn't enough space + available, or -ENOMEM or -EIO on other errors. + + The reservation may exceed the size of the object, thus permitting future + expansion. If the amount of space consumed by an object would exceed the + reservation, it's permitted to refuse requests to allocate pages, but not + required. An object may be pruned down to its reservation size if larger + than that already. + + (*) Request page be read from cache [mandatory]: + + int (*read_or_alloc_page)(struct fscache_object *object, + struct page *page, + fscache_rw_complete_t end_io_func, + void *end_io_data, + gfp_t gfp) + + This is called to attempt to read a netfs page from the cache, or to + reserve a backing block if not. FS-Cache will have done as much checking + as it can before calling, but most of the work belongs to the backend. + + If there's no page in the cache, then -ENODATA should be returned if the + backend managed to reserve a backing block; -ENOBUFS, -ENOMEM or -EIO if + it didn't. + + If there is a page in the cache, then a read operation should be queued + and 0 returned. When the read finishes, end_io_func() should be called + with the following arguments: + + (*end_io_func)(object->cookie->netfs_data, + page, + end_io_data, + error); + + The mark_pages_cached() cookie operation should be called for the page if + any cache metadata is retained. This will indicate to the netfs that the + page needs explicit uncaching. This operation takes a pagevec, thus + allowing several pages to be marked at once. + + (*) Request pages be read from cache [mandatory]: + + int (*read_or_alloc_pages)(struct fscache_object *object, + struct address_space *mapping, + struct list_head *pages, + unsigned *nr_pages, + fscache_rw_complete_t end_io_func, + void *end_io_data, + gfp_t gfp) + + This is like the previous operation, except it will be handed a list of + pages instead of one page. Any pages on which a read operation is started + must be added to the page cache for the specified mapping and also to the + LRU. Such pages must also be removed from the pages list and nr_pages + decremented per page. + + If there was an error such as -ENOMEM, then that should be returned; else + if one or more pages couldn't be read or allocated, then -ENOBUFS should + be returned; else if one or more pages couldn't be read, then -ENODATA + should be returned. If all the pages are dispatched then 0 should be + returned. + + (*) Request page be allocated in the cache [mandatory]: + + int (*allocate_page)(struct fscache_object *object, + struct page *page, + gfp_t gfp) + + This is like read_or_alloc_page(), except that it shouldn't read from the + cache, even if there's data there that could be retrieved. It should, + however, set up any internal metadata required such that write_page() can + write to the cache. + + If there's no backing block available, then -ENOBUFS should be returned + (or -ENOMEM or -EIO if there were other problems). If a block is + successfully allocated, then the netfs page should be marked and 0 + returned. + + (*) Request page be written to cache [mandatory]: + + int (*write_page)(struct fscache_object *object, + struct page *page, + fscache_rw_complete_t end_io_func, + void *end_io_data, + gfp_t gfp) + + This is called to write from a page on which there was a previously + successful read_or_alloc_page() call. FS-Cache filters out pages that + don't have mappings. + + If there's no backing block available, then -ENOBUFS should be returned + (or -ENOMEM or -EIO if there were other problems). + + If the write operation could be queued, then 0 should be returned. When + the write completes, end_io_func() should be called with the following + arguments: + + (*end_io_func)(object->cookie->netfs_data, + page, + end_io_data, + error); + + (*) Discard retained per-page metadata [mandatory]: + + void (*uncache_pages)(struct fscache_object *object, + struct pagevec *pagevec) + + This is called when one or more netfs pages are being evicted from the + pagecache. The cache backend should tear down any internal representation + or tracking it maintains.
Documentation/filesystems/caching/fscache.txt new file +151 -0
151 lines not on this page · raw message
Documentation/filesystems/caching/netfs-api.txt new file +726 -0
726 lines not on this page · raw message
fs/Kconfig +15 -0
@@ -508,6 +508,21 @@ config FUSE_FS If you want to develop a userspace FS, or if you want to use a filesystem based on FUSE, answer Y or M. +menu "Caches" + +config FSCACHE + tristate "General filesystem cache manager" + depends on EXPERIMENTAL + help + This option enables a generic filesystem caching manager that can be + used by various network and other filesystems to cache data + locally. Different sorts of caches can be plugged in, depending on the + resources available. + + See Documentation/filesystems/caching/fscache.txt for more information. + +endmenu + menu "CD-ROM/DVD Filesystems" config ISO9660_FS
fs/Makefile +1 -0
@@ -50,6 +50,7 @@ obj-y += devpts/ obj-$(CONFIG_PROFILING) += dcookies.o # Do not add any filesystems before this line +obj-$(CONFIG_FSCACHE) += fscache/ obj-$(CONFIG_REISERFS_FS) += reiserfs/ obj-$(CONFIG_EXT3_FS) += ext3/ # Before ext2 so root fs can be ext3 obj-$(CONFIG_JBD) += jbd/
fs/fscache/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# +# Makefile for general filesystem caching code +# + +fscache-objs := \ + cookie.o \ + fsdef.o \ + main.o \ + page.o + +obj-$(CONFIG_FSCACHE) := fscache.o
fs/fscache/cookie.c new file +1063 -0
1,063 lines not on this page · raw message
fs/fscache/fscache-int.h new file +93 -0
93 lines not on this page · raw message
fs/fscache/fsdef.c new file +113 -0
113 lines not on this page · raw message
fs/fscache/main.c new file +105 -0
105 lines not on this page · raw message
fs/fscache/page.c new file +548 -0
365 lines not on this page · raw message
include/linux/fscache-cache.h new file +226 -0
226 lines not on this page · raw message
include/linux/fscache.h new file +486 -0
486 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
David Howells
maintainerPATCH 11/14 FS-Cache: Release page->private in failed readahead [try #10]
In reply to David HowellsThe attached patch causes read_cache_pages() to release page-private data on a page for which add_to_page_cache() fails or the filler function fails. This permits pages with caching references associated with them to be cleaned up.
Further changes [try #9] that have been made:
(*) The try_to_release_page() is called instead of calling the releasepage()
op directly.
(*) The page is locked before try_to_release_page() is called.
(*) The call to try_to_release_page() and page_cache_release() have been
abstracted out into a helper function as this bit of code occurs twice..
Further changes [try #10] that have been made:
(*) The comment header on the helper function is much expanded. This states
why there's a need to call the releasepage() op in the event of an error.
(*) BUG() if the page is already locked when we try and lock it.
(*) Don't set the page mapping pointer until we've locked the page.
(*) The page is unlocked after try_to_release_page() is called.
---
mm/readahead.c | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-)
mm/readahead.c +23 -2
@@ -14,6 +14,7 @@ #include <linux/module.h>#include <linux/blkdev.h> #include <linux/backing-dev.h> #include <linux/pagevec.h> +#include <linux/buffer_head.h> void default_unplug_io_fn (struct backing_dev_info *bdi,struct page *page) {
@@ -117,6 +118,26 @@ static inline unsigned long get_next_ra_#define list_to_page (head) (list_entry((head)->prev, struct page, lru)) +/* +* see if a page needs releasing upon read_cache_pages() failure +* - the caller of read_cache_pages() may have set PG_private before calling, +* such as the NFS fs marking pages that are cached locally on disk, thus we +* need to give the fs a chance to clean up in the event of an error +*/ +static inline void read_cache_pages_release_page (struct address_space *mapping, +struct page *page) +{ +if (PagePrivate (page)) { +if (TestSetPageLocked (page)) +BUG (); + page->mapping = mapping; +try_to_release_page (page,GFP_KERNEL ); + page->mapping =NULL ; +unlock_page (page); + } +page_cache_release (page); +} +/** * read_cache_pages - populate an address space with some pages, and * start reads against them.
@@ -141,7 +162,7 @@ int read_cache_pages(struct address_spac page =list_to_page (pages);list_del (&page->lru);if (add_to_page_cache (page, mapping, page->index,GFP_KERNEL )) { -page_cache_release (page); +read_cache_pages_release_page (mapping, page);continue ; } ret =filler (data, page);
@@ -153,7 +174,7 @@ int read_cache_pages(struct address_spac victim =list_to_page (pages);list_del (&victim->lru); -page_cache_release (victim); +read_cache_pages_release_page (mapping, victim); }break ; }
David Howells
maintainerPATCH 12/14 FS-Cache: Make kAFS use FS-Cache [try #10]
In reply to David HowellsThe attached patch makes the kAFS filesystem in fs/afs/ use FS-Cache, and through it any attached caches. The kAFS filesystem will use caching automatically if it's available.
---
fs/Kconfig | 7 + fs/afs/cache.h | 27 ------ fs/afs/cell.c | 109 ++++++++++++++--------- fs/afs/cell.h | 16 +-- fs/afs/cmservice.c | 2 fs/afs/dir.c | 10 +- fs/afs/file.c | 237 +++++++++++++++++++++++++++++++++----------------- fs/afs/fsclient.c | 4 + fs/afs/inode.c | 43 ++++++--- fs/afs/internal.h | 24 ++--- fs/afs/main.c | 24 ++--- fs/afs/mntpt.c | 12 +-- fs/afs/proc.c | 1 fs/afs/server.c | 3 - fs/afs/vlocation.c | 179 +++++++++++++++++++++++--------------- fs/afs/vnode.c | 248 +++++++++++++++++++++++++++++++++++++++++++--------- fs/afs/vnode.h | 10 +- fs/afs/volume.c | 78 ++++++---------- fs/afs/volume.h | 28 +----- 19 files changed, 654 insertions(+), 408 deletions(-)
fs/Kconfig +7 -0
@@ -1816,6 +1816,13 @@ # for fs/nls/Config.in If unsure, say N. +config AFS_FSCACHE + bool "Provide AFS client caching support" + depends on AFS_FS && FSCACHE && EXPERIMENTAL + help + Say Y here if you want AFS data to be cached locally on through the + generic filesystem cache manager + config RXRPC tristate
fs/afs/cache.h deleted +0 -27
@@ -1,27 +0,0 @@ -/* cache.h: AFS local cache management interface -* -* Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. -* Written by David Howells ([email protected]) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version -* 2 of the License, or (at your option) any later version. -*/ - -#ifndef _LINUX_AFS_CACHE_H -#define _LINUX_AFS_CACHE_H - -#undef AFS_CACHING_SUPPORT - -#include <linux/mm.h> -#ifdef AFS_CACHING_SUPPORT -#include <linux/cachefs.h> -#endif -#include "types.h" - -#ifdef __KERNEL__ - -#endif /* __KERNEL__ */ - -#endif /* _LINUX_AFS_CACHE_H */
fs/afs/cell.c +65 -44
146 lines not on this page · raw message
fs/afs/cell.h +3 -13
@@ -13,7 +13,7 @@ #ifndef _LINUX_AFS_CELL_H#define _LINUX_AFS_CELL_H#include "types.h" -#include "cache.h" +#include <linux/fscache.h> #define AFS_CELL_MAX_ADDRS 15
@@ -21,16 +21,6 @@ extern volatile int afs_cells_being_purg/*****************************************************************************/ /* -* entry in the cached cell catalogue -*/ -struct afs_cache_cell -{ -char name[64 ];/* cell name (padded with NULs) */ -struct in_addr vl_servers[15 ];/* cached cell VL servers */ -}; - -/*****************************************************************************/ -/* * AFS cell record */ struct afs_cell
@@ -39,8 +29,8 @@ struct afs_cellstruct list_head link;/* main cell list link */ struct list_head proc_link;/* /proc cell list link */ struct proc_dir_entry *proc_dir;/* /proc dir for this cell */ -#ifdef AFS_CACHING_SUPPORT -struct cachefs_cookie *cache;/* caching cookie */ +#ifdef CONFIG_AFS_FSCACHE +struct fscache_cookie *cache;/* caching cookie */ #endif /* server record management */
fs/afs/cmservice.c +1 -1
@@ -24,7 +24,7 @@ #include "cmservice.h"#include "internal.h" static unsigned afscm_usage;/* AFS cache manager usage count */ -static struct rw_semaphore afscm_sem;/* AFS cache manager start/stop semaphore */ +static DECLARE_RWSEM (afscm_sem);/* AFS cache manager start/stop semaphore */ static int afscm_new_call (struct rxrpc_call *call);static void afscm_attention (struct rxrpc_call *call);
fs/afs/dir.c +6 -4
@@ -145,7 +145,7 @@ #endif qty /=sizeof (union afs_dir_block );/* check them */ - dbuf =page_address (page); + dbuf =kmap_atomic (page,KM_USER0 );for (tmp =0 ; tmp < qty; tmp++) {if (dbuf->blocks[tmp].pagehdr.magic !=AFS_DIR_MAGIC ) { printk("kAFS: %s(%lu): bad magic %d/%d is %04hx\n",
@@ -154,10 +154,12 @@ #endif goto error; } } +kunmap_atomic (dbuf,KM_USER0 );return ; error: +kunmap_atomic (dbuf,KM_USER0 );SetPageError (page); }/* end afs_dir_check_page() */
@@ -168,7 +170,6 @@ #endif*/ static inline void afs_dir_put_page (struct page *page) { -kunmap (page);page_cache_release (page); }/* end afs_dir_put_page() */
@@ -188,7 +189,6 @@ static struct page *afs_dir_get_page(str NULL);if (!IS_ERR (page)) {wait_on_page_locked (page); -kmap (page);if (!PageUptodate (page)) goto fail;afs_dir_check_page (dir, page);
@@ -356,7 +356,7 @@ static int afs_dir_iterate(struct inode limit = blkoff & ~(PAGE_SIZE -1 ); - dbuf =page_address (page); + dbuf =kmap_atomic (page,KM_USER0 );/* deal with the individual blocks stashed on this page */ do {
@@ -365,6 +365,7 @@ static int afs_dir_iterate(struct inode ret =afs_dir_iterate_block (fpos, dblock, blkoff, cookie, filldir);if (ret !=1 ) { +kunmap_atomic (dbuf,KM_USER0 );afs_dir_put_page (page); goto out; }
@@ -373,6 +374,7 @@ static int afs_dir_iterate(struct inode }while (*fpos < dir->i_size && blkoff < limit); +kunmap_atomic (dbuf,KM_USER0 );afs_dir_put_page (page); ret =0 ; }
fs/afs/file.c +158 -79
374 lines not on this page · raw message
fs/afs/fsclient.c +3 -1
@@ -398,6 +398,8 @@ int afs_rxfs_fetch_file_status(struct af bp++;/* spare6 */ } +_debug ("Data Version %llx\n" , vnode->status.version); +/* success */ ret =0 ;
@@ -408,7 +410,7 @@ int afs_rxfs_fetch_file_status(struct af out_put_conn:afs_server_release_callslot (server, &callslot); out: -_leave ("" ); +_leave (" = %d" , ret);return ret; abort:
fs/afs/inode.c +30 -13
83 lines not on this page · raw message
fs/afs/internal.h +9 -15
@@ -16,15 +16,17 @@ #include <linux/compiler.h>#include <linux/kernel.h> #include <linux/fs.h> #include <linux/pagemap.h> +#include <linux/fscache.h> /* * debug tracing */ -#define kenter(FMT, a...) printk("==> %s("FMT")\n",__FUNCTION__ , ## a) -#define kleave(FMT, a...) printk("<== %s()"FMT"\n",__FUNCTION__ , ## a) -#define kdebug(FMT, a...) printk(FMT"\n" , ## a) -#define kproto(FMT, a...) printk("### "FMT"\n" , ## a) -#define knet(FMT, a...) printk(FMT"\n" , ## a) +#define __kdbg(FMT, a...) printk("[%05d] "FMT"\n", current->pid , ## a) +#define kenter(FMT, a...) __kdbg("==> %s("FMT")", __FUNCTION__ , ## a) +#define kleave(FMT, a...) __kdbg("<== %s()"FMT, __FUNCTION__ , ## a) +#define kdebug(FMT, a...) __kdbg(FMT , ## a) +#define kproto(FMT, a...) __kdbg("### "FMT , ## a) +#define knet(FMT, a...) __kdbg(FMT , ## a)#ifdef __KDEBUG #define _enter(FMT, a...) kenter(FMT , ## a)
@@ -56,9 +58,6 @@ static inline void afs_discard_my_signal*/ extern struct rw_semaphore afs_proc_cells_sem;extern struct list_head afs_proc_cells; -#ifdef AFS_CACHING_SUPPORT -extern struct cachefs_index_def afs_cache_cell_index_def; -#endif /* * dir.c
@@ -72,11 +71,6 @@ extern const struct file_operations afs_extern struct address_space_operations afs_fs_aops;extern struct inode_operations afs_file_inode_operations; -#ifdef AFS_CACHING_SUPPORT -extern int afs_cache_get_page_cookie (struct page *page, -struct cachefs_page **_page_cookie); -#endif -/* * inode.c */
@@ -97,8 +91,8 @@ #endif/* * main.c */ -#ifdef AFS_CACHING_SUPPORT -extern struct cachefs_netfs afs_cache_netfs; +#ifdef CONFIG_AFS_FSCACHE +extern struct fscache_netfs afs_cache_netfs;#endif /*
fs/afs/main.c +11 -13
@@ -1,6 +1,6 @@/* main.c: AFS client file system * -* Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. +* Copyright (C) 2002,5 Red Hat, Inc. All Rights Reserved. * Written by David Howells ([email protected]) * * This program is free software; you can redistribute it and/or
@@ -14,11 +14,11 @@ #include <linux/moduleparam.h>#include <linux/init.h> #include <linux/sched.h> #include <linux/completion.h> +#include <linux/fscache.h> #include <rxrpc/rxrpc.h> #include <rxrpc/transport.h> #include <rxrpc/call.h> #include <rxrpc/peer.h> -#include "cache.h" #include "cell.h" #include "server.h" #include "fsclient.h"
@@ -51,12 +51,11 @@ static struct rxrpc_peer_ops afs_peer_opstruct list_head afs_cb_hash_tbl[AFS_CB_HASH_COUNT ];DEFINE_SPINLOCK (afs_cb_hash_lock); -#ifdef AFS_CACHING_SUPPORT -static struct cachefs_netfs_operations afs_cache_ops = { - .get_page_cookie = afs_cache_get_page_cookie, +#ifdef CONFIG_AFS_FSCACHE +static struct fscache_netfs_operations afs_cache_ops = { }; -struct cachefs_netfs afs_cache_netfs = { +struct fscache_netfs afs_cache_netfs = { .name ="afs" , .version =0 , .ops = &afs_cache_ops,
@@ -83,10 +82,9 @@ static int __init afs_init(void)if (ret <0 )return ret; -#ifdef AFS_CACHING_SUPPORT +#ifdef CONFIG_AFS_FSCACHE /* we want to be able to cache */ - ret =cachefs_register_netfs (&afs_cache_netfs, - &afs_cache_cell_index_def); + ret =fscache_register_netfs (&afs_cache_netfs);if (ret <0 ) goto error;#endif
@@ -137,8 +135,8 @@ #ifdef CONFIG_KEYS_TURNED_OFFafs_key_unregister (); error_cache:#endif -#ifdef AFS_CACHING_SUPPORT -cachefs_unregister_netfs (&afs_cache_netfs); +#ifdef CONFIG_AFS_FSCACHE +fscache_unregister_netfs (&afs_cache_netfs); error:#endif afs_cell_purge ();
@@ -167,8 +165,8 @@ static void __exit afs_exit(void)#ifdef CONFIG_KEYS_TURNED_OFF afs_key_unregister ();#endif -#ifdef AFS_CACHING_SUPPORT -cachefs_unregister_netfs (&afs_cache_netfs); +#ifdef CONFIG_AFS_FSCACHE +fscache_unregister_netfs (&afs_cache_netfs);#endif afs_proc_cleanup ();
fs/afs/mntpt.c +6 -6
@@ -82,7 +82,7 @@ int afs_mntpt_check_symlink(struct afs_v ret = -EIO ;wait_on_page_locked (page); - buf =kmap (page); + buf =kmap_atomic (page,KM_USER0 );if (!PageUptodate (page)) goto out_free;if (PageError (page))
@@ -105,7 +105,7 @@ int afs_mntpt_check_symlink(struct afs_v ret =0 ; out_free: -kunmap (page); +kunmap_atomic (buf,KM_USER0 );page_cache_release (page); out:_leave (" = %d" , ret);
@@ -195,9 +195,9 @@ static struct vfsmount *afs_mntpt_do_autif (!PageUptodate (page) ||PageError (page)) goto error; - buf =kmap (page); + buf =kmap_atomic (page,KM_USER0 );memcpy (devname, buf, size); -kunmap (page); +kunmap_atomic (buf,KM_USER0 );page_cache_release (page); page =NULL ;
@@ -276,12 +276,12 @@ static void *afs_mntpt_follow_link(struc*/ static void afs_mntpt_expiry_timed_out (struct afs_timer *timer) { -kenter ("" ); +// kenter(""); mark_mounts_for_expiry (&afs_vfsmounts);afs_kafstimod_add_timer (&afs_mntpt_expiry_timer, afs_mntpt_expiry_timeout *HZ ); -kleave ("" ); +// kleave(""); }/* end afs_mntpt_expiry_timed_out() */
fs/afs/proc.c +1 -0
@@ -177,6 +177,7 @@ int afs_proc_init(void)*/ void afs_proc_cleanup (void ) { +remove_proc_entry ("rootcell" , proc_afs);remove_proc_entry ("cells" , proc_afs);remove_proc_entry ("fs/afs" ,NULL );
fs/afs/server.c +1 -2
@@ -377,7 +377,6 @@ int afs_server_request_callslot(struct aelse if (list_empty (&server->fs_callq)) {/* no one waiting */ server->fs_conn_cnt[nconn]++; -spin_unlock (&server->fs_lock); }else {/* someone's waiting - dequeue them and wake them up */
@@ -395,9 +394,9 @@ int afs_server_request_callslot(struct a } pcallslot->ready =1 ;wake_up_process (pcallslot->task); -spin_unlock (&server->fs_lock); } +spin_unlock (&server->fs_lock);rxrpc_put_connection (callslot->conn); callslot->conn =NULL ;
fs/afs/vlocation.c +110 -69
237 lines not on this page · raw message
fs/afs/vnode.c +204 -44
287 lines not on this page · raw message
fs/afs/vnode.h +5 -5
@@ -13,9 +13,9 @@ #ifndef _LINUX_AFS_VNODE_H#define _LINUX_AFS_VNODE_H#include <linux/fs.h> +#include <linux/fscache.h> #include "server.h" #include "kafstimod.h" -#include "cache.h" #ifdef __KERNEL__
@@ -32,8 +32,8 @@ struct afs_cache_vnodeafs_dataversion_t data_version;/* data version */ }; -#ifdef AFS_CACHING_SUPPORT -extern struct cachefs_index_def afs_vnode_cache_index_def; +#ifdef CONFIG_AFS_FSCACHE +extern struct fscache_cookie_def afs_vnode_cache_index_def;#endif /*****************************************************************************/
@@ -47,8 +47,8 @@ struct afs_vnodestruct afs_volume *volume;/* volume on which vnode resides */ struct afs_fid fid;/* the file identifier for this inode */ struct afs_file_status status;/* AFS status info for this file */ -#ifdef AFS_CACHING_SUPPORT -struct cachefs_cookie *cache;/* caching cookie */ +#ifdef CONFIG_AFS_FSCACHE +struct fscache_cookie *cache;/* caching cookie */ #endif wait_queue_head_t update_waitq;/* status fetch waitqueue */
fs/afs/volume.c +29 -49
116 lines not on this page · raw message
fs/afs/volume.h +5 -23
@@ -12,11 +12,11 @@ #ifndef _LINUX_AFS_VOLUME_H #define _LINUX_AFS_VOLUME_H +#include <linux/fscache.h> #include "types.h" #include "fsclient.h" #include "kafstimod.h" #include "kafsasyncd.h" -#include "cache.h" typedef enum { AFS_VLUPD_SLEEP, /* sleeping waiting for update timer to fire */
@@ -45,24 +45,6 @@ #define AFS_VOL_VTM_BAK 0x04 /* backup vtime_t rtime;/* last retrieval time */ }; -#ifdef AFS_CACHING_SUPPORT -extern struct cachefs_index_def afs_vlocation_cache_index_def; -#endif - -/*****************************************************************************/ -/* -* volume -> vnode hash table entry -*/ -struct afs_cache_vhash -{ -afs_voltype_t vtype;/* which volume variation */ -uint8_t hash_bucket;/* which hash bucket this represents */ -} __attribute__((packed)); - -#ifdef AFS_CACHING_SUPPORT -extern struct cachefs_index_def afs_volume_cache_index_def; -#endif -/*****************************************************************************/ /* * AFS volume location record
@@ -73,8 +55,8 @@ struct afs_vlocationstruct list_head link;/* link in cell volume location list */ struct afs_timer timeout;/* decaching timer */ struct afs_cell *cell;/* cell to which volume belongs */ -#ifdef AFS_CACHING_SUPPORT -struct cachefs_cookie *cache;/* caching cookie */ +#ifdef CONFIG_AFS_FSCACHE +struct fscache_cookie *cache;/* caching cookie */ #endif struct afs_cache_vlocation vldb;/* volume information DB record */ struct afs_volume *vols[3 ];/* volume access record pointer (index by type) */
@@ -109,8 +91,8 @@ struct afs_volumeatomic_t usage;struct afs_cell *cell;/* cell to which belongs (unrefd ptr) */ struct afs_vlocation *vlocation;/* volume location */ -#ifdef AFS_CACHING_SUPPORT -struct cachefs_cookie *cache;/* caching cookie */ +#ifdef CONFIG_AFS_FSCACHE +struct fscache_cookie *cache;/* caching cookie */ #endif afs_volid_t vid;/* volume ID */ afs_voltype_t type;/* type of volume */
David Howells
maintainerPATCH 13/14 FS-Cache: CacheFiles: A cache that backs onto a mounted filesystem [try #10]
In reply to David HowellsAdd a cache backend that permits a mounted filesystem to be used as a backing store for the cache.
CacheFiles uses a userspace daemon to do some of the cache management - such as reaping stale nodes and culling. This is called cachefilesd and lives in /sbin. The source for the daemon can be downloaded from:
http://people.redhat.com/~dhowells/cachefs/cachefilesd.c
And an example configuration from:
http://people.redhat.com/~dhowells/cachefs/cachefilesd.conf
The filesystem and data integrity of the cache are only as good as those of the filesystem providing the backing services. Note that CacheFiles does not attempt to journal anything since the journalling interfaces of the various filesystems are very specific in nature.
CacheFiles creates a proc-file - "/proc/fs/cachefiles" - that is used for communication with the daemon. Only one thing may have this open at once, and whilst it is open, a cache is at least partially in existence. The daemon opens this and sends commands down it to control the cache.
CacheFiles is currently limited to a single cache.
CacheFiles attempts to maintain at least a certain percentage of free space on the filesystem, shrinking the cache by culling the objects it contains to make space if necessary - see the "Cache Culling" section. This means it can be placed on the same medium as a live set of data, and will expand to make use of spare space and automatically contract when the set of data requires more space.
============
REQUIREMENTS
============
The use of CacheFiles and its daemon requires the following features to be available in the system and in the cache filesystem:
- dnotify.
- extended attributes (xattrs).
- openat() and friends.
- bmap() support on files in the filesystem (FIBMAP ioctl).
- The use of bmap() to detect a partial page at the end of the file.
It is strongly recommended that the "dir_index" option is enabled on Ext3 filesystems being used as a cache.
=============
CONFIGURATION
=============
The cache is configured by a script in /etc/cachefilesd.conf. These commands set up cache ready for use. The following script commands are available:
(*) brun <N>%
(*) bcull <N>%
(*) bstop <N>%
Configure the culling limits. Optional. See the section on culling The defaults are 7%, 5% and 1% respectively.
(*) dir <path>
Specify the directory containing the root of the cache. Mandatory.
(*) tag <name>
Specify a tag to FS-Cache to use in distinguishing multiple caches. Optional. The default is "CacheFiles".
(*) debug <mask>
Specify a numeric bitmask to control debugging in the kernel module. Optional. The default is zero (all off).
==================
STARTING THE CACHE
==================
The cache is started by running the daemon. The daemon opens the cache proc file, configures the cache and tells it to begin caching. At that point the cache binds to fscache and the cache becomes live.
The daemon is run as follows:
/sbin/cachefilesd [-d]* [-s] [-n] [-f <configfile>]
The flags are:
(*) -d
Increase the debugging level. This can be specified multiple times and is cumulative with itself.
(*) -s
Send messages to stderr instead of syslog.
(*) -n
Don't daemonise and go into background.
(*) -f <configfile>
Use an alternative configuration file rather than the default one.
===============
THINGS TO AVOID
===============
Do not mount other things within the cache as this will cause problems. The kernel module contains its own very cut-down path walking facility that ignores mountpoints, but the daemon can't avoid them.
Do not create, rename or unlink files and directories in the cache whilst the cache is active, as this may cause the state to become uncertain.
Renaming files in the cache might make objects appear to be other objects (the filename is part of the lookup key).
Do not change or remove the extended attributes attached to cache files by the cache as this will cause the cache state management to get confused.
Do not create files or directories in the cache, lest the cache get confused or serve incorrect data.
Do not chmod files in the cache. The module creates things with minimal permissions to prevent random users being able to access them directly.
=============
CACHE CULLING
=============
The cache may need culling occasionally to make space. This involves discarding objects from the cache that have been used less recently than anything else. Culling is based on the access time of data objects. Empty directories are culled if not in use.
Cache culling is done on the basis of the percentage of blocks available in the underlying filesystem. There are three "limits":
(*) brun
If the amount of available space in the cache rises above this limit, then culling is turned off.
(*) bcull
If the amount of available space in the cache falls below this limit, then culling is started.
(*) bstop
If the amount of available space in the cache falls below this limit, then no further allocation of disk space is permitted until culling has raised the amount above this limit again.
These must be configured thusly:
0 <= bstop < bcull < brun < 100
Note that these are percentages of available space, and do _not_ appear as 100 minus the percentage displayed by the "df" program.
The userspace daemon scans the cache to build up a table of cullable objects. These are then culled in least recently used order. A new scan of the cache is started as soon as space is made in the table. Objects will be skipped if their atimes have changed or if the kernel module says it is still using them.
===============
CACHE STRUCTURE
===============
The CacheFiles module will create two directories in the directory it was given:
(*) cache/
(*) graveyard/
The active cache objects all reside in the first directory. The CacheFiles kernel module moves any retired or culled objects that it can't simply unlink to the graveyard from which the daemon will actually delete them.
The daemon uses dnotify to monitor the graveyard directory, and will delete anything that appears therein.
The module represents index objects as directories with the filename "I..." or "J...". Note that the "cache/" directory is itself a special index.
Data objects are represented as files if they have no children, or directories if they do. Their filenames all begin "D..." or "E...". If represented as a directory, data objects will have a file in the directory called "data" that actually holds the data.
Special objects are similar to data objects, except their filenames begin "S..." or "T...".
If an object has children, then it will be represented as a directory. Immediately in the representative directory are a collection of directories named for hash values of the child object keys with an '@' prepended. Into this directory, if possible, will be placed the representations of the child objects:
INDEX INDEX INDEX DATA FILES ========= ========== ================================= ================ cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400 cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...DB1ry cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...N22ry cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...FP1ry
If the key is so long that it exceeds NAME_MAX with the decorations added on to it, then it will be cut into pieces, the first few of which will be used to make a nest of directories, and the last one of which will be the objects inside the last directory. The names of the intermediate directories will have '+' prepended:
J1223/@23/+xy...z/+kl...m/Epqr
Note that keys are raw data, and not only may they exceed NAME_MAX in size, they may also contain things like '/' and NUL characters, and so they may not be suitable for turning directly into a filename.
To handle this, CacheFiles will use a suitably printable filename directly and "base-64" encode ones that aren't directly suitable. The two versions of object filenames indicate the encoding:
OBJECT TYPE PRINTABLE ENCODED =============== =============== =============== Index "I..." "J..." Data "D..." "E..." Special "S..." "T..."
Intermediate directories are always "@" or "+" as appropriate.
Each object in the cache has an extended attribute label that holds the object type ID (required to distinguish special objects) and the auxiliary data from the netfs. The latter is used to detect stale objects in the cache and update or retire them.
Note that CacheFiles will erase from the cache any file it doesn't recognise or any file of an incorrect type (such as a FIFO file or a device file).
This documentation is added by the patch to:
Documentation/filesystems/caching/cachefiles.txt
---
Documentation/filesystems/caching/cachefiles.txt | 274 +++++ fs/Kconfig | 8 fs/Makefile | 1 fs/buffer.c | 2 fs/cachefiles/Makefile | 14 fs/cachefiles/cf-bind.c | 283 +++++ fs/cachefiles/cf-interface.c | 1303 ++++++++++++++++++++++ fs/cachefiles/cf-key.c | 160 +++ fs/cachefiles/cf-main.c | 122 ++ fs/cachefiles/cf-namei.c | 837 ++++++++++++++ fs/cachefiles/cf-proc.c | 510 +++++++++ fs/cachefiles/cf-xattr.c | 299 +++++ fs/cachefiles/internal.h | 292 +++++ fs/fcntl.c | 2 fs/file_table.c | 1 include/linux/pagemap.h | 6 mm/filemap.c | 103 ++ 17 files changed, 4217 insertions(+), 0 deletions(-)
Documentation/filesystems/caching/cachefiles.txt new file +274 -0
@@ -0,0 +1,274 @@ + =============================================== + CacheFiles: CACHE ON ALREADY MOUNTED FILESYSTEM + =============================================== + +Contents: + + (*) Overview. + + (*) Requirements. + + (*) Configuration. + + (*) Starting the cache. + + (*) Things to avoid. + + +======== +OVERVIEW +======== + +CacheFiles is a caching backend that's meant to use as a cache a directory on +an already mounted filesystem of a local type (such as Ext3). + +CacheFiles uses a userspace daemon to do some of the cache management - such as +reaping stale nodes and culling. This is called cachefilesd and lives in +/sbin. + +The filesystem and data integrity of the cache are only as good as those of the +filesystem providing the backing services. Note that CacheFiles does not +attempt to journal anything since the journalling interfaces of the various +filesystems are very specific in nature. + +CacheFiles creates a proc-file - "/proc/fs/cachefiles" - that is used for +communication with the daemon. Only one thing may have this open at once, and +whilst it is open, a cache is at least partially in existence. The daemon +opens this and sends commands down it to control the cache. + +CacheFiles is currently limited to a single cache. + +CacheFiles attempts to maintain at least a certain percentage of free space on +the filesystem, shrinking the cache by culling the objects it contains to make +space if necessary - see the "Cache Culling" section. This means it can be +placed on the same medium as a live set of data, and will expand to make use of +spare space and automatically contract when the set of data requires more +space. + + +============ +REQUIREMENTS +============ + +The use of CacheFiles and its daemon requires the following features to be +available in the system and in the cache filesystem: + + - dnotify. + + - extended attributes (xattrs). + + - openat() and friends. + + - bmap() support on files in the filesystem (FIBMAP ioctl). + + - The use of bmap() to detect a partial page at the end of the file. + +It is strongly recommended that the "dir_index" option is enabled on Ext3 +filesystems being used as a cache. + + +============= +CONFIGURATION +============= + +The cache is configured by a script in /etc/cachefilesd.conf. These commands +set up cache ready for use. The following script commands are available: + + (*) brun <N>% + (*) bcull <N>% + (*) bstop <N>% + + Configure the culling limits. Optional. See the section on culling + The defaults are 7%, 5% and 1% respectively. + + (*) dir <path> + + Specify the directory containing the root of the cache. Mandatory. + + (*) tag <name> + + Specify a tag to FS-Cache to use in distinguishing multiple caches. + Optional. The default is "CacheFiles". + + (*) debug <mask> + + Specify a numeric bitmask to control debugging in the kernel module. + Optional. The default is zero (all off). + + +================== +STARTING THE CACHE +================== + +The cache is started by running the daemon. The daemon opens the cache proc +file, configures the cache and tells it to begin caching. At that point the +cache binds to fscache and the cache becomes live. + +The daemon is run as follows: + + /sbin/cachefilesd [-d]* [-s] [-n] [-f <configfile>] + +The flags are: + + (*) -d + + Increase the debugging level. This can be specified multiple times and + is cumulative with itself. + + (*) -s + + Send messages to stderr instead of syslog. + + (*) -n + + Don't daemonise and go into background. + + (*) -f <configfile> + + Use an alternative configuration file rather than the default one. + + +=============== +THINGS TO AVOID +=============== + +Do not mount other things within the cache as this will cause problems. The +kernel module contains its own very cut-down path walking facility that ignores +mountpoints, but the daemon can't avoid them. + +Do not create, rename or unlink files and directories in the cache whilst the +cache is active, as this may cause the state to become uncertain. + +Renaming files in the cache might make objects appear to be other objects (the +filename is part of the lookup key). + +Do not change or remove the extended attributes attached to cache files by the +cache as this will cause the cache state management to get confused. + +Do not create files or directories in the cache, lest the cache get confused or +serve incorrect data. + +Do not chmod files in the cache. The module creates things with minimal +permissions to prevent random users being able to access them directly. + + +============= +CACHE CULLING +============= + +The cache may need culling occasionally to make space. This involves +discarding objects from the cache that have been used less recently than +anything else. Culling is based on the access time of data objects. Empty +directories are culled if not in use. + +Cache culling is done on the basis of the percentage of blocks available in the +underlying filesystem. There are three "limits": + + (*) brun + + If the amount of available space in the cache rises above this limit, then + culling is turned off. + + (*) bcull + + If the amount of available space in the cache falls below this limit, then + culling is started. + + (*) bstop + + If the amount of available space in the cache falls below this limit, then + no further allocation of disk space is permitted until culling has raised + the amount above this limit again. + +These must be configured thusly: + + 0 <= bstop < bcull < brun < 100 + +Note that these are percentages of available space, and do _not_ appear as 100 +minus the percentage displayed by the "df" program. + +The userspace daemon scans the cache to build up a table of cullable objects. +These are then culled in least recently used order. A new scan of the cache is +started as soon as space is made in the table. Objects will be skipped if +their atimes have changed or if the kernel module says it is still using them. + + +=============== +CACHE STRUCTURE +=============== + +The CacheFiles module will create two directories in the directory it was +given: + + (*) cache/ + + (*) graveyard/ + +The active cache objects all reside in the first directory. The CacheFiles +kernel module moves any retired or culled objects that it can't simply unlink +to the graveyard from which the daemon will actually delete them. + +The daemon uses dnotify to monitor the graveyard directory, and will delete +anything that appears therein. + + +The module represents index objects as directories with the filename "I..." or +"J...". Note that the "cache/" directory is itself a special index. + +Data objects are represented as files if they have no children, or directories +if they do. Their filenames all begin "D..." or "E...". If represented as a +directory, data objects will have a file in the directory called "data" that +actually holds the data. + +Special objects are similar to data objects, except their filenames begin +"S..." or "T...". + + +If an object has children, then it will be represented as a directory. +Immediately in the representative directory are a collection of directories +named for hash values of the child object keys with an '@' prepended. Into +this directory, if possible, will be placed the representations of the child +objects: + + INDEX INDEX INDEX DATA FILES + ========= ========== ================================= ================ + cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400 + cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...DB1ry + cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...N22ry + cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...FP1ry + + +If the key is so long that it exceeds NAME_MAX with the decorations added on to +it, then it will be cut into pieces, the first few of which will be used to +make a nest of directories, and the last one of which will be the objects +inside the last directory. The names of the intermediate directories will have +'+' prepended: + + J1223/@23/+xy...z/+kl...m/Epqr + + +Note that keys are raw data, and not only may they exceed NAME_MAX in size, +they may also contain things like '/' and NUL characters, and so they may not +be suitable for turning directly into a filename. + +To handle this, CacheFiles will use a suitably printable filename directly and +"base-64" encode ones that aren't directly suitable. The two versions of +object filenames indicate the encoding: + + OBJECT TYPE PRINTABLE ENCODED + =============== =============== =============== + Index "I..." "J..." + Data "D..." "E..." + Special "S..." "T..." + +Intermediate directories are always "@" or "+" as appropriate. + + +Each object in the cache has an extended attribute label that holds the object +type ID (required to distinguish special objects) and the auxiliary data from +the netfs. The latter is used to detect stale objects in the cache and update +or retire them. + + +Note that CacheFiles will erase from the cache any file it doesn't recognise or +any file of an incorrect type (such as a FIFO file or a device file).
fs/Kconfig +8 -0
@@ -521,6 +521,14 @@ config FSCACHE See Documentation/filesystems/caching/fscache.txt for more information. +config CACHEFILES + tristate "Filesystem caching on files" + depends on FSCACHE + help + This permits use of a mounted filesystem as a cache for other + filesystems - primarily networking filesystems - thus allowing fast + local disk to enhance the speed of slower devices. + endmenu menu "CD-ROM/DVD Filesystems"
fs/Makefile +1 -0
@@ -100,6 +100,7 @@ obj-$(CONFIG_AFS_FS) += afs/ obj-$(CONFIG_BEFS_FS) += befs/ obj-$(CONFIG_HOSTFS) += hostfs/ obj-$(CONFIG_HPPFS) += hppfs/ +obj-$(CONFIG_CACHEFILES) += cachefiles/ obj-$(CONFIG_DEBUG_FS) += debugfs/ obj-$(CONFIG_CONFIGFS_FS) += configfs/ obj-$(CONFIG_OCFS2_FS) += ocfs2/
fs/buffer.c +2 -0
@@ -185,6 +185,8 @@ int fsync_super(struct super_block *sb)return sync_blockdev (sb->s_bdev); } +EXPORT_SYMBOL (fsync_super); +/* * Write out and wait upon all dirty data associated with this * device. Filesystem data as well as the underlying block
fs/cachefiles/Makefile new file +14 -0
@@ -0,0 +1,14 @@ +# +# Makefile for caching in a mounted filesystem +# + +cachefiles-objs := \ + cf-bind.o \ + cf-interface.o \ + cf-key.o \ + cf-main.o \ + cf-namei.o \ + cf-proc.o \ + cf-xattr.o + +obj-$(CONFIG_CACHEFILES) := cachefiles.o
fs/cachefiles/cf-bind.c new file +283 -0
283 lines not on this page · raw message
fs/cachefiles/cf-interface.c new file +1303 -0
1,303 lines not on this page · raw message
fs/cachefiles/cf-key.c new file +160 -0
160 lines not on this page · raw message
fs/cachefiles/cf-main.c new file +122 -0
122 lines not on this page · raw message
fs/cachefiles/cf-namei.c new file +837 -0
815 lines not on this page · raw message
fs/cachefiles/cf-proc.c new file +510 -0
510 lines not on this page · raw message
fs/cachefiles/cf-xattr.c new file +299 -0
299 lines not on this page · raw message
fs/cachefiles/internal.h new file +292 -0
292 lines not on this page · raw message
mm/filemap.c +103 -0
103 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
David Howells
maintainerPATCH 14/14 NFS: Use local caching [try #10]
In reply to David HowellsThe attached patch makes it possible for the NFS filesystem to make use of the network filesystem local caching service (FS-Cache).
To be able to use this, an updated mount program is required. This can be obtained from:
http://people.redhat.com/steved/cachefs/util-linux/
To mount an NFS filesystem to use caching, add an "fsc" option to the mount:
mount warthog:/ /a -o fsc
---
fs/Kconfig | 7 + fs/cachefiles/cf-bind.c | 2 fs/cachefiles/cf-interface.c | 2 fs/nfs/Makefile | 1 fs/nfs/client.c | 18 +++ fs/nfs/file.c | 31 +++++ fs/nfs/inode.c | 26 +++++ fs/nfs/internal.h | 10 ++ fs/nfs/nfs-fscache.c | 191 +++++++++++++++++++++++++++++++++ fs/nfs/nfs-fscache.h | 169 +++++++++++++++++++++++++++++ fs/nfs/pagelist.c | 3 - fs/nfs/read.c | 241 ++++++++++++++++++++++++++++++++++++++++++ fs/nfs/super.c | 21 ++++ fs/nfs/sysctl.c | 43 +++++++ fs/nfs/write.c | 54 +++++++++ include/linux/nfs4_mount.h | 1 include/linux/nfs_fs.h | 5 + include/linux/nfs_fs_sb.h | 5 + include/linux/nfs_mount.h | 1 19 files changed, 824 insertions(+), 7 deletions(-)
fs/Kconfig +7 -0
@@ -1424,6 +1424,13 @@ config NFS_V4 If unsure, say N. +config NFS_FSCACHE + bool "Provide NFS client caching support (EXPERIMENTAL)" + depends on NFS_FS && FSCACHE && EXPERIMENTAL + help + Say Y here if you want NFS data to be cached locally on disc through + the general filesystem cache manager + config NFS_DIRECTIO bool "Allow direct I/O on NFS files (EXPERIMENTAL)" depends on NFS_FS && EXPERIMENTAL
fs/cachefiles/cf-bind.c +1 -1
@@ -155,7 +155,7 @@ static int cachefiles_proc_add_cache(str goto error_unsupported;/* get the cache size and blocksize */ - ret = root->d_sb->s_op->statfs (cache->mnt, &stats); + ret = root->d_sb->s_op->statfs (root, &stats);if (ret <0 ) goto error_unsupported;
fs/cachefiles/cf-interface.c +1 -1
@@ -339,7 +339,7 @@ int cachefiles_has_space(struct cachefil/* find out how many pages of blockdev are available */ memset (&stats,0 ,sizeof (stats)); - ret = cache->mnt->mnt_sb->s_op->statfs (cache->mnt, &stats); + ret = cache->mnt->mnt_sb->s_op->statfs (cache->mnt->mnt_root, &stats);if (ret <0 ) {if (ret == -EIO )cachefiles_io_error (cache,"statfs failed" );
fs/nfs/Makefile +1 -0
@@ -16,4 +16,5 @@ nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4x nfs4namespace.o nfs-$(CONFIG_NFS_DIRECTIO) += direct.o nfs-$(CONFIG_SYSCTL) += sysctl.o +nfs-$(CONFIG_NFS_FSCACHE) += nfs-fscache.o nfs-objs := $(nfs-y)
fs/nfs/client.c +16 -2
@@ -42,6 +42,7 @@ #include "nfs4_fs.h"#include "callback.h" #include "delegation.h" #include "iostat.h" +#include "nfs-fscache.h" #include "internal.h" #define NFSDBG_FACILITY NFSDBG_CLIENT
@@ -182,6 +183,8 @@ #endifdprintk ("--> nfs_free_client()\n" ); +nfs_kill_fscookie (clp); +/* -EIO all pending I/O */ rpc = clp->client;if (!IS_ERR (rpc))
@@ -497,6 +500,9 @@ #endif clp->acdirmin = data->acdirmin *HZ ; clp->acdirmax = data->acdirmax *HZ ; +if (clp->flags &NFS_MOUNT_FSCACHE ) +nfs_fill_fscookie (clp); +/* Start lockd here, before we might error out */ if (!(clp->flags &NFS_MOUNT_NONLM )) { error =lockd_up ();
@@ -831,6 +837,9 @@ static int nfs4_create_client(struct nfs clp->retrans_timeo = timeparms.to_initval; clp->retrans_count = timeparms.to_retries; +if (clp->flags &NFS4_MOUNT_FSCACHE ) +nfs4_fill_fscookie (clp); +/* Start lockd here, before we might error out */ if (!(clp->flags &NFS_MOUNT_NONLM )) { error =lockd_up ();
@@ -1221,7 +1230,7 @@ static int nfs_client_list_show(struct s/* display header on line 1 */ if (v ==SEQ_START_TOKEN ) { -seq_puts (m,"NV SERVER PORT USE AUTH HOSTNAME\n" ); +seq_puts (m,"NV SERVER PORT USE AUTH FSC HOSTNAME\n" );return 0 ; }
@@ -1233,12 +1242,17 @@ static int nfs_client_list_show(struct s nfs_auth_flavours[clp->authflavour]) auth = nfs_auth_flavours[clp->authflavour]; -seq_printf (m,"v%d %02x%02x%02x%02x %4hx %3d %s %s\n" , +seq_printf (m,"v%d %02x%02x%02x%02x %4hx %3d %s %s %s\n" , clp->nfsversion,NIPQUAD (clp->addr.sin_addr),ntohs (clp->addr.sin_port),atomic_read (&clp->usage), auth, +#ifdef CONFIG_NFS_FSCACHE + clp->fscache ?"yes" :"no " , +#else +"no " , +#endif clp->hostname);return 0 ;
fs/nfs/file.c +31 -0
@@ -27,9 +27,11 @@ #include <linux/mm.h>#include <linux/slab.h> #include <linux/pagemap.h> #include <linux/smp_lock.h> +#include <linux/buffer_head.h> #include <asm/uaccess.h> #include <asm/system.h> +#include "nfs-fscache.h" #include "delegation.h" #include "iostat.h"
@@ -253,6 +255,19 @@ nfs_file_sendfile(struct file *filp, lofreturn res; } +#ifdef CONFIG_NFS_FSCACHE +static int nfs_file_page_mkwrite (struct vm_area_struct *vma,struct page *page) +{ +wait_on_page_fs_misc (page); +return 0 ; +} +static struct vm_operations_struct nfs_fs_vm_operations = { + .nopage = filemap_nopage, + .populate = filemap_populate, + .page_mkwrite = nfs_file_page_mkwrite, +}; +#endif +static int nfs_file_mmap (struct file * file,struct vm_area_struct * vma) {
@@ -266,6 +281,12 @@ nfs_file_mmap(struct file * file, struct status =nfs_revalidate_file (inode, file);if (!status) status =generic_file_mmap (file, vma); + +#ifdef CONFIG_NFS_FSCACHE +if (NFS_I (inode)->fscache !=NULL ) + vma->vm_ops = &nfs_fs_vm_operations; +#endif +return status; }
@@ -328,6 +349,11 @@ static int nfs_release_page(struct pagereturn !nfs_wb_page (page->mapping->host, page); } +/* +* since we use page->private for our own nefarious purposes when using fscache, we have to +* override extra address space ops to prevent fs/buffer.c from getting confused, even though we +* may not have asked its opinion +*/ struct address_space_operations nfs_file_aops = { .readpage = nfs_readpage, .readpages = nfs_readpages,
@@ -341,6 +367,11 @@ struct address_space_operations nfs_file#ifdef CONFIG_NFS_DIRECTIO .direct_IO = nfs_direct_IO,#endif +#ifdef CONFIG_NFS_FSCACHE + .sync_page = block_sync_page, + .releasepage = nfs_releasepage, + .invalidatepage = nfs_invalidatepage, +#endif };/*
fs/nfs/inode.c +26 -0
@@ -48,6 +48,8 @@ #include "delegation.h"#include "iostat.h" #include "internal.h" +#include "nfs-fscache.h" +#define NFSDBG_FACILITY NFSDBG_VFS#define NFS_PARANOIA 1
@@ -103,6 +105,8 @@ void nfs_clear_inode(struct inode *inode cred = nfsi->cache_access.cred;if (cred)put_rpccred (cred); + +nfs_clear_fscookie (NFS_SERVER (inode), nfsi);BUG_ON (atomic_read (&nfsi->data_updates) !=0 ); }
@@ -149,6 +153,8 @@ void nfs_zap_caches(struct inode *inode)spin_lock (&inode->i_lock);nfs_zap_caches_locked (inode);spin_unlock (&inode->i_lock); + +nfs_zap_fscookie (NFS_SERVER (inode),NFS_I (inode)); }static void nfs_zap_acl_cache (struct inode *inode)
@@ -227,6 +233,7 @@ nfs_fhget(struct super_block *sb, struct };struct inode *inode =ERR_PTR (-ENOENT );unsigned long hash; +int maycache =1 ;if ((fattr->valid &NFS_ATTR_FATTR ) ==0 ) goto out_no_inode;
@@ -275,6 +282,7 @@ nfs_fhget(struct super_block *sb, structelse inode->i_op = &nfs_mountpoint_inode_operations; inode->i_fop =NULL ; + maycache =0 ; } }else if (S_ISLNK (inode->i_mode)) inode->i_op = &nfs_symlink_inode_operations;
@@ -307,6 +315,12 @@ nfs_fhget(struct super_block *sb, structmemset (nfsi->cookieverf,0 ,sizeof (nfsi->cookieverf)); nfsi->cache_access.cred =NULL ; +#ifdef CONFIG_NFS_FSCACHE + nfsi->fscache =NULL ; +#endif +if (maycache) +nfs_fhget_fscookie (sb, nfsi); +unlock_new_inode (inode); }else nfs_refresh_inode (inode, fattr);
@@ -389,6 +403,7 @@ void nfs_setattr_update_inode(struct inoif ((attr->ia_valid &ATTR_SIZE ) !=0 ) {nfs_inc_stats (inode,NFSIOS_SETATTRTRUNC ); inode->i_size = attr->ia_size; +nfs_set_fscsize (NFS_SERVER (inode),NFS_I (inode), inode->i_size);vmtruncate (inode, attr->ia_size); } }
@@ -704,6 +719,8 @@ void nfs_revalidate_mapping(struct inode }spin_unlock (&inode->i_lock); +nfs_renew_fscookie (NFS_SERVER (inode), nfsi); +dfprintk (PAGECACHE ,"NFS: (%s/%Ld) data cache invalidated\n" , inode->i_sb->s_id, (long long )NFS_FILEID (inode));
@@ -943,11 +960,13 @@ static int nfs_update_inode(struct inodeif (data_stable) { inode->i_size = new_isize; invalid |=NFS_INO_INVALID_DATA ; +nfs_set_fscsize (NFS_SERVER (inode), nfsi, inode->i_size); } invalid |=NFS_INO_INVALID_ATTR ; }else if (new_isize > cur_isize) { inode->i_size = new_isize; invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_DATA ; +nfs_set_fscsize (NFS_SERVER (inode), nfsi, inode->i_size); } nfsi->cache_change_attribute = jiffies; dprintk("NFS: isize change on server for file %s/%ld\n",
@@ -1162,6 +1181,10 @@ static int __init init_nfs_fs(void) {int err; + err =nfs_register_fscache (); +if (err <0 ) + goto out6; + err =nfs_fs_proc_init ();if (err) goto out5;
@@ -1208,6 +1231,8 @@ out3: out4:nfs_fs_proc_exit (); out5: +nfs_unregister_fscache (); +out6:return err; }
@@ -1218,6 +1243,7 @@ static void __exit exit_nfs_fs(void)nfs_destroy_readpagecache ();nfs_destroy_inodecache ();nfs_destroy_nfspagecache (); +nfs_unregister_fscache ();#ifdef CONFIG_PROC_FS rpc_proc_unregister ("nfs" );#endif
fs/nfs/internal.h +10 -0
@@ -4,6 +4,16 @@#include <linux/mount.h> +#define NFS_PAGE_WRITING 0 + +#define PageNfsWriting (page) test_bit(NFS_PAGE_WRITING, &(page)->private) +#define SetPageNfsWriting (page) set_bit(NFS_PAGE_WRITING, &(page)->private) +#define ClearPageNfsWriting (page) clear_bit(NFS_PAGE_WRITING, &(page)->private) + +#define PageNfsCached (page) PagePrivate(page) +#define SetPageNfsCached (page) SetPagePrivate(page) +#define ClearPageNfsCached (page) ClearPagePrivate(page) +struct nfs_string ;struct nfs_mount_data ;struct nfs4_mount_data ;
fs/nfs/nfs-fscache.c new file +191 -0
191 lines not on this page · raw message
fs/nfs/nfs-fscache.h new file +169 -0
169 lines not on this page · raw message
fs/nfs/pagelist.c +2 -1
@@ -18,6 +18,7 @@ #include <linux/nfs4.h>#include <linux/nfs_page.h> #include <linux/nfs_fs.h> #include <linux/nfs_mount.h> +#include "internal.h" #define NFS_PARANOIA 1
@@ -85,7 +86,7 @@ nfs_create_request(struct nfs_open_conteatomic_set (&req->wb_complete,0 ); req->wb_index = page->index;page_cache_get (page); -BUG_ON (PagePrivate (page)); +BUG_ON (PageNfsWriting (page));BUG_ON (!PageLocked (page));BUG_ON (page->mapping->host != inode); req->wb_offset = offset;
fs/nfs/read.c +241 -0
297 lines not on this page · raw message
fs/nfs/super.c +21 -0
@@ -295,6 +295,7 @@ static void nfs_show_mount_options(struc { NFS_MOUNT_NOAC, ",noac", "" }, { NFS_MOUNT_NONLM, ",nolock", "" }, { NFS_MOUNT_NOACL, ",noacl", "" }, + { NFS_MOUNT_FSCACHE, ",fsc", "" }, { 0, NULL, NULL } };const struct proc_nfs_info *nfs_infop;
@@ -512,6 +513,16 @@ #endif /* CONFIG_NFS_V3 */memset (mntfh->data + mntfh->size,0 ,sizeof (mntfh->data) - mntfh->size); +/* if filesystem caching isn't compiled in, then requesting its use is +* invalid */ +#ifndef CONFIG_NFS_FSCACHE +if (data->flags &NFS_MOUNT_FSCACHE ) { +printk (KERN_WARNING +"NFS: kernel not compiled with CONFIG_NFS_FSCACHE\n" ); +return -EINVAL ; + } +#endif +return 0 ; }
@@ -821,6 +832,16 @@ static int nfs4_get_sb(struct file_systereturn -EINVAL ; } +/* if filesystem caching isn't compiled in, then requesting its use is +* invalid */ +#ifndef CONFIG_NFS_FSCACHE +if (data->flags &NFS_MOUNT_FSCACHE ) { +printk (KERN_WARNING +"NFS: kernel not compiled with CONFIG_NFS_FSCACHE\n" ); +return -EINVAL ; + } +#endif +/* We now require that the mount process passes the remote address */ if (data->host_addrlen !=sizeof (addr))return -EINVAL ;
fs/nfs/sysctl.c +43 -0
55 lines not on this page · raw message
fs/nfs/write.c +52 -2
90 lines not on this page · raw message
include/linux/nfs4_mount.h +1 -0
@@ -65,6 +65,7 @@ #define NFS4_MOUNT_INTR 0x0002 /* 1 */#define NFS4_MOUNT_NOCTO 0x0010/* 1 */ #define NFS4_MOUNT_NOAC 0x0020/* 1 */ #define NFS4_MOUNT_STRICTLOCK 0x1000/* 1 */ +#define NFS4_MOUNT_FSCACHE 0x4000/* 1 */ #define NFS4_MOUNT_FLAGMASK 0xFFFF#endif
include/linux/nfs_fs.h +5 -0
@@ -30,6 +30,7 @@ #include <linux/nfs_fs_sb.h>#include <linux/rwsem.h> #include <linux/mempool.h> +#include <linux/fscache.h> /* * Enable debugging support for nfs client.
@@ -180,6 +181,9 @@ #ifdef CONFIG_NFS_V4int delegation_state;struct rw_semaphore rwsem;#endif /* CONFIG_NFS_V4*/ +#ifdef CONFIG_NFS_FSCACHE +struct fscache_cookie *fscache; +#endif struct inode vfs_inode; };
@@ -579,6 +583,7 @@ #define NFSDBG_FILE 0x0040#define NFSDBG_ROOT 0x0080#define NFSDBG_CALLBACK 0x0100#define NFSDBG_CLIENT 0x0200 +#define NFSDBG_FSCACHE 0x0400#define NFSDBG_ALL 0xFFFF#ifdef __KERNEL__
include/linux/nfs_fs_sb.h +5 -0
@@ -3,6 +3,7 @@ #define _NFS_FS_SB#include <linux/list.h> #include <linux/backing-dev.h> +#include <linux/fscache.h> struct nfs_iostats ;
@@ -86,6 +87,10 @@ #ifdef CONFIG_NFS_V4*/ char ip_addr[16 ];#endif + +#ifdef CONFIG_NFS_FSCACHE +struct fscache_cookie *fscache;/* client index cache cookie */ +#endif };/*
include/linux/nfs_mount.h +1 -0
@@ -61,6 +61,7 @@ #define NFS_MOUNT_BROKEN_SUID 0x0400 /*#define NFS_MOUNT_NOACL 0x0800/* 4 */ #define NFS_MOUNT_STRICTLOCK 0x1000/* reserved for NFSv4 */ #define NFS_MOUNT_SECFLAVOUR 0x2000/* 5 */ +#define NFS_MOUNT_FSCACHE 0x4000#define NFS_MOUNT_FLAGMASK 0xFFFF#endif