* [NFS] Forcefully resetting a lock
@ 2008-04-16 9:17 Erik Hensema / HostingXS Internet Services
[not found] ` <200804161117.24734.hensema-yolSOB3tinz/D1n+0JDH9g@public.gmane.org>
0 siblings, 1 reply; 21+ messages in thread
From: Erik Hensema / HostingXS Internet Services @ 2008-04-16 9:17 UTC (permalink / raw)
To: nfs
Hi all,
Sometimes a file lock gets stuck. Is there any way on either server or
client to obtain a list of locks? Or a list of processes/clients
locking a particular file?
And the million dollar question: is it possible to forcefully remove a
lock?
I'm using NFSv4 on Linux 2.6.18 (server and client).
Met vriendelijke groet,
Erik Hensema
--
HostingXS
eXcellent Service
Telefoon: 024 - 324 91 77
E-mail: hensema-yolSOB3tinz/D1n+0JDH9g@public.gmane.org
Website: http://www.hostingxs.nl/
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
_______________________________________________
Please note that nfs@lists.sourceforge.net is being discontinued.
Please subscribe to linux-nfs@vger.kernel.org instead.
http://vger.kernel.org/vger-lists.html#linux-nfs
^ permalink raw reply [flat|nested] 21+ messages in thread[parent not found: <200804161117.24734.hensema-yolSOB3tinz/D1n+0JDH9g@public.gmane.org>]
* Re: [NFS] Forcefully resetting a lock [not found] ` <200804161117.24734.hensema-yolSOB3tinz/D1n+0JDH9g@public.gmane.org> @ 2008-04-16 11:44 ` Jeff Layton 2008-04-16 15:15 ` Wendy Cheng 1 sibling, 0 replies; 21+ messages in thread From: Jeff Layton @ 2008-04-16 11:44 UTC (permalink / raw) To: Erik Hensema / HostingXS Internet Services; +Cc: nfs On Wed, 16 Apr 2008 11:17:24 +0200 Erik Hensema / HostingXS Internet Services <hensema-yolSOB3tinz/D1n+0JDH9g@public.gmane.org> wrote: > Hi all, > > Sometimes a file lock gets stuck. Is there any way on either server or > client to obtain a list of locks? Or a list of processes/clients > locking a particular file? $ cat /proc/locks The PID field can be a little misleading there though. On the server, it'll generally show the pid of knfsd, and on the client you'll see the pid of the processes actually doing the locking. As far as I know, info about which clients have blocked locks isn't exposed. > And the million dollar question: is it possible to forcefully remove a > lock? > Hmm...with NFSv2/3, yes. You can send a SIGKILL to lockd to make it drop all of its locks. You'll need to couple that with a statd SM_NOTIFY event to make everyone recover their locks too... > I'm using NFSv4 on Linux 2.6.18 (server and client). > I don't think the same sort of trick works for NFSv4. I suppose you could probably shut down all the nfsd's on the server and bring them back up again. I've never tested that though... > Met vriendelijke groet, > > > Erik Hensema > -- > HostingXS > eXcellent Service > > Telefoon: 024 - 324 91 77 > E-mail: hensema-yolSOB3tinz/D1n+0JDH9g@public.gmane.org > Website: http://www.hostingxs.nl/ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > NFS maillist - NFS@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/nfs > _______________________________________________ > Please note that nfs@lists.sourceforge.net is being discontinued. > Please subscribe to linux-nfs@vger.kernel.org instead. > http://vger.kernel.org/vger-lists.html#linux-nfs > > -- > To unsubscribe from this list: send the line "unsubscribe linux-nfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [NFS] Forcefully resetting a lock [not found] ` <200804161117.24734.hensema-yolSOB3tinz/D1n+0JDH9g@public.gmane.org> 2008-04-16 11:44 ` Jeff Layton @ 2008-04-16 15:15 ` Wendy Cheng 2008-04-16 18:42 ` J. Bruce Fields 1 sibling, 1 reply; 21+ messages in thread From: Wendy Cheng @ 2008-04-16 15:15 UTC (permalink / raw) To: J. Bruce Fields; +Cc: nfs, Erik Hensema / HostingXS Internet Services Erik Hensema / HostingXS Internet Services wrote: > Hi all, > > Sometimes a file lock gets stuck. Is there any way on either server or > client to obtain a list of locks? Or a list of processes/clients > locking a particular file? > And the million dollar question: is it possible to forcefully remove a > lock? > > I'm using NFSv4 on Linux 2.6.18 (server and client). > > *Cough* ! Bruce, so what happens to my lock dropping patch that was said "will get pulled into 2.6.26 kernel" ? -- Wendy ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [NFS] Forcefully resetting a lock 2008-04-16 15:15 ` Wendy Cheng @ 2008-04-16 18:42 ` J. Bruce Fields 2008-04-16 19:39 ` Wendy Cheng 0 siblings, 1 reply; 21+ messages in thread From: J. Bruce Fields @ 2008-04-16 18:42 UTC (permalink / raw) To: Wendy Cheng; +Cc: nfs, Erik Hensema / HostingXS Internet Services On Wed, Apr 16, 2008 at 10:15:19AM -0500, Wendy Cheng wrote: > Erik Hensema / HostingXS Internet Services wrote: >> Hi all, >> >> Sometimes a file lock gets stuck. Is there any way on either server or >> client to obtain a list of locks? Or a list of processes/clients >> locking a particular file? >> And the million dollar question: is it possible to forcefully remove a >> lock? >> >> I'm using NFSv4 on Linux 2.6.18 (server and client). >> >> > > *Cough* ! > > Bruce, so what happens to my lock dropping patch that was said "will get > pulled into 2.6.26 kernel" ? Gulp. I started an alternative implementation, and got it to the point where it was basically working (but I didn't completely trust it). And I did a small fix or two on your patches, but I seem to recall there were one or more todo's there too. Then I dropped both for a couple weeks. I'll take a harder look this afternoon.... --b. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [NFS] Forcefully resetting a lock 2008-04-16 18:42 ` J. Bruce Fields @ 2008-04-16 19:39 ` Wendy Cheng 2008-04-17 21:52 ` J. Bruce Fields 0 siblings, 1 reply; 21+ messages in thread From: Wendy Cheng @ 2008-04-16 19:39 UTC (permalink / raw) To: J. Bruce Fields; +Cc: nfs, Erik Hensema / HostingXS Internet Services J. Bruce Fields wrote: > On Wed, Apr 16, 2008 at 10:15:19AM -0500, Wendy Cheng wrote: > >> Erik Hensema / HostingXS Internet Services wrote: >> >>> Hi all, >>> >>> Sometimes a file lock gets stuck. Is there any way on either server or >>> client to obtain a list of locks? Or a list of processes/clients >>> locking a particular file? >>> And the million dollar question: is it possible to forcefully remove a >>> lock? >>> >>> I'm using NFSv4 on Linux 2.6.18 (server and client). >>> >>> >>> >> *Cough* ! >> >> Bruce, so what happens to my lock dropping patch that was said "will get >> pulled into 2.6.26 kernel" ? >> > > Gulp. > > I started an alternative implementation, and got it to the point where > it was basically working (but I didn't completely trust it). And I did > a small fix or two on your patches, but I seem to recall there were one > or more todo's there too. > > Then I dropped both for a couple weeks. > Be carefully. .. "a couple weeks" can turn into "a couple years" .. It has been more than 2 years since my first patch submission. Regardless the patch has been repeatedly requested and had gone thru thorough testings, it just sits there idling while Linux nfs server keeps suffering the very same issue. Don't get too ambitious. Cluster issues are not trivial - please take one step at a time. The patch is very usable *and* solves an immediate issue *and* has a clean boundary with existing main-line logic. I really don't see the reason to delay it. -- Wendy > I'll take a harder look this afternoon.... > > --b. > ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [NFS] Forcefully resetting a lock 2008-04-16 19:39 ` Wendy Cheng @ 2008-04-17 21:52 ` J. Bruce Fields 2008-04-18 14:02 ` Wendy Cheng 0 siblings, 1 reply; 21+ messages in thread From: J. Bruce Fields @ 2008-04-17 21:52 UTC (permalink / raw) To: Wendy Cheng; +Cc: nfs, Erik Hensema / HostingXS Internet Services On Wed, Apr 16, 2008 at 02:39:19PM -0500, Wendy Cheng wrote: > J. Bruce Fields wrote: >> On Wed, Apr 16, 2008 at 10:15:19AM -0500, Wendy Cheng wrote: >> >>> Erik Hensema / HostingXS Internet Services wrote: >>> >>>> Hi all, >>>> >>>> Sometimes a file lock gets stuck. Is there any way on either server >>>> or client to obtain a list of locks? Or a list of >>>> processes/clients locking a particular file? >>>> And the million dollar question: is it possible to forcefully >>>> remove a lock? >>>> >>>> I'm using NFSv4 on Linux 2.6.18 (server and client). >>>> >>>> >>> *Cough* ! >>> >>> Bruce, so what happens to my lock dropping patch that was said "will >>> get pulled into 2.6.26 kernel" ? >>> >> >> Gulp. >> >> I started an alternative implementation, and got it to the point where >> it was basically working (but I didn't completely trust it). And I did >> a small fix or two on your patches, but I seem to recall there were one >> or more todo's there too. >> >> Then I dropped both for a couple weeks. >> > > Be carefully. .. "a couple weeks" can turn into "a couple years" .. It > has been more than 2 years since my first patch submission. Regardless > the patch has been repeatedly requested and had gone thru thorough > testings, it just sits there idling while Linux nfs server keeps > suffering the very same issue. Yes, apologies for not getting this done on time. > Don't get too ambitious. Cluster issues are not trivial - please take > one step at a time. The patch is very usable *and* solves an immediate > issue *and* has a clean boundary with existing main-line logic. I really > don't see the reason to delay it. My current version of your patch follows. I've rebased it a couple times (the only change I recall being required was a trivial fix to take into account reorganization of struct nameidata.). I also made two other changes; any objections to either?: - I believe the addition of f_iaddr to store the server-side ip address was not quite correct, since the struct nlm_file may be shared by multiple clients accessing the filesystem through multiple server ip's--possibly not an issue for your use case, but easily fixable, since there's already a host->h_saddr filled in for server-side nlm_host structs, which saves us the trouble of inventing a new field. - I made the unlock-by-path match filesystems on superblock, not vfs_mount: my understanding is that its purpose is to release all of the locks held by nfs which would prevent completely unmounting the given filesystem. So we should be matching on all locks for a given superblock, not just those for a single vfsmount of that superblock. Still to fix: - The write methods appear to return the number of failed unlock requests. But positive return values have a special meaning to nfsctl_transaction_write(). This looks like a bug. - The nlm_traverse_files() changes are hairy. Also still to do, though not necessarily blocks to submitting them: - Figure out how to drop locks held by nfsv4 clients as well. - Fix the ip address type. --b. commit 5f4e32d8544564c477c04009393db914145d6d5b Author: Wendy Cheng <wcheng@redhat.com> Date: Thu Jan 17 11:10:12 2008 -0500 NLM failover unlock commands Two new NFSD procfs files are added: /proc/fs/nfsd/unlock_ip /proc/fs/nfsd/unlock_filesystem They are intended to allow admin or user mode script to release NLM locks based on either a path name or a server in-bound ip address (ipv4 for now) as: shell> echo 10.1.1.2 > /proc/fs/nfsd/unlock_ip shell> echo /mnt/sfs1 > /proc/fs/nfsd/unlock_filesystem The expected sequence of events can be: 1. Tear down the IP address 2. Unexport the path 3. Write IP to /proc/fs/nfsd/unlock_ip to unlock files 4. If unmount required, write path name to /proc/fs/nfsd/unlock_filesystem, then unmount. 5. Signal peer to begin take-over. Signed-off-by: S. Wendy Cheng <wcheng@redhat.com> Signed-off-by: Lon Hohberger <lhh@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> fs/lockd/svcsubs.c | 66 +++++++++++++++++++++++++++++++++++++++----- fs/nfsd/nfsctl.c | 65 +++++++++++++++++++++++++++++++++++++++++++ include/linux/lockd/lockd.h | 7 ++++ 3 files changed, 131 insertions(+), 7 deletions(-) diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index dbbefbc..a82019e 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -18,6 +18,8 @@ #include <linux/lockd/lockd.h> #include <linux/lockd/share.h> #include <linux/lockd/sm_inter.h> +#include <linux/module.h> +#include <linux/mount.h> #define NLMDBG_FACILITY NLMDBG_SVCSUBS @@ -194,6 +196,12 @@ again: return 0; } +static int +nlmsvc_always_match(void *dummy1, struct nlm_host *dummy2) +{ + return 1; +} + /* * Inspect a single file */ @@ -230,7 +238,8 @@ nlm_file_inuse(struct nlm_file *file) * Loop over all files in the file table. */ static int -nlm_traverse_files(struct nlm_host *host, nlm_host_match_fn_t match) +nlm_traverse_files(void *data, nlm_host_match_fn_t match, + int (*is_failover_file)(void *data, struct nlm_file *file)) { struct hlist_node *pos, *next; struct nlm_file *file; @@ -244,8 +253,17 @@ nlm_traverse_files(struct nlm_host *host, nlm_host_match_fn_t match) /* Traverse locks, blocks and shares of this file * and update file->f_locks count */ - if (nlm_inspect_file(host, file, match)) - ret = 1; + + if (likely(is_failover_file == NULL) || + is_failover_file(data, file)) { + /* + * Note that nlm_inspect_file updates f_locks + * and ret is the number of files that can't + * be unlocked. + */ + ret += nlm_inspect_file(data, file, match); + } else + file->f_locks = nlm_file_inuse(file); mutex_lock(&nlm_file_mutex); file->f_count--; @@ -303,21 +321,27 @@ nlm_release_file(struct nlm_file *file) * Used by nlmsvc_invalidate_all */ static int -nlmsvc_mark_host(struct nlm_host *host, struct nlm_host *dummy) +nlmsvc_mark_host(void *data, struct nlm_host *dummy) { + struct nlm_host *host = data; + host->h_inuse = 1; return 0; } static int -nlmsvc_same_host(struct nlm_host *host, struct nlm_host *other) +nlmsvc_same_host(void *data, struct nlm_host *other) { + struct nlm_host *host = data; + return host == other; } static int -nlmsvc_is_client(struct nlm_host *host, struct nlm_host *dummy) +nlmsvc_is_client(void *data, struct nlm_host *dummy) { + struct nlm_host *host = data; + if (host->h_server) { /* we are destroying locks even though the client * hasn't asked us too, so don't unmonitor the @@ -337,7 +361,7 @@ void nlmsvc_mark_resources(void) { dprintk("lockd: nlmsvc_mark_resources\n"); - nlm_traverse_files(NULL, nlmsvc_mark_host); + nlm_traverse_files(NULL, nlmsvc_mark_host, NULL); } /* @@ -348,7 +372,7 @@ nlmsvc_free_host_resources(struct nlm_host *host) { dprintk("lockd: nlmsvc_free_host_resources\n"); - if (nlm_traverse_files(host, nlmsvc_same_host)) { + if (nlm_traverse_files(host, nlmsvc_same_host, NULL)) { printk(KERN_WARNING "lockd: couldn't remove all locks held by %s\n", host->h_name); @@ -368,5 +392,36 @@ nlmsvc_invalidate_all(void) * turn, which is about as inefficient as it gets. * Now we just do it once in nlm_traverse_files. */ - nlm_traverse_files(NULL, nlmsvc_is_client); + nlm_traverse_files(NULL, nlmsvc_is_client, NULL); +} + +static int +nlmsvc_failover_file_ok_path(void *datap, struct nlm_file *file) +{ + struct nameidata *nd = datap; + return nd->path.mnt->mnt_sb == file->f_file->f_path.mnt->mnt_sb; +} + +int +nlmsvc_failover_path(struct nameidata *nd) +{ + return nlm_traverse_files(nd, nlmsvc_always_match, + nlmsvc_failover_file_ok_path); +} +EXPORT_SYMBOL_GPL(nlmsvc_failover_path); + +static int +nlmsvc_failover_file_ok_ip(void *datap, struct nlm_host *host) +{ + __be32 *server_addr = datap; + + return host->h_saddr.sin_addr.s_addr == *server_addr; +} + +int +nlmsvc_failover_ip(__be32 server_addr) +{ + return nlm_traverse_files(&server_addr, nlmsvc_failover_file_ok_ip, + NULL); } +EXPORT_SYMBOL_GPL(nlmsvc_failover_ip); diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 8516137..05a59cc 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -22,6 +22,7 @@ #include <linux/seq_file.h> #include <linux/pagemap.h> #include <linux/init.h> +#include <linux/inet.h> #include <linux/string.h> #include <linux/smp_lock.h> #include <linux/ctype.h> @@ -35,6 +36,7 @@ #include <linux/nfsd/cache.h> #include <linux/nfsd/xdr.h> #include <linux/nfsd/syscall.h> +#include <linux/lockd/lockd.h> #include <asm/uaccess.h> @@ -52,6 +54,8 @@ enum { NFSD_Getfs, NFSD_List, NFSD_Fh, + NFSD_FO_UnlockIP, + NFSD_FO_UnlockFS, NFSD_Threads, NFSD_Pool_Threads, NFSD_Versions, @@ -88,6 +92,9 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size); static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); #endif +static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size); +static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size); + static ssize_t (*write_op[])(struct file *, char *, size_t) = { [NFSD_Svc] = write_svc, [NFSD_Add] = write_add, @@ -97,6 +104,8 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { [NFSD_Getfd] = write_getfd, [NFSD_Getfs] = write_getfs, [NFSD_Fh] = write_filehandle, + [NFSD_FO_UnlockIP] = failover_unlock_ip, + [NFSD_FO_UnlockFS] = failover_unlock_fs, [NFSD_Threads] = write_threads, [NFSD_Pool_Threads] = write_pool_threads, [NFSD_Versions] = write_versions, @@ -288,6 +297,58 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size) return err; } +static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) +{ + __be32 server_ip; + char *fo_path, c; + int b1, b2, b3, b4; + + /* sanity check */ + if (size == 0) + return -EINVAL; + + if (buf[size-1] != '\n') + return -EINVAL; + + fo_path = buf; + if (qword_get(&buf, fo_path, size) < 0) + return -EINVAL; + + /* get ipv4 address */ + if (sscanf(fo_path, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4) + return -EINVAL; + server_ip = htonl((((((b1<<8)|b2)<<8)|b3)<<8)|b4); + + return nlmsvc_failover_ip(server_ip); +} + +static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) +{ + struct nameidata nd; + char *fo_path; + int error; + + /* sanity check */ + if (size == 0) + return -EINVAL; + + if (buf[size-1] != '\n') + return -EINVAL; + + fo_path = buf; + if (qword_get(&buf, fo_path, size) < 0) + return -EINVAL; + + error = path_lookup(fo_path, 0, &nd); + if (error) + return error; + + error = nlmsvc_failover_path(&nd); + + path_put(&nd.path); + return error; +} + static ssize_t write_filehandle(struct file *file, char *buf, size_t size) { /* request is: @@ -696,6 +757,10 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent) [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, + [NFSD_FO_UnlockIP] = {"unlock_ip", + &transaction_ops, S_IWUSR|S_IRUSR}, + [NFSD_FO_UnlockFS] = {"unlock_filesystem", + &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index 4babb2a..cde8605 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h @@ -191,7 +191,7 @@ void nsm_release(struct nsm_handle *); * This is used in garbage collection and resource reclaim * A return value != 0 means destroy the lock/block/share */ -typedef int (*nlm_host_match_fn_t)(struct nlm_host *cur, struct nlm_host *ref); +typedef int (*nlm_host_match_fn_t)(void *cur, struct nlm_host *ref); /* * Server-side lock handling @@ -217,6 +217,12 @@ void nlmsvc_mark_resources(void); void nlmsvc_free_host_resources(struct nlm_host *); void nlmsvc_invalidate_all(void); +/* + * Cluster failover support + */ +int nlmsvc_failover_path(struct nameidata *nd); +int nlmsvc_failover_ip(__be32 server_addr); + static __inline__ struct inode * nlmsvc_file_inode(struct nlm_file *file) { ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [NFS] Forcefully resetting a lock 2008-04-17 21:52 ` J. Bruce Fields @ 2008-04-18 14:02 ` Wendy Cheng 2008-04-18 18:19 ` J. Bruce Fields 0 siblings, 1 reply; 21+ messages in thread From: Wendy Cheng @ 2008-04-18 14:02 UTC (permalink / raw) To: J. Bruce Fields; +Cc: nfs, Erik Hensema / HostingXS Internet Services J. Bruce Fields wrote: > On Wed, Apr 16, 2008 at 02:39:19PM -0500, Wendy Cheng wrote: > >> J. Bruce Fields wrote: >> >>> On Wed, Apr 16, 2008 at 10:15:19AM -0500, Wendy Cheng wrote: >>> >>> >>>> Erik Hensema / HostingXS Internet Services wrote: >>>> >>>> >>>>> Hi all, >>>>> >>>>> Sometimes a file lock gets stuck. Is there any way on either server >>>>> or client to obtain a list of locks? Or a list of >>>>> processes/clients locking a particular file? >>>>> And the million dollar question: is it possible to forcefully >>>>> remove a lock? >>>>> >>>>> I'm using NFSv4 on Linux 2.6.18 (server and client). >>>>> >>>>> >>>>> >>>> *Cough* ! >>>> >>>> Bruce, so what happens to my lock dropping patch that was said "will >>>> get pulled into 2.6.26 kernel" ? >>>> >>>> >>> Gulp. >>> >>> I started an alternative implementation, and got it to the point where >>> it was basically working (but I didn't completely trust it). And I did >>> a small fix or two on your patches, but I seem to recall there were one >>> or more todo's there too. >>> >>> Then I dropped both for a couple weeks. >>> >>> >> Be carefully. .. "a couple weeks" can turn into "a couple years" .. It >> has been more than 2 years since my first patch submission. Regardless >> the patch has been repeatedly requested and had gone thru thorough >> testings, it just sits there idling while Linux nfs server keeps >> suffering the very same issue. >> > > Yes, apologies for not getting this done on time. > > >> Don't get too ambitious. Cluster issues are not trivial - please take >> one step at a time. The patch is very usable *and* solves an immediate >> issue *and* has a clean boundary with existing main-line logic. I really >> don't see the reason to delay it. >> > > My current version of your patch follows. > > I've rebased it a couple times (the only change I recall being required > was a trivial fix to take into account reorganization of struct > nameidata.). I also made two other changes; any objections to either?: > Thanks for doing this... The changes look good - though I don't have chances to test it out yet. When is 2.6.26 code cut-off date (or we have missed it again) ? -- Wendy > ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [NFS] Forcefully resetting a lock 2008-04-18 14:02 ` Wendy Cheng @ 2008-04-18 18:19 ` J. Bruce Fields 2008-04-22 23:15 ` J. Bruce Fields 0 siblings, 1 reply; 21+ messages in thread From: J. Bruce Fields @ 2008-04-18 18:19 UTC (permalink / raw) To: Wendy Cheng; +Cc: nfs, Erik Hensema / HostingXS Internet Services On Fri, Apr 18, 2008 at 09:02:06AM -0500, Wendy Cheng wrote: > J. Bruce Fields wrote: >> My current version of your patch follows. >> >> I've rebased it a couple times (the only change I recall being required >> was a trivial fix to take into account reorganization of struct >> nameidata.). I also made two other changes; any objections to either?: >> > > Thanks for doing this... The changes look good - though I don't have > chances to test it out yet. When is 2.6.26 code cut-off date (or we have > missed it again) ? Really it should be now, though there's another week or so when we can submit stuff if it's in good shape. But I'm feeling bad about letting this go recently, so I'll look at the last couple issues and do some testing over the next few days... --b. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [NFS] Forcefully resetting a lock 2008-04-18 18:19 ` J. Bruce Fields @ 2008-04-22 23:15 ` J. Bruce Fields 2008-04-22 23:17 ` [NFS] [PATCH] lockd: unlock lockd locks associated with a given server ip J. Bruce Fields 0 siblings, 1 reply; 21+ messages in thread From: J. Bruce Fields @ 2008-04-22 23:15 UTC (permalink / raw) To: Wendy Cheng; +Cc: nfs, Erik Hensema / HostingXS Internet Services On Fri, Apr 18, 2008 at 02:19:18PM -0400, bfields wrote: > Really it should be now, though there's another week or so when we can > submit stuff if it's in good shape. > > But I'm feeling bad about letting this go recently, so I'll look at the > last couple issues and do some testing over the next few days... OK, I changed the return value to -EIO in the case locks weren't unlocked. (Better suggestions welcomed. I notice lockd actually BUG()s in a similar situation elsewhere in the code, but that's probably not right.) I also simplified the nlm_traverse_files() change so now it's just: @@ -241,6 +248,8 @@ nlm_traverse_files(void *data, nlm_host_match_fn_t match) mutex_lock(&nlm_file_mutex); for (i = 0; i < FILE_NRHASH; i++) { hlist_for_each_entry_safe(file, pos, next, &nlm_files[i], f_list) { + if (is_failover_file && !is_failover_file(data, file)) + continue; file->f_count++; mutex_unlock(&nlm_file_mutex); Since the "continue" happens before we do anything at all with that file, I believe this is safe, and avoids the need for the extra nlm_file_inuse() call. And I split the patch into two (unlock_ip, unlock_fs) and edited the commit messages a little. The only testing I've done was just connecthon tests plus a simple manual test with unlock_filesystem (acquiring a lock from a client, echoing path to unlock_filesystem, verifying that it's gone from /proc/locks). Revised patches follow.... --b. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply [flat|nested] 21+ messages in thread
* [NFS] [PATCH] lockd: unlock lockd locks associated with a given server ip 2008-04-22 23:15 ` J. Bruce Fields @ 2008-04-22 23:17 ` J. Bruce Fields 2008-04-22 23:18 ` [NFS] [PATCH] lockd: unlock lockd locks held for a certain filesystem J. Bruce Fields 0 siblings, 1 reply; 21+ messages in thread From: J. Bruce Fields @ 2008-04-22 23:17 UTC (permalink / raw) To: Wendy Cheng Cc: Lon Hohberger, nfs, Christoph Hellwig, Erik Hensema / HostingXS Internet Services From: Wendy Cheng <wcheng@redhat.com> For high-availability NFS service, we generally need to be able to drop file locks held on the exported filesystem before moving clients to a new server. Currently the only way to do that is by shutting down lockd entirely, which is often undesireable (for example, if you want to continue exporting other filesystems). This patch allows the administrator to release all locks held by clients accessing the client through a given server ip address, by echoing that address to a new file, /proc/fs/nfsd/unlock_ip, as in: shell> echo 10.1.1.2 > /proc/fs/nfsd/unlock_ip The expected sequence of events can be: 1. Tear down the IP address 2. Unexport the path 3. Write IP to /proc/fs/nfsd/unlock_ip to unlock files 4. Signal peer to begin take-over. For now we only support IPv4 addresses and NFSv2/v3 (NFSv4 locks are not affected). Also, if unmounting the filesystem is required, we assume at step 3 that clients using the given server ip are the only clients holding locks on the given filesystem; otherwise, an additional patch is required to allow revoking all locks held by lockd on a given filesystem. Signed-off-by: S. Wendy Cheng <wcheng@redhat.com> Cc: Lon Hohberger <lhh@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> fs/lockd/svcsubs.c | 66 +++++++++++++++++++++++++++++++++++++++----- fs/nfsd/nfsctl.c | 65 +++++++++++++++++++++++++++++++++++++++++++ include/linux/lockd/lockd.h | 7 ++++ 3 files changed, 131 insertions(+), 7 deletions(-) --- fs/lockd/svcsubs.c | 36 +++++++++++++++++++++++++++++++----- fs/nfsd/nfsctl.c | 33 +++++++++++++++++++++++++++++++++ include/linux/lockd/lockd.h | 7 ++++++- 3 files changed, 70 insertions(+), 6 deletions(-) diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index dbbefbc..e12daba 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -18,6 +18,8 @@ #include <linux/lockd/lockd.h> #include <linux/lockd/share.h> #include <linux/lockd/sm_inter.h> +#include <linux/module.h> +#include <linux/mount.h> #define NLMDBG_FACILITY NLMDBG_SVCSUBS @@ -230,7 +232,7 @@ nlm_file_inuse(struct nlm_file *file) * Loop over all files in the file table. */ static int -nlm_traverse_files(struct nlm_host *host, nlm_host_match_fn_t match) +nlm_traverse_files(void *data, nlm_host_match_fn_t match) { struct hlist_node *pos, *next; struct nlm_file *file; @@ -244,7 +246,7 @@ nlm_traverse_files(struct nlm_host *host, nlm_host_match_fn_t match) /* Traverse locks, blocks and shares of this file * and update file->f_locks count */ - if (nlm_inspect_file(host, file, match)) + if (nlm_inspect_file(data, file, match)) ret = 1; mutex_lock(&nlm_file_mutex); @@ -303,21 +305,27 @@ nlm_release_file(struct nlm_file *file) * Used by nlmsvc_invalidate_all */ static int -nlmsvc_mark_host(struct nlm_host *host, struct nlm_host *dummy) +nlmsvc_mark_host(void *data, struct nlm_host *dummy) { + struct nlm_host *host = data; + host->h_inuse = 1; return 0; } static int -nlmsvc_same_host(struct nlm_host *host, struct nlm_host *other) +nlmsvc_same_host(void *data, struct nlm_host *other) { + struct nlm_host *host = data; + return host == other; } static int -nlmsvc_is_client(struct nlm_host *host, struct nlm_host *dummy) +nlmsvc_is_client(void *data, struct nlm_host *dummy) { + struct nlm_host *host = data; + if (host->h_server) { /* we are destroying locks even though the client * hasn't asked us too, so don't unmonitor the @@ -370,3 +378,21 @@ nlmsvc_invalidate_all(void) */ nlm_traverse_files(NULL, nlmsvc_is_client); } + +static int +nlmsvc_failover_file_ok_ip(void *datap, struct nlm_host *host) +{ + __be32 *server_addr = datap; + + return host->h_saddr.sin_addr.s_addr == *server_addr; +} + +int +nlmsvc_failover_ip(__be32 server_addr) +{ + int ret; + ret = nlm_traverse_files(&server_addr, nlmsvc_failover_file_ok_ip); + return ret ? -EIO : 0; + +} +EXPORT_SYMBOL_GPL(nlmsvc_failover_ip); diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 8516137..02c3949 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -22,6 +22,7 @@ #include <linux/seq_file.h> #include <linux/pagemap.h> #include <linux/init.h> +#include <linux/inet.h> #include <linux/string.h> #include <linux/smp_lock.h> #include <linux/ctype.h> @@ -35,6 +36,7 @@ #include <linux/nfsd/cache.h> #include <linux/nfsd/xdr.h> #include <linux/nfsd/syscall.h> +#include <linux/lockd/lockd.h> #include <asm/uaccess.h> @@ -52,6 +54,7 @@ enum { NFSD_Getfs, NFSD_List, NFSD_Fh, + NFSD_FO_UnlockIP, NFSD_Threads, NFSD_Pool_Threads, NFSD_Versions, @@ -88,6 +91,8 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size); static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); #endif +static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size); + static ssize_t (*write_op[])(struct file *, char *, size_t) = { [NFSD_Svc] = write_svc, [NFSD_Add] = write_add, @@ -97,6 +102,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { [NFSD_Getfd] = write_getfd, [NFSD_Getfs] = write_getfs, [NFSD_Fh] = write_filehandle, + [NFSD_FO_UnlockIP] = failover_unlock_ip, [NFSD_Threads] = write_threads, [NFSD_Pool_Threads] = write_pool_threads, [NFSD_Versions] = write_versions, @@ -288,6 +294,31 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size) return err; } +static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) +{ + __be32 server_ip; + char *fo_path, c; + int b1, b2, b3, b4; + + /* sanity check */ + if (size == 0) + return -EINVAL; + + if (buf[size-1] != '\n') + return -EINVAL; + + fo_path = buf; + if (qword_get(&buf, fo_path, size) < 0) + return -EINVAL; + + /* get ipv4 address */ + if (sscanf(fo_path, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4) + return -EINVAL; + server_ip = htonl((((((b1<<8)|b2)<<8)|b3)<<8)|b4); + + return nlmsvc_failover_ip(server_ip); +} + static ssize_t write_filehandle(struct file *file, char *buf, size_t size) { /* request is: @@ -696,6 +727,8 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent) [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, + [NFSD_FO_UnlockIP] = {"unlock_ip", + &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index 4babb2a..f06d2db 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h @@ -191,7 +191,7 @@ void nsm_release(struct nsm_handle *); * This is used in garbage collection and resource reclaim * A return value != 0 means destroy the lock/block/share */ -typedef int (*nlm_host_match_fn_t)(struct nlm_host *cur, struct nlm_host *ref); +typedef int (*nlm_host_match_fn_t)(void *cur, struct nlm_host *ref); /* * Server-side lock handling @@ -217,6 +217,11 @@ void nlmsvc_mark_resources(void); void nlmsvc_free_host_resources(struct nlm_host *); void nlmsvc_invalidate_all(void); +/* + * Cluster failover support + */ +int nlmsvc_failover_ip(__be32 server_addr); + static __inline__ struct inode * nlmsvc_file_inode(struct nlm_file *file) { -- 1.5.5.rc1 ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [NFS] [PATCH] lockd: unlock lockd locks held for a certain filesystem 2008-04-22 23:17 ` [NFS] [PATCH] lockd: unlock lockd locks associated with a given server ip J. Bruce Fields @ 2008-04-22 23:18 ` J. Bruce Fields 2008-04-23 2:57 ` Wendy Cheng 2008-04-23 7:44 ` Christoph Hellwig 0 siblings, 2 replies; 21+ messages in thread From: J. Bruce Fields @ 2008-04-22 23:18 UTC (permalink / raw) To: Wendy Cheng Cc: Lon Hohberger, nfs, Christoph Hellwig, Erik Hensema / HostingXS Internet Services From: Wendy Cheng <wcheng@redhat.com> Add /proc/fs/nfsd/unlock_filesystem, which allows e.g.: shell> echo /mnt/sfs1 > /proc/fs/nfsd/unlock_filesystem so that a filesystem can be unmounted before allowing a peer nfsd to take over nfs service for the filesystem. Signed-off-by: S. Wendy Cheng <wcheng@redhat.com> Cc: Lon Hohberger <lhh@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> fs/lockd/svcsubs.c | 66 +++++++++++++++++++++++++++++++++++++++----- fs/nfsd/nfsctl.c | 65 +++++++++++++++++++++++++++++++++++++++++++ include/linux/lockd/lockd.h | 7 ++++ 3 files changed, 131 insertions(+), 7 deletions(-) --- fs/lockd/svcsubs.c | 38 +++++++++++++++++++++++++++++++++----- fs/nfsd/nfsctl.c | 32 ++++++++++++++++++++++++++++++++ include/linux/lockd/lockd.h | 1 + 3 files changed, 66 insertions(+), 5 deletions(-) diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index e12daba..24589de 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -196,6 +196,12 @@ again: return 0; } +static int +nlmsvc_always_match(void *dummy1, struct nlm_host *dummy2) +{ + return 1; +} + /* * Inspect a single file */ @@ -232,7 +238,8 @@ nlm_file_inuse(struct nlm_file *file) * Loop over all files in the file table. */ static int -nlm_traverse_files(void *data, nlm_host_match_fn_t match) +nlm_traverse_files(void *data, nlm_host_match_fn_t match, + int (*is_failover_file)(void *data, struct nlm_file *file)) { struct hlist_node *pos, *next; struct nlm_file *file; @@ -241,6 +248,8 @@ nlm_traverse_files(void *data, nlm_host_match_fn_t match) mutex_lock(&nlm_file_mutex); for (i = 0; i < FILE_NRHASH; i++) { hlist_for_each_entry_safe(file, pos, next, &nlm_files[i], f_list) { + if (is_failover_file && !is_failover_file(data, file)) + continue; file->f_count++; mutex_unlock(&nlm_file_mutex); @@ -345,7 +354,7 @@ void nlmsvc_mark_resources(void) { dprintk("lockd: nlmsvc_mark_resources\n"); - nlm_traverse_files(NULL, nlmsvc_mark_host); + nlm_traverse_files(NULL, nlmsvc_mark_host, NULL); } /* @@ -356,7 +365,7 @@ nlmsvc_free_host_resources(struct nlm_host *host) { dprintk("lockd: nlmsvc_free_host_resources\n"); - if (nlm_traverse_files(host, nlmsvc_same_host)) { + if (nlm_traverse_files(host, nlmsvc_same_host, NULL)) { printk(KERN_WARNING "lockd: couldn't remove all locks held by %s\n", host->h_name); @@ -376,8 +385,26 @@ nlmsvc_invalidate_all(void) * turn, which is about as inefficient as it gets. * Now we just do it once in nlm_traverse_files. */ - nlm_traverse_files(NULL, nlmsvc_is_client); + nlm_traverse_files(NULL, nlmsvc_is_client, NULL); +} + +static int +nlmsvc_failover_file_ok_path(void *datap, struct nlm_file *file) +{ + struct nameidata *nd = datap; + return nd->path.mnt->mnt_sb == file->f_file->f_path.mnt->mnt_sb; +} + +int +nlmsvc_failover_path(struct nameidata *nd) +{ + int ret; + + ret = nlm_traverse_files(nd, nlmsvc_always_match, + nlmsvc_failover_file_ok_path); + return ret ? -EIO : 0; } +EXPORT_SYMBOL_GPL(nlmsvc_failover_path); static int nlmsvc_failover_file_ok_ip(void *datap, struct nlm_host *host) @@ -391,7 +418,8 @@ int nlmsvc_failover_ip(__be32 server_addr) { int ret; - ret = nlm_traverse_files(&server_addr, nlmsvc_failover_file_ok_ip); + ret = nlm_traverse_files(&server_addr, nlmsvc_failover_file_ok_ip, + NULL); return ret ? -EIO : 0; } diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 02c3949..05a59cc 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -55,6 +55,7 @@ enum { NFSD_List, NFSD_Fh, NFSD_FO_UnlockIP, + NFSD_FO_UnlockFS, NFSD_Threads, NFSD_Pool_Threads, NFSD_Versions, @@ -92,6 +93,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); #endif static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size); +static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size); static ssize_t (*write_op[])(struct file *, char *, size_t) = { [NFSD_Svc] = write_svc, @@ -103,6 +105,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { [NFSD_Getfs] = write_getfs, [NFSD_Fh] = write_filehandle, [NFSD_FO_UnlockIP] = failover_unlock_ip, + [NFSD_FO_UnlockFS] = failover_unlock_fs, [NFSD_Threads] = write_threads, [NFSD_Pool_Threads] = write_pool_threads, [NFSD_Versions] = write_versions, @@ -319,6 +322,33 @@ static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) return nlmsvc_failover_ip(server_ip); } +static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) +{ + struct nameidata nd; + char *fo_path; + int error; + + /* sanity check */ + if (size == 0) + return -EINVAL; + + if (buf[size-1] != '\n') + return -EINVAL; + + fo_path = buf; + if (qword_get(&buf, fo_path, size) < 0) + return -EINVAL; + + error = path_lookup(fo_path, 0, &nd); + if (error) + return error; + + error = nlmsvc_failover_path(&nd); + + path_put(&nd.path); + return error; +} + static ssize_t write_filehandle(struct file *file, char *buf, size_t size) { /* request is: @@ -729,6 +759,8 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent) [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, [NFSD_FO_UnlockIP] = {"unlock_ip", &transaction_ops, S_IWUSR|S_IRUSR}, + [NFSD_FO_UnlockFS] = {"unlock_filesystem", + &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index f06d2db..cde8605 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h @@ -220,6 +220,7 @@ void nlmsvc_invalidate_all(void); /* * Cluster failover support */ +int nlmsvc_failover_path(struct nameidata *nd); int nlmsvc_failover_ip(__be32 server_addr); static __inline__ struct inode * -- 1.5.5.rc1 ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [NFS] [PATCH] lockd: unlock lockd locks held for a certain filesystem 2008-04-22 23:18 ` [NFS] [PATCH] lockd: unlock lockd locks held for a certain filesystem J. Bruce Fields @ 2008-04-23 2:57 ` Wendy Cheng 2008-04-23 7:44 ` Christoph Hellwig 1 sibling, 0 replies; 21+ messages in thread From: Wendy Cheng @ 2008-04-23 2:57 UTC (permalink / raw) To: J. Bruce Fields Cc: Lon Hohberger, nfs, Christoph Hellwig, Erik Hensema / HostingXS Internet Services ok, just pulled the linux kernel source few minutes ago. will restart cluster testings and let you know tomorrow... Wendy ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [NFS] [PATCH] lockd: unlock lockd locks held for a certain filesystem 2008-04-22 23:18 ` [NFS] [PATCH] lockd: unlock lockd locks held for a certain filesystem J. Bruce Fields 2008-04-23 2:57 ` Wendy Cheng @ 2008-04-23 7:44 ` Christoph Hellwig 2008-04-23 17:12 ` J. Bruce Fields 1 sibling, 1 reply; 21+ messages in thread From: Christoph Hellwig @ 2008-04-23 7:44 UTC (permalink / raw) To: J. Bruce Fields Cc: Lon Hohberger, Wendy Cheng, nfs, Christoph Hellwig, Erik Hensema / HostingXS Internet Services Please don't pass down the nameidata, but just the super_block. That's all we need in the lower layer functions. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [NFS] [PATCH] lockd: unlock lockd locks held for a certain filesystem 2008-04-23 7:44 ` Christoph Hellwig @ 2008-04-23 17:12 ` J. Bruce Fields 2008-04-23 17:52 ` Christoph Hellwig 2008-04-23 20:39 ` Wendy Cheng 0 siblings, 2 replies; 21+ messages in thread From: J. Bruce Fields @ 2008-04-23 17:12 UTC (permalink / raw) To: Christoph Hellwig Cc: Lon Hohberger, Wendy Cheng, nfs, Erik Hensema / HostingXS Internet Services On Wed, Apr 23, 2008 at 09:44:22AM +0200, Christoph Hellwig wrote: > Please don't pass down the nameidata, but just the super_block. That's > all we need in the lower layer functions. Yep, I agree that's nicer; here's the result. --b. commit 26a816586b71877d8a84fbb436373099384e328b Author: Wendy Cheng <wcheng@redhat.com> Date: Thu Jan 17 11:10:12 2008 -0500 lockd: unlock lockd locks held for a certain filesystem Add /proc/fs/nfsd/unlock_filesystem, which allows e.g.: shell> echo /mnt/sfs1 > /proc/fs/nfsd/unlock_filesystem so that a filesystem can be unmounted before allowing a peer nfsd to take over nfs service for the filesystem. Signed-off-by: S. Wendy Cheng <wcheng@redhat.com> Cc: Lon Hohberger <lhh@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> fs/lockd/svcsubs.c | 66 +++++++++++++++++++++++++++++++++++++++----- fs/nfsd/nfsctl.c | 65 +++++++++++++++++++++++++++++++++++++++++++ include/linux/lockd/lockd.h | 7 ++++ 3 files changed, 131 insertions(+), 7 deletions(-) diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index e12daba..dcdcff6 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -196,6 +196,12 @@ again: return 0; } +static int +nlmsvc_always_match(void *dummy1, struct nlm_host *dummy2) +{ + return 1; +} + /* * Inspect a single file */ @@ -232,7 +238,8 @@ nlm_file_inuse(struct nlm_file *file) * Loop over all files in the file table. */ static int -nlm_traverse_files(void *data, nlm_host_match_fn_t match) +nlm_traverse_files(void *data, nlm_host_match_fn_t match, + int (*is_failover_file)(void *data, struct nlm_file *file)) { struct hlist_node *pos, *next; struct nlm_file *file; @@ -241,6 +248,8 @@ nlm_traverse_files(void *data, nlm_host_match_fn_t match) mutex_lock(&nlm_file_mutex); for (i = 0; i < FILE_NRHASH; i++) { hlist_for_each_entry_safe(file, pos, next, &nlm_files[i], f_list) { + if (is_failover_file && !is_failover_file(data, file)) + continue; file->f_count++; mutex_unlock(&nlm_file_mutex); @@ -345,7 +354,7 @@ void nlmsvc_mark_resources(void) { dprintk("lockd: nlmsvc_mark_resources\n"); - nlm_traverse_files(NULL, nlmsvc_mark_host); + nlm_traverse_files(NULL, nlmsvc_mark_host, NULL); } /* @@ -356,7 +365,7 @@ nlmsvc_free_host_resources(struct nlm_host *host) { dprintk("lockd: nlmsvc_free_host_resources\n"); - if (nlm_traverse_files(host, nlmsvc_same_host)) { + if (nlm_traverse_files(host, nlmsvc_same_host, NULL)) { printk(KERN_WARNING "lockd: couldn't remove all locks held by %s\n", host->h_name); @@ -376,8 +385,27 @@ nlmsvc_invalidate_all(void) * turn, which is about as inefficient as it gets. * Now we just do it once in nlm_traverse_files. */ - nlm_traverse_files(NULL, nlmsvc_is_client); + nlm_traverse_files(NULL, nlmsvc_is_client, NULL); +} + +static int +nlmsvc_failover_file_ok_path(void *datap, struct nlm_file *file) +{ + struct super_block *sb = datap; + + return sb == file->f_file->f_path.mnt->mnt_sb; +} + +int +nlmsvc_failover_path(struct super_block *sb) +{ + int ret; + + ret = nlm_traverse_files(sb, nlmsvc_always_match, + nlmsvc_failover_file_ok_path); + return ret ? -EIO : 0; } +EXPORT_SYMBOL_GPL(nlmsvc_failover_path); static int nlmsvc_failover_file_ok_ip(void *datap, struct nlm_host *host) @@ -391,7 +419,8 @@ int nlmsvc_failover_ip(__be32 server_addr) { int ret; - ret = nlm_traverse_files(&server_addr, nlmsvc_failover_file_ok_ip); + ret = nlm_traverse_files(&server_addr, nlmsvc_failover_file_ok_ip, + NULL); return ret ? -EIO : 0; } diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 02c3949..b4ca5c9 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -55,6 +55,7 @@ enum { NFSD_List, NFSD_Fh, NFSD_FO_UnlockIP, + NFSD_FO_UnlockFS, NFSD_Threads, NFSD_Pool_Threads, NFSD_Versions, @@ -92,6 +93,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); #endif static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size); +static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size); static ssize_t (*write_op[])(struct file *, char *, size_t) = { [NFSD_Svc] = write_svc, @@ -103,6 +105,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { [NFSD_Getfs] = write_getfs, [NFSD_Fh] = write_filehandle, [NFSD_FO_UnlockIP] = failover_unlock_ip, + [NFSD_FO_UnlockFS] = failover_unlock_fs, [NFSD_Threads] = write_threads, [NFSD_Pool_Threads] = write_pool_threads, [NFSD_Versions] = write_versions, @@ -319,6 +322,33 @@ static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) return nlmsvc_failover_ip(server_ip); } +static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) +{ + struct nameidata nd; + char *fo_path; + int error; + + /* sanity check */ + if (size == 0) + return -EINVAL; + + if (buf[size-1] != '\n') + return -EINVAL; + + fo_path = buf; + if (qword_get(&buf, fo_path, size) < 0) + return -EINVAL; + + error = path_lookup(fo_path, 0, &nd); + if (error) + return error; + + error = nlmsvc_failover_path(nd.path.mnt->mnt_sb); + + path_put(&nd.path); + return error; +} + static ssize_t write_filehandle(struct file *file, char *buf, size_t size) { /* request is: @@ -729,6 +759,8 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent) [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, [NFSD_FO_UnlockIP] = {"unlock_ip", &transaction_ops, S_IWUSR|S_IRUSR}, + [NFSD_FO_UnlockFS] = {"unlock_filesystem", + &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index f06d2db..7cd9c8e 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h @@ -220,6 +220,7 @@ void nlmsvc_invalidate_all(void); /* * Cluster failover support */ +int nlmsvc_failover_path(struct super_block *sb); int nlmsvc_failover_ip(__be32 server_addr); static __inline__ struct inode * ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [NFS] [PATCH] lockd: unlock lockd locks held for a certain filesystem 2008-04-23 17:12 ` J. Bruce Fields @ 2008-04-23 17:52 ` Christoph Hellwig 2008-04-23 20:01 ` J. Bruce Fields 2008-04-23 20:39 ` Wendy Cheng 1 sibling, 1 reply; 21+ messages in thread From: Christoph Hellwig @ 2008-04-23 17:52 UTC (permalink / raw) To: J. Bruce Fields Cc: Lon Hohberger, Wendy Cheng, nfs, Christoph Hellwig, Erik Hensema / HostingXS Internet Services On Wed, Apr 23, 2008 at 01:12:40PM -0400, J. Bruce Fields wrote: > +int nlmsvc_failover_path(struct super_block *sb); With a super_block argument the path suffix doesn't make sense anymore. Should probably be an _sb instead. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [NFS] [PATCH] lockd: unlock lockd locks held for a certain filesystem 2008-04-23 17:52 ` Christoph Hellwig @ 2008-04-23 20:01 ` J. Bruce Fields 0 siblings, 0 replies; 21+ messages in thread From: J. Bruce Fields @ 2008-04-23 20:01 UTC (permalink / raw) To: Christoph Hellwig Cc: Lon Hohberger, Wendy Cheng, nfs, Erik Hensema / HostingXS Internet Services On Wed, Apr 23, 2008 at 07:52:26PM +0200, Christoph Hellwig wrote: > On Wed, Apr 23, 2008 at 01:12:40PM -0400, J. Bruce Fields wrote: > > +int nlmsvc_failover_path(struct super_block *sb); > > With a super_block argument the path suffix doesn't make sense anymore. > Should probably be an _sb instead. OK. As long as we're renaming stuff, I always found nlmsvc_failover_{ip,path}() a little vague, so I've made them nlmsvc_unlock_all_by_{ip,sb}(). --b. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs _______________________________________________ Please note that nfs@lists.sourceforge.net is being discontinued. Please subscribe to linux-nfs@vger.kernel.org instead. http://vger.kernel.org/vger-lists.html#linux-nfs ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] lockd: unlock lockd locks held for a certain filesystem 2008-04-23 17:12 ` J. Bruce Fields 2008-04-23 17:52 ` Christoph Hellwig @ 2008-04-23 20:39 ` Wendy Cheng 2008-04-23 21:02 ` J. Bruce Fields 1 sibling, 1 reply; 21+ messages in thread From: Wendy Cheng @ 2008-04-23 20:39 UTC (permalink / raw) To: J. Bruce Fields; +Cc: Christoph Hellwig, nfs, linux-nfs, Lon Hohberger #if defined(BRUCE_CHECK_THIS_OUT) error = nlmsvc_failover_path(nd.path.mnt->mnt_sb); #else error = nlmsvc_failover_path(nd.mnt->mnt_sb); #endif -- Wendy ---------- based on the following email ---------------------------- J. Bruce Fields wrote: > On Wed, Apr 23, 2008 at 09:44:22AM +0200, Christoph Hellwig wrote: > >> Please don't pass down the nameidata, but just the super_block. That's >> all we need in the lower layer functions. >> > > Yep, I agree that's nicer; here's the result. > > --b. > > commit 26a816586b71877d8a84fbb436373099384e328b > Author: Wendy Cheng <wcheng@redhat.com> > Date: Thu Jan 17 11:10:12 2008 -0500 > > lockd: unlock lockd locks held for a certain filesystem > > Add /proc/fs/nfsd/unlock_filesystem, which allows e.g.: > > shell> echo /mnt/sfs1 > /proc/fs/nfsd/unlock_filesystem > > so that a filesystem can be unmounted before allowing a peer nfsd to > take over nfs service for the filesystem. > > Signed-off-by: S. Wendy Cheng <wcheng@redhat.com> > Cc: Lon Hohberger <lhh@redhat.com> > Cc: Christoph Hellwig <hch@lst.de> > Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> > > fs/lockd/svcsubs.c | 66 +++++++++++++++++++++++++++++++++++++++----- > fs/nfsd/nfsctl.c | 65 +++++++++++++++++++++++++++++++++++++++++++ > include/linux/lockd/lockd.h | 7 ++++ > 3 files changed, 131 insertions(+), 7 deletions(-) > > diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c > index e12daba..dcdcff6 100644 > --- a/fs/lockd/svcsubs.c > +++ b/fs/lockd/svcsubs.c > @@ -196,6 +196,12 @@ again: > return 0; > } > > +static int > +nlmsvc_always_match(void *dummy1, struct nlm_host *dummy2) > +{ > + return 1; > +} > + > /* > * Inspect a single file > */ > @@ -232,7 +238,8 @@ nlm_file_inuse(struct nlm_file *file) > * Loop over all files in the file table. > */ > static int > -nlm_traverse_files(void *data, nlm_host_match_fn_t match) > +nlm_traverse_files(void *data, nlm_host_match_fn_t match, > + int (*is_failover_file)(void *data, struct nlm_file *file)) > { > struct hlist_node *pos, *next; > struct nlm_file *file; > @@ -241,6 +248,8 @@ nlm_traverse_files(void *data, nlm_host_match_fn_t match) > mutex_lock(&nlm_file_mutex); > for (i = 0; i < FILE_NRHASH; i++) { > hlist_for_each_entry_safe(file, pos, next, &nlm_files[i], f_list) { > + if (is_failover_file && !is_failover_file(data, file)) > + continue; > file->f_count++; > mutex_unlock(&nlm_file_mutex); > > @@ -345,7 +354,7 @@ void > nlmsvc_mark_resources(void) > { > dprintk("lockd: nlmsvc_mark_resources\n"); > - nlm_traverse_files(NULL, nlmsvc_mark_host); > + nlm_traverse_files(NULL, nlmsvc_mark_host, NULL); > } > > /* > @@ -356,7 +365,7 @@ nlmsvc_free_host_resources(struct nlm_host *host) > { > dprintk("lockd: nlmsvc_free_host_resources\n"); > > - if (nlm_traverse_files(host, nlmsvc_same_host)) { > + if (nlm_traverse_files(host, nlmsvc_same_host, NULL)) { > printk(KERN_WARNING > "lockd: couldn't remove all locks held by %s\n", > host->h_name); > @@ -376,8 +385,27 @@ nlmsvc_invalidate_all(void) > * turn, which is about as inefficient as it gets. > * Now we just do it once in nlm_traverse_files. > */ > - nlm_traverse_files(NULL, nlmsvc_is_client); > + nlm_traverse_files(NULL, nlmsvc_is_client, NULL); > +} > + > +static int > +nlmsvc_failover_file_ok_path(void *datap, struct nlm_file *file) > +{ > + struct super_block *sb = datap; > + > + return sb == file->f_file->f_path.mnt->mnt_sb; > +} > + > +int > +nlmsvc_failover_path(struct super_block *sb) > +{ > + int ret; > + > + ret = nlm_traverse_files(sb, nlmsvc_always_match, > + nlmsvc_failover_file_ok_path); > + return ret ? -EIO : 0; > } > +EXPORT_SYMBOL_GPL(nlmsvc_failover_path); > > static int > nlmsvc_failover_file_ok_ip(void *datap, struct nlm_host *host) > @@ -391,7 +419,8 @@ int > nlmsvc_failover_ip(__be32 server_addr) > { > int ret; > - ret = nlm_traverse_files(&server_addr, nlmsvc_failover_file_ok_ip); > + ret = nlm_traverse_files(&server_addr, nlmsvc_failover_file_ok_ip, > + NULL); > return ret ? -EIO : 0; > > } > diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c > index 02c3949..b4ca5c9 100644 > --- a/fs/nfsd/nfsctl.c > +++ b/fs/nfsd/nfsctl.c > @@ -55,6 +55,7 @@ enum { > NFSD_List, > NFSD_Fh, > NFSD_FO_UnlockIP, > + NFSD_FO_UnlockFS, > NFSD_Threads, > NFSD_Pool_Threads, > NFSD_Versions, > @@ -92,6 +93,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); > #endif > > static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size); > +static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size); > > static ssize_t (*write_op[])(struct file *, char *, size_t) = { > [NFSD_Svc] = write_svc, > @@ -103,6 +105,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { > [NFSD_Getfs] = write_getfs, > [NFSD_Fh] = write_filehandle, > [NFSD_FO_UnlockIP] = failover_unlock_ip, > + [NFSD_FO_UnlockFS] = failover_unlock_fs, > [NFSD_Threads] = write_threads, > [NFSD_Pool_Threads] = write_pool_threads, > [NFSD_Versions] = write_versions, > @@ -319,6 +322,33 @@ static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) > return nlmsvc_failover_ip(server_ip); > } > > +static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) > +{ > + struct nameidata nd; > + char *fo_path; > + int error; > + > + /* sanity check */ > + if (size == 0) > + return -EINVAL; > + > + if (buf[size-1] != '\n') > + return -EINVAL; > + > + fo_path = buf; > + if (qword_get(&buf, fo_path, size) < 0) > + return -EINVAL; > + > + error = path_lookup(fo_path, 0, &nd); > + if (error) > + return error; > + > + error = nlmsvc_failover_path(nd.path.mnt->mnt_sb); > + > + path_put(&nd.path); > + return error; > +} > + > static ssize_t write_filehandle(struct file *file, char *buf, size_t size) > { > /* request is: > @@ -729,6 +759,8 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent) > [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, > [NFSD_FO_UnlockIP] = {"unlock_ip", > &transaction_ops, S_IWUSR|S_IRUSR}, > + [NFSD_FO_UnlockFS] = {"unlock_filesystem", > + &transaction_ops, S_IWUSR|S_IRUSR}, > [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, > [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, > [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, > diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h > index f06d2db..7cd9c8e 100644 > --- a/include/linux/lockd/lockd.h > +++ b/include/linux/lockd/lockd.h > @@ -220,6 +220,7 @@ void nlmsvc_invalidate_all(void); > /* > * Cluster failover support > */ > +int nlmsvc_failover_path(struct super_block *sb); > int nlmsvc_failover_ip(__be32 server_addr); > > static __inline__ struct inode * > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] lockd: unlock lockd locks held for a certain filesystem 2008-04-23 20:39 ` Wendy Cheng @ 2008-04-23 21:02 ` J. Bruce Fields 2008-04-23 21:17 ` Wendy Cheng 0 siblings, 1 reply; 21+ messages in thread From: J. Bruce Fields @ 2008-04-23 21:02 UTC (permalink / raw) To: Wendy Cheng; +Cc: Christoph Hellwig, nfs, linux-nfs, Lon Hohberger On Wed, Apr 23, 2008 at 04:39:11PM -0400, Wendy Cheng wrote: > #if defined(BRUCE_CHECK_THIS_OUT) > error = nlmsvc_failover_path(nd.path.mnt->mnt_sb); > #else > error = nlmsvc_failover_path(nd.mnt->mnt_sb); > #endif The vfsmount and dentry got moved into the path argument sometime in the last kernel version or so. Is there a macro defining the latter as a shortcut for the former? I didn't see one. --b. > > -- Wendy > > ---------- based on the following email ---------------------------- > > J. Bruce Fields wrote: >> On Wed, Apr 23, 2008 at 09:44:22AM +0200, Christoph Hellwig wrote: >> >>> Please don't pass down the nameidata, but just the super_block. That's >>> all we need in the lower layer functions. >>> >> >> Yep, I agree that's nicer; here's the result. >> >> --b. >> >> commit 26a816586b71877d8a84fbb436373099384e328b >> Author: Wendy Cheng <wcheng@redhat.com> >> Date: Thu Jan 17 11:10:12 2008 -0500 >> >> lockd: unlock lockd locks held for a certain filesystem >> Add /proc/fs/nfsd/unlock_filesystem, which allows e.g.: >> shell> echo /mnt/sfs1 > /proc/fs/nfsd/unlock_filesystem >> so that a filesystem can be unmounted before allowing a peer >> nfsd to >> take over nfs service for the filesystem. >> Signed-off-by: S. Wendy Cheng <wcheng@redhat.com> >> Cc: Lon Hohberger <lhh@redhat.com> >> Cc: Christoph Hellwig <hch@lst.de> >> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> >> fs/lockd/svcsubs.c | 66 >> +++++++++++++++++++++++++++++++++++++++----- >> fs/nfsd/nfsctl.c | 65 +++++++++++++++++++++++++++++++++++++++++++ >> include/linux/lockd/lockd.h | 7 ++++ >> 3 files changed, 131 insertions(+), 7 deletions(-) >> >> diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c >> index e12daba..dcdcff6 100644 >> --- a/fs/lockd/svcsubs.c >> +++ b/fs/lockd/svcsubs.c >> @@ -196,6 +196,12 @@ again: >> return 0; >> } >> +static int >> +nlmsvc_always_match(void *dummy1, struct nlm_host *dummy2) >> +{ >> + return 1; >> +} >> + >> /* >> * Inspect a single file >> */ >> @@ -232,7 +238,8 @@ nlm_file_inuse(struct nlm_file *file) >> * Loop over all files in the file table. >> */ >> static int >> -nlm_traverse_files(void *data, nlm_host_match_fn_t match) >> +nlm_traverse_files(void *data, nlm_host_match_fn_t match, >> + int (*is_failover_file)(void *data, struct nlm_file *file)) >> { >> struct hlist_node *pos, *next; >> struct nlm_file *file; >> @@ -241,6 +248,8 @@ nlm_traverse_files(void *data, nlm_host_match_fn_t match) >> mutex_lock(&nlm_file_mutex); >> for (i = 0; i < FILE_NRHASH; i++) { >> hlist_for_each_entry_safe(file, pos, next, &nlm_files[i], f_list) { >> + if (is_failover_file && !is_failover_file(data, file)) >> + continue; >> file->f_count++; >> mutex_unlock(&nlm_file_mutex); >> @@ -345,7 +354,7 @@ void >> nlmsvc_mark_resources(void) >> { >> dprintk("lockd: nlmsvc_mark_resources\n"); >> - nlm_traverse_files(NULL, nlmsvc_mark_host); >> + nlm_traverse_files(NULL, nlmsvc_mark_host, NULL); >> } >> /* >> @@ -356,7 +365,7 @@ nlmsvc_free_host_resources(struct nlm_host *host) >> { >> dprintk("lockd: nlmsvc_free_host_resources\n"); >> - if (nlm_traverse_files(host, nlmsvc_same_host)) { >> + if (nlm_traverse_files(host, nlmsvc_same_host, NULL)) { >> printk(KERN_WARNING >> "lockd: couldn't remove all locks held by %s\n", >> host->h_name); >> @@ -376,8 +385,27 @@ nlmsvc_invalidate_all(void) >> * turn, which is about as inefficient as it gets. >> * Now we just do it once in nlm_traverse_files. >> */ >> - nlm_traverse_files(NULL, nlmsvc_is_client); >> + nlm_traverse_files(NULL, nlmsvc_is_client, NULL); >> +} >> + >> +static int >> +nlmsvc_failover_file_ok_path(void *datap, struct nlm_file *file) >> +{ >> + struct super_block *sb = datap; >> + >> + return sb == file->f_file->f_path.mnt->mnt_sb; >> +} >> + >> +int >> +nlmsvc_failover_path(struct super_block *sb) >> +{ >> + int ret; >> + >> + ret = nlm_traverse_files(sb, nlmsvc_always_match, >> + nlmsvc_failover_file_ok_path); >> + return ret ? -EIO : 0; >> } >> +EXPORT_SYMBOL_GPL(nlmsvc_failover_path); >> static int >> nlmsvc_failover_file_ok_ip(void *datap, struct nlm_host *host) >> @@ -391,7 +419,8 @@ int >> nlmsvc_failover_ip(__be32 server_addr) >> { >> int ret; >> - ret = nlm_traverse_files(&server_addr, nlmsvc_failover_file_ok_ip); >> + ret = nlm_traverse_files(&server_addr, nlmsvc_failover_file_ok_ip, >> + NULL); >> return ret ? -EIO : 0; >> } >> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c >> index 02c3949..b4ca5c9 100644 >> --- a/fs/nfsd/nfsctl.c >> +++ b/fs/nfsd/nfsctl.c >> @@ -55,6 +55,7 @@ enum { >> NFSD_List, >> NFSD_Fh, >> NFSD_FO_UnlockIP, >> + NFSD_FO_UnlockFS, >> NFSD_Threads, >> NFSD_Pool_Threads, >> NFSD_Versions, >> @@ -92,6 +93,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); >> #endif >> static ssize_t failover_unlock_ip(struct file *file, char *buf, >> size_t size); >> +static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size); >> static ssize_t (*write_op[])(struct file *, char *, size_t) = { >> [NFSD_Svc] = write_svc, >> @@ -103,6 +105,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { >> [NFSD_Getfs] = write_getfs, >> [NFSD_Fh] = write_filehandle, >> [NFSD_FO_UnlockIP] = failover_unlock_ip, >> + [NFSD_FO_UnlockFS] = failover_unlock_fs, >> [NFSD_Threads] = write_threads, >> [NFSD_Pool_Threads] = write_pool_threads, >> [NFSD_Versions] = write_versions, >> @@ -319,6 +322,33 @@ static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) >> return nlmsvc_failover_ip(server_ip); >> } >> +static ssize_t failover_unlock_fs(struct file *file, char *buf, >> size_t size) >> +{ >> + struct nameidata nd; >> + char *fo_path; >> + int error; >> + >> + /* sanity check */ >> + if (size == 0) >> + return -EINVAL; >> + >> + if (buf[size-1] != '\n') >> + return -EINVAL; >> + >> + fo_path = buf; >> + if (qword_get(&buf, fo_path, size) < 0) >> + return -EINVAL; >> + >> + error = path_lookup(fo_path, 0, &nd); >> + if (error) >> + return error; >> + >> + error = nlmsvc_failover_path(nd.path.mnt->mnt_sb); >> + >> + path_put(&nd.path); >> + return error; >> +} >> + >> static ssize_t write_filehandle(struct file *file, char *buf, size_t size) >> { >> /* request is: >> @@ -729,6 +759,8 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent) >> [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, >> [NFSD_FO_UnlockIP] = {"unlock_ip", >> &transaction_ops, S_IWUSR|S_IRUSR}, >> + [NFSD_FO_UnlockFS] = {"unlock_filesystem", >> + &transaction_ops, S_IWUSR|S_IRUSR}, >> [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, >> [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, >> [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, >> diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h >> index f06d2db..7cd9c8e 100644 >> --- a/include/linux/lockd/lockd.h >> +++ b/include/linux/lockd/lockd.h >> @@ -220,6 +220,7 @@ void nlmsvc_invalidate_all(void); >> /* >> * Cluster failover support >> */ >> +int nlmsvc_failover_path(struct super_block *sb); >> int nlmsvc_failover_ip(__be32 server_addr); >> static __inline__ struct inode * >> > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] lockd: unlock lockd locks held for a certain filesystem 2008-04-23 21:02 ` J. Bruce Fields @ 2008-04-23 21:17 ` Wendy Cheng 2008-04-23 21:39 ` J. Bruce Fields 0 siblings, 1 reply; 21+ messages in thread From: Wendy Cheng @ 2008-04-23 21:17 UTC (permalink / raw) To: J. Bruce Fields; +Cc: Christoph Hellwig, nfs, linux-nfs, Lon Hohberger J. Bruce Fields wrote: > On Wed, Apr 23, 2008 at 04:39:11PM -0400, Wendy Cheng wrote: > >> #if defined(BRUCE_CHECK_THIS_OUT) >> error = nlmsvc_failover_path(nd.path.mnt->mnt_sb); >> #else >> error = nlmsvc_failover_path(nd.mnt->mnt_sb); >> #endif >> > > The vfsmount and dentry got moved into the path argument sometime in the > last kernel version or so. Is there a macro defining the latter as a > shortcut for the former? I didn't see one. > > > Sorry, just realized my kernel is too old (2.6.25) .. It would be cumbersome for me to test RHCS with newer kernels. Linux is really a moving target :( .... Anyway, will think of something else to test this out.. -- Wendy ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] lockd: unlock lockd locks held for a certain filesystem 2008-04-23 21:17 ` Wendy Cheng @ 2008-04-23 21:39 ` J. Bruce Fields 2008-04-23 21:44 ` Wendy Cheng 0 siblings, 1 reply; 21+ messages in thread From: J. Bruce Fields @ 2008-04-23 21:39 UTC (permalink / raw) To: Wendy Cheng; +Cc: Christoph Hellwig, nfs, linux-nfs, Lon Hohberger On Wed, Apr 23, 2008 at 05:17:29PM -0400, Wendy Cheng wrote: > J. Bruce Fields wrote: >> On Wed, Apr 23, 2008 at 04:39:11PM -0400, Wendy Cheng wrote: >> >>> #if defined(BRUCE_CHECK_THIS_OUT) >>> error = nlmsvc_failover_path(nd.path.mnt->mnt_sb); >>> #else >>> error = nlmsvc_failover_path(nd.mnt->mnt_sb); >>> #endif >>> >> >> The vfsmount and dentry got moved into the path argument sometime in the >> last kernel version or so. Is there a macro defining the latter as a >> shortcut for the former? I didn't see one. >> >> >> > Sorry, just realized my kernel is too old (2.6.25) 2.6.25 is'nt that old quite yet! OK, I get the idea, anyway. > .. It would be > cumbersome for me to test RHCS with newer kernels. Linux is really a > moving target :( .... > > Anyway, will think of something else to test this out.. OK, thanks. I did some very basic tests, and I'm not terribly worried about it; at worst, it's unlikely to break anything that's already working. But let me know what you find out. I've sent off my merge request for 2.6.26, but I may try to bundle this up with a few smaller patches I think I've missed and submit another request before the weekend. --b. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] lockd: unlock lockd locks held for a certain filesystem 2008-04-23 21:39 ` J. Bruce Fields @ 2008-04-23 21:44 ` Wendy Cheng 0 siblings, 0 replies; 21+ messages in thread From: Wendy Cheng @ 2008-04-23 21:44 UTC (permalink / raw) To: J. Bruce Fields; +Cc: Christoph Hellwig, nfs, linux-nfs, Lon Hohberger J. Bruce Fields wrote: > On Wed, Apr 23, 2008 at 05:17:29PM -0400, Wendy Cheng wrote: > >> J. Bruce Fields wrote: >> >>> On Wed, Apr 23, 2008 at 04:39:11PM -0400, Wendy Cheng wrote: >>> >>> >>>> #if defined(BRUCE_CHECK_THIS_OUT) >>>> error = nlmsvc_failover_path(nd.path.mnt->mnt_sb); >>>> #else >>>> error = nlmsvc_failover_path(nd.mnt->mnt_sb); >>>> #endif >>>> >>>> >>> The vfsmount and dentry got moved into the path argument sometime in the >>> last kernel version or so. Is there a macro defining the latter as a >>> shortcut for the former? I didn't see one. >>> >>> >>> >>> >> Sorry, just realized my kernel is too old (2.6.25) >> > > 2.6.25 is'nt that old quite yet! OK, I get the idea, anyway. > > >> .. It would be >> cumbersome for me to test RHCS with newer kernels. Linux is really a >> moving target :( .... >> >> Anyway, will think of something else to test this out.. >> > > OK, thanks. I did some very basic tests, and I'm not terribly worried > about it; at worst, it's unlikely to break anything that's already > working. But let me know what you find out. > > I've sent off my merge request for 2.6.26, but I may try to bundle this > up with a few smaller patches I think I've missed and submit another > request before the weekend. > Please do .. this has been going on for more than two years .. it would be ridiculous to put it off any longer. I'll see what I can do here to help out. -- Wendy ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2008-04-23 21:42 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-16 9:17 [NFS] Forcefully resetting a lock Erik Hensema / HostingXS Internet Services
[not found] ` <200804161117.24734.hensema-yolSOB3tinz/D1n+0JDH9g@public.gmane.org>
2008-04-16 11:44 ` Jeff Layton
2008-04-16 15:15 ` Wendy Cheng
2008-04-16 18:42 ` J. Bruce Fields
2008-04-16 19:39 ` Wendy Cheng
2008-04-17 21:52 ` J. Bruce Fields
2008-04-18 14:02 ` Wendy Cheng
2008-04-18 18:19 ` J. Bruce Fields
2008-04-22 23:15 ` J. Bruce Fields
2008-04-22 23:17 ` [NFS] [PATCH] lockd: unlock lockd locks associated with a given server ip J. Bruce Fields
2008-04-22 23:18 ` [NFS] [PATCH] lockd: unlock lockd locks held for a certain filesystem J. Bruce Fields
2008-04-23 2:57 ` Wendy Cheng
2008-04-23 7:44 ` Christoph Hellwig
2008-04-23 17:12 ` J. Bruce Fields
2008-04-23 17:52 ` Christoph Hellwig
2008-04-23 20:01 ` J. Bruce Fields
2008-04-23 20:39 ` Wendy Cheng
2008-04-23 21:02 ` J. Bruce Fields
2008-04-23 21:17 ` Wendy Cheng
2008-04-23 21:39 ` J. Bruce Fields
2008-04-23 21:44 ` Wendy Cheng
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.