gfs2: add nfslocks mount option
PATCH 1/1 gfs2: add nfslocks mount option
Using the nfslocks mount option causes gfs2 to pass posix locks from nfs to the dlm to be clustered. It is off by default because posix locks from nfs are not fully handled by the cluster.
Signed-off-by David Teigland <[email protected]>
--- fs/gfs2/file.c | 11 +++++++++++ fs/gfs2/incore.h | 1 + fs/gfs2/super.c | 13 +++++++++++++ 3 files changed, 25 insertions(+), 0 deletions(-)
fs/gfs2/file.c +11 -0
@@ -650,6 +650,17 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) }if (unlikely (test_bit (SDF_SHUTDOWN , &sdp->sd_flags)))return -EIO ; + +if (fl->fl_lmops && fl->fl_lmops->fl_grant && + !sdp->sd_args.ar_nfslocks) { +if (IS_GETLK (cmd)) { +posix_test_lock (file, fl); +return 0 ; + }else { +return posix_lock_file_wait (file, fl); + } + } +if (IS_GETLK (cmd))return dlm_posix_get (ls->ls_dlm, ip->i_no_addr, file, fl);else if (fl->fl_type ==F_UNLCK )
fs/gfs2/incore.h +1 -0
@@ -430,6 +430,7 @@ struct gfs2_args { unsigned int ar_discard:1; /* discard requests */ unsigned int ar_errors:2; /* errors=withdraw | panic */ unsigned int ar_nobarrier:1; /* do not send barriers */ + unsigned int ar_nfslocks:1; /* pass nfs plocks to dlm */int ar_commit;/* Commit interval */ int ar_statfs_quantum;/* The fast statfs interval */ int ar_quota_quantum;/* The quota interval */
fs/gfs2/super.c +13 -0
@@ -77,6 +77,8 @@ enum { Opt_quota_quantum, Opt_barrier, Opt_nobarrier, + Opt_nfslocks, + Opt_nonfslocks, Opt_error, };
@@ -113,6 +115,8 @@ static const match_table_t tokens = { {Opt_quota_quantum, "quota_quantum=%d"}, {Opt_barrier, "barrier"}, {Opt_nobarrier, "nobarrier"}, + {Opt_nfslocks, "nfslocks"}, + {Opt_nonfslocks, "nonfslocks"}, {Opt_error, NULL} };
@@ -265,6 +269,12 @@ int gfs2_mount_args(struct gfs2_args *args, char *options)case Opt_nobarrier: args->ar_nobarrier =1 ;break ; +case Opt_nfslocks: + args->ar_nfslocks =1 ; +break ; +case Opt_nonfslocks: + args->ar_nfslocks =0 ; +break ;case Opt_error:default :printk (KERN_WARNING "GFS2: invalid mount option: %s\n" , o);
@@ -1135,6 +1145,7 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)args_neq (&args, &sdp->sd_args, ignore_local_fs) ||args_neq (&args, &sdp->sd_args, localflocks) ||args_neq (&args, &sdp->sd_args, localcaching) || +args_neq (&args, &sdp->sd_args, nfslocks) || args_neq(&args, &sdp->sd_args, meta)) return -EINVAL;
@@ -1262,6 +1273,8 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)seq_printf (s,",localflocks" );if (args->ar_localcaching)seq_printf (s,",localcaching" ); +if (args->ar_nfslocks) +seq_printf (s,",nfslocks" );if (args->ar_debug)seq_printf (s,",debug" );if (args->ar_upgrade)
Signature · 1 line
1.6.6
PATCH 1/1 gfs2: add nfslocks mount option
Hi,
The code is ok, but I'm not intending to take this at least until I can figure out why it is needed. I can't see any use case in which it would be useful at the moment,
Steve.
Quoted 97 lines · David Teigland
Using the nfslocks mount option causes gfs2 to pass posix locks from nfs to the dlm to be clustered. It is off by default because posix locks from nfs are not fully handled by the cluster.
Signed-off-by David Teigland <[email protected]>--- fs/gfs2/file.c | 11 +++++++++++ fs/gfs2/incore.h | 1 + fs/gfs2/super.c | 13 +++++++++++++ 3 files changed, 25 insertions(+), 0 deletions(-)fs/gfs2/file.c +11
-0@@ -650,6 +650,17 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) }if (unlikely (test_bit (SDF_SHUTDOWN , &sdp->sd_flags)))return -EIO ; + +if (fl->fl_lmops && fl->fl_lmops->fl_grant && + !sdp->sd_args.ar_nfslocks) { +if (IS_GETLK (cmd)) { +posix_test_lock (file, fl); +return 0 ; + }else { +return posix_lock_file_wait (file, fl); + } + } +if (IS_GETLK (cmd))return dlm_posix_get (ls->ls_dlm, ip->i_no_addr, file, fl);else if (fl->fl_type ==F_UNLCK )fs/gfs2/incore.h +1
-0@@ -430,6 +430,7 @@ struct gfs2_args { unsigned int ar_discard:1; /* discard requests */ unsigned int ar_errors:2; /* errors=withdraw | panic */ unsigned int ar_nobarrier:1; /* do not send barriers */ + unsigned int ar_nfslocks:1; /* pass nfs plocks to dlm */int ar_commit;/* Commit interval */ int ar_statfs_quantum;/* The fast statfs interval */ int ar_quota_quantum;/* The quota interval */ fs/gfs2/super.c +13
-0@@ -77,6 +77,8 @@ enum { Opt_quota_quantum, Opt_barrier, Opt_nobarrier, + Opt_nfslocks, + Opt_nonfslocks, Opt_error, };@@ -113,6 +115,8 @@ static const match_table_t tokens = { {Opt_quota_quantum, "quota_quantum=%d"}, {Opt_barrier, "barrier"}, {Opt_nobarrier, "nobarrier"}, + {Opt_nfslocks, "nfslocks"}, + {Opt_nonfslocks, "nonfslocks"}, {Opt_error, NULL} };@@ -265,6 +269,12 @@ int gfs2_mount_args(struct gfs2_args *args, char *options)case Opt_nobarrier: args->ar_nobarrier =1 ;break ; +case Opt_nfslocks: + args->ar_nfslocks =1 ; +break ; +case Opt_nonfslocks: + args->ar_nfslocks =0 ; +break ;case Opt_error:default :printk (KERN_WARNING "GFS2: invalid mount option: %s\n" , o);@@ -1135,6 +1145,7 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)args_neq (&args, &sdp->sd_args, ignore_local_fs) ||args_neq (&args, &sdp->sd_args, localflocks) ||args_neq (&args, &sdp->sd_args, localcaching) || +args_neq (&args, &sdp->sd_args, nfslocks) || args_neq(&args, &sdp->sd_args, meta)) return -EINVAL;@@ -1262,6 +1273,8 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)seq_printf (s,",localflocks" );if (args->ar_localcaching)seq_printf (s,",localcaching" ); +if (args->ar_nfslocks) +seq_printf (s,",nfslocks" );if (args->ar_debug)seq_printf (s,",debug" );if (args->ar_upgrade)