From 5603bc2c750e311542dd2d7293176333ab2ed651 Mon Sep 17 00:00:00 2001 From: green <green> Date: Wed, 16 May 2007 20:43:02 +0000 Subject: [PATCH] b=11563 r=adilger,nathan Add -o localflock option to simulate old noflock behaviour. --- lustre/ChangeLog | 8 ++++++++ lustre/llite/file.c | 23 +++++++++++++++++++---- lustre/llite/llite_internal.h | 2 ++ lustre/llite/llite_lib.c | 11 +++++++++-- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index c9682652e0..62841646c0 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -102,6 +102,14 @@ Details : in some rare cases it was possible for a client to connect to an MDS multiple times. Upon recovery the MDS would detect this and fail during startup. Handle this more gracefully. +Severity : enhancement +Bugzilla : 11563 +Description: Add -o localflock option to simulate old noflock +behaviour. +Details : This will achieve local-only flock/fcntl locks + coherentness. + + -------------------------------------------------------------------------------- 2007-05-03 Cluster File Systems, Inc. <info@clusterfs.com> diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 84c9b06566..947654f66c 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2612,6 +2612,7 @@ check_capabilities: } #endif +/* -o localflock - only provides locally consistent flock locks */ struct file_operations ll_file_operations = { .read = ll_file_read, .write = ll_file_write, @@ -2624,10 +2625,6 @@ struct file_operations ll_file_operations = { .sendfile = ll_file_sendfile, #endif .fsync = ll_fsync, -#ifdef HAVE_F_OP_FLOCK - .flock = ll_file_noflock, -#endif - .lock = ll_file_noflock }; struct file_operations ll_file_operations_flock = { @@ -2648,6 +2645,24 @@ struct file_operations ll_file_operations_flock = { .lock = ll_file_flock }; +/* These are for -o noflock - to return ENOSYS on flock calls */ +struct file_operations ll_file_operations_noflock = { + .read = ll_file_read, + .write = ll_file_write, + .ioctl = ll_file_ioctl, + .open = ll_file_open, + .release = ll_file_release, + .mmap = ll_file_mmap, + .llseek = ll_file_seek, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) + .sendfile = ll_file_sendfile, +#endif + .fsync = ll_fsync, +#ifdef HAVE_F_OP_FLOCK + .flock = ll_file_noflock, +#endif + .lock = ll_file_noflock +}; struct inode_operations ll_file_inode_operations = { #ifdef LUSTRE_KERNEL_VERSION diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 0d3e52bc52..9303e96d44 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -225,6 +225,7 @@ enum vfs_track_type { #define LL_SBI_USER_XATTR 0x08 /* support user xattr */ #define LL_SBI_ACL 0x10 /* support ACL */ #define LL_SBI_JOIN 0x20 /* support JOIN */ +#define LL_SBI_LOCALFLOCK 0x40 /* Local flocks support by kernel */ struct ll_sb_info { struct list_head ll_list; @@ -484,6 +485,7 @@ int ll_sync_page_range(struct inode *, struct address_space *, loff_t, size_t); /* llite/file.c */ extern struct file_operations ll_file_operations; extern struct file_operations ll_file_operations_flock; +extern struct file_operations ll_file_operations_noflock; extern struct inode_operations ll_file_inode_operations; extern int ll_inode_revalidate_it(struct dentry *, struct lookup_intent *); extern int ll_have_md_lock(struct inode *inode, __u64 bits); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 872fafddf0..0671d57207 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -170,8 +170,10 @@ static int client_common_fill_super(struct super_block *sb, if (sbi->ll_flags & LL_SBI_FLOCK) sbi->ll_fop = &ll_file_operations_flock; - else + else if (sbi->ll_flags & LL_SBI_LOCALFLOCK) sbi->ll_fop = &ll_file_operations; + else + sbi->ll_fop = &ll_file_operations_noflock; err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, data); if (err == -EBUSY) { @@ -631,7 +633,12 @@ static int ll_options(char *options, int *flags) *flags |= tmp; goto next; } - tmp = ll_set_opt("noflock", s1, LL_SBI_FLOCK); + tmp = ll_set_opt("localflock", s1, LL_SBI_LOCALFLOCK); + if (tmp) { + *flags |= tmp; + goto next; + } + tmp = ll_set_opt("noflock", s1, LL_SBI_FLOCK|LL_SBI_LOCALFLOCK); if (tmp) { *flags &= ~tmp; goto next; -- GitLab