Whamcloud - gitweb
b=22911 Fix incompatibilies between ext4 and ext3 based ldiskfs
[fs/lustre-release.git] / lustre / lvfs / fsfilt_ext3.c
index bde0093..d2e4c18 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -622,9 +622,21 @@ static int fsfilt_ext3_iocontrol(struct inode *inode, struct file *file,
         ENTRY;
 
         /* FIXME: Can't do this because of nested transaction deadlock */
-        if (cmd == EXT3_IOC_SETFLAGS && (*(int *)arg) & EXT3_JOURNAL_DATA_FL) {
-                CERROR("can't set data journal flag on file\n");
-                RETURN(-EPERM);
+        if (cmd == EXT3_IOC_SETFLAGS) {
+                /* We can't enable data journaling on OST objects, because
+                * this forces the transaction to be closed in order to
+                * flush the journal, but the caller will already have a
+                * compound transaction open to update the last_rcvd file,
+                * and this thread would deadlock trying to set the flag. */
+                if ((*(int *)arg) & EXT3_JOURNAL_DATA_FL) {
+                        CERROR("can't set data journal flag on file\n");
+                        RETURN(-EPERM);
+                }
+                /* Because the MDS does not see the EXTENTS_FL set on the
+                 * OST objects, mask this flag into all set flags.  It is
+                 * not legal to clear this flag in any case, so we are not
+                 * changing the functionality by doing this.  b=22911 */
+                *(int *)arg |= EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL;
         }
 
 #ifdef HAVE_EXT4_LDISKFS
@@ -2219,6 +2231,12 @@ ssize_t lustre_read_quota(struct file *f, struct inode *inode, int type,
         loff_t p = pos;
         int rc;
 
+        if (!f && !inode) {
+                CERROR("lustre_read_quota failed for no quota file!\n");
+                libcfs_debug_dumpstack(NULL);
+                return -EINVAL;
+        }
+
         /* Support for both adm and op quota files must be provided */
         if (f) {
                 rc = fsfilt_ext3_read_record(f, buf, count, &p);