Whamcloud - gitweb
b=11563
authorgreen <green>
Wed, 16 May 2007 20:43:02 +0000 (20:43 +0000)
committergreen <green>
Wed, 16 May 2007 20:43:02 +0000 (20:43 +0000)
r=adilger,nathan

Add -o localflock option to simulate  old noflock behaviour.

lustre/ChangeLog
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c

index c968265..6284164 100644 (file)
@@ -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>
index 84c9b06..947654f 100644 (file)
@@ -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
index 0d3e52b..9303e96 100644 (file)
@@ -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);
index 872fafd..0671d57 100644 (file)
@@ -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;