Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[patch 9/9] fuse: lockd support

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


miklos at szeredi

May 9, 2008, 5:41 AM

Post #1 of 2 (53 views)
Permalink
[patch 9/9] fuse: lockd support

From: Miklos Szeredi <mszeredi[at]suse.cz>

If fuse filesystem doesn't define it's own lock operations, then allow
the lock manager to work with fuse.

Adding lockd support for remote locking is also possible, but more
difficult, because of the need handle lock cancellation. It's also
rarely used, so leave it till later.

Signed-off-by: Miklos Szeredi <mszeredi[at]suse.cz>
---
fs/fuse/file.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

Index: linux-2.6/fs/fuse/file.c
===================================================================
--- linux-2.6.orig/fs/fuse/file.c 2008-05-09 14:04:45.000000000 +0200
+++ linux-2.6/fs/fuse/file.c 2008-05-09 14:04:52.000000000 +0200
@@ -1341,6 +1341,11 @@ static int fuse_setlk(struct file *file,
pid_t pid = fl->fl_type != F_UNLCK ? current->tgid : 0;
int err;

+ if (fl->fl_lmops && fl->fl_lmops->fl_grant) {
+ /* NLM needs asynchronous locks, which we don't support yet */
+ return -ENOLCK;
+ }
+
/* Unlock on close is handled by the flush method */
if (fl->fl_flags & FL_CLOSE)
return 0;
@@ -1365,7 +1370,9 @@ static int fuse_file_lock(struct file *f
struct fuse_conn *fc = get_fuse_conn(inode);
int err;

- if (cmd == F_GETLK) {
+ if (cmd == F_CANCELLK) {
+ err = 0;
+ } else if (cmd == F_GETLK) {
if (fc->no_lock) {
posix_test_lock(file, fl);
err = 0;
@@ -1373,7 +1380,7 @@ static int fuse_file_lock(struct file *f
err = fuse_getlk(file, fl);
} else {
if (fc->no_lock)
- err = posix_lock_file_wait(file, fl);
+ err = posix_lock_file(file, fl, NULL);
else
err = fuse_setlk(file, fl, 0);
}

--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo[at]vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


miklos at szeredi

May 15, 2008, 12:50 PM

Post #2 of 2 (36 views)
Permalink
[patch 9/9] fuse: lockd support [In reply to]

From: Miklos Szeredi <mszeredi[at]suse.cz>

If fuse filesystem doesn't define it's own lock operations, then allow
the lock manager to work with fuse.

Adding lockd support for remote locking is also possible, but more
difficult, because of the need handle lock cancellation. It's also
rarely used, so leave it till later.

Signed-off-by: Miklos Szeredi <mszeredi[at]suse.cz>
---
fs/fuse/file.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

Index: linux-2.6/fs/fuse/file.c
===================================================================
--- linux-2.6.orig/fs/fuse/file.c 2008-05-09 14:04:45.000000000 +0200
+++ linux-2.6/fs/fuse/file.c 2008-05-09 14:04:52.000000000 +0200
@@ -1341,6 +1341,11 @@ static int fuse_setlk(struct file *file,
pid_t pid = fl->fl_type != F_UNLCK ? current->tgid : 0;
int err;

+ if (fl->fl_lmops && fl->fl_lmops->fl_grant) {
+ /* NLM needs asynchronous locks, which we don't support yet */
+ return -ENOLCK;
+ }
+
/* Unlock on close is handled by the flush method */
if (fl->fl_flags & FL_CLOSE)
return 0;
@@ -1365,7 +1370,9 @@ static int fuse_file_lock(struct file *f
struct fuse_conn *fc = get_fuse_conn(inode);
int err;

- if (cmd == F_GETLK) {
+ if (cmd == F_CANCELLK) {
+ err = 0;
+ } else if (cmd == F_GETLK) {
if (fc->no_lock) {
posix_test_lock(file, fl);
err = 0;
@@ -1373,7 +1380,7 @@ static int fuse_file_lock(struct file *f
err = fuse_getlk(file, fl);
} else {
if (fc->no_lock)
- err = posix_lock_file_wait(file, fl);
+ err = posix_lock_file(file, fl, NULL);
else
err = fuse_setlk(file, fl, 0);
}

--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo[at]vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.