Skip to content

Commit 46be7b7

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
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
2 parents 81770f4 + 0f23ae7 commit 46be7b7

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

fs/btrfs/btrfs_inode.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,17 @@ static inline int btrfs_inode_in_log(struct inode *inode, u64 generation)
234234
BTRFS_I(inode)->last_sub_trans <=
235235
BTRFS_I(inode)->last_log_commit &&
236236
BTRFS_I(inode)->last_sub_trans <=
237-
BTRFS_I(inode)->root->last_log_commit)
238-
return 1;
237+
BTRFS_I(inode)->root->last_log_commit) {
238+
/*
239+
* After a ranged fsync we might have left some extent maps
240+
* (that fall outside the fsync's range). So return false
241+
* here if the list isn't empty, to make sure btrfs_log_inode()
242+
* will be called and process those extent maps.
243+
*/
244+
smp_mb();
245+
if (list_empty(&BTRFS_I(inode)->extent_tree.modified_extents))
246+
return 1;
247+
}
239248
return 0;
240249
}
241250

fs/btrfs/tree-log.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4093,18 +4093,8 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
40934093
}
40944094
}
40954095

4096-
write_lock(&em_tree->lock);
4097-
/*
4098-
* If we're doing a ranged fsync and there are still modified extents
4099-
* in the list, we must run on the next fsync call as it might cover
4100-
* those extents (a full fsync or an fsync for other range).
4101-
*/
4102-
if (list_empty(&em_tree->modified_extents)) {
4103-
BTRFS_I(inode)->logged_trans = trans->transid;
4104-
BTRFS_I(inode)->last_log_commit =
4105-
BTRFS_I(inode)->last_sub_trans;
4106-
}
4107-
write_unlock(&em_tree->lock);
4096+
BTRFS_I(inode)->logged_trans = trans->transid;
4097+
BTRFS_I(inode)->last_log_commit = BTRFS_I(inode)->last_sub_trans;
41084098
out_unlock:
41094099
if (unlikely(err))
41104100
btrfs_put_logged_extents(&logged_list);

fs/btrfs/volumes.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -529,21 +529,20 @@ static noinline int device_list_add(const char *path,
529529
*/
530530

531531
/*
532-
* As of now don't allow update to btrfs_fs_device through
533-
* the btrfs dev scan cli, after FS has been mounted.
532+
* For now, we do allow update to btrfs_fs_device through the
533+
* btrfs dev scan cli after FS has been mounted. We're still
534+
* tracking a problem where systems fail mount by subvolume id
535+
* when we reject replacement on a mounted FS.
534536
*/
535-
if (fs_devices->opened) {
536-
return -EBUSY;
537-
} else {
537+
if (!fs_devices->opened && found_transid < device->generation) {
538538
/*
539539
* That is if the FS is _not_ mounted and if you
540540
* are here, that means there is more than one
541541
* disk with same uuid and devid.We keep the one
542542
* with larger generation number or the last-in if
543543
* generation are equal.
544544
*/
545-
if (found_transid < device->generation)
546-
return -EEXIST;
545+
return -EEXIST;
547546
}
548547

549548
name = rcu_string_strdup(path, GFP_NOFS);

0 commit comments

Comments
 (0)