Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 19 Sep 2014 20:10:53 +0000 (13:10 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 19 Sep 2014 20:10:53 +0000 (13:10 -0700)
Pull btrfs fixes from Chris Mason:
 "I've got a revert to fix a regression with btrfs device registration,
  and Filipe has part two of his fsync fix from last week"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  Revert "Btrfs: device_list_add() should not update list when mounted"
  Btrfs: set inode's logged_trans/last_log_commit after ranged fsync

fs/btrfs/btrfs_inode.h
fs/btrfs/tree-log.c
fs/btrfs/volumes.c

index 43527fd78825b690503347426118e09f76017c95..56b8522d5767b5858928d4152c0ab64ca43886ca 100644 (file)
@@ -234,8 +234,17 @@ static inline int btrfs_inode_in_log(struct inode *inode, u64 generation)
            BTRFS_I(inode)->last_sub_trans <=
            BTRFS_I(inode)->last_log_commit &&
            BTRFS_I(inode)->last_sub_trans <=
-           BTRFS_I(inode)->root->last_log_commit)
-               return 1;
+           BTRFS_I(inode)->root->last_log_commit) {
+               /*
+                * After a ranged fsync we might have left some extent maps
+                * (that fall outside the fsync's range). So return false
+                * here if the list isn't empty, to make sure btrfs_log_inode()
+                * will be called and process those extent maps.
+                */
+               smp_mb();
+               if (list_empty(&BTRFS_I(inode)->extent_tree.modified_extents))
+                       return 1;
+       }
        return 0;
 }
 
index d296efe2d3e76ce4f690687a9647cf7f8c71a27f..1d1ba083ca6ecc1497bd1c141a431a2d5fa26cd9 100644 (file)
@@ -4093,18 +4093,8 @@ log_extents:
                }
        }
 
-       write_lock(&em_tree->lock);
-       /*
-        * If we're doing a ranged fsync and there are still modified extents
-        * in the list, we must run on the next fsync call as it might cover
-        * those extents (a full fsync or an fsync for other range).
-        */
-       if (list_empty(&em_tree->modified_extents)) {
-               BTRFS_I(inode)->logged_trans = trans->transid;
-               BTRFS_I(inode)->last_log_commit =
-                       BTRFS_I(inode)->last_sub_trans;
-       }
-       write_unlock(&em_tree->lock);
+       BTRFS_I(inode)->logged_trans = trans->transid;
+       BTRFS_I(inode)->last_log_commit = BTRFS_I(inode)->last_sub_trans;
 out_unlock:
        if (unlikely(err))
                btrfs_put_logged_extents(&logged_list);
index 340a92d08e84d9e5268a18fe5f3112465fa47888..2c2d6d1d8eee929fc910a82cd17fbec79803cbb2 100644 (file)
@@ -529,12 +529,12 @@ static noinline int device_list_add(const char *path,
                 */
 
                /*
-                * As of now don't allow update to btrfs_fs_device through
-                * the btrfs dev scan cli, after FS has been mounted.
+                * For now, we do allow update to btrfs_fs_device through the
+                * btrfs dev scan cli after FS has been mounted.  We're still
+                * tracking a problem where systems fail mount by subvolume id
+                * when we reject replacement on a mounted FS.
                 */
-               if (fs_devices->opened) {
-                       return -EBUSY;
-               } else {
+               if (!fs_devices->opened && found_transid < device->generation) {
                        /*
                         * That is if the FS is _not_ mounted and if you
                         * are here, that means there is more than one
@@ -542,8 +542,7 @@ static noinline int device_list_add(const char *path,
                         * with larger generation number or the last-in if
                         * generation are equal.
                         */
-                       if (found_transid < device->generation)
-                               return -EEXIST;
+                       return -EEXIST;
                }
 
                name = rcu_string_strdup(path, GFP_NOFS);