History

Merge branch 'for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs

Pull btrfs fixes from Chris Mason: "A couple of small fixes" * 'for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: Btrfs: check prepare_uptodate_page() error code earlier Btrfs: check for empty bitmap list in setup_cluster_bitmaps btrfs: fix misleading warning when space cache failed to load Btrfs: fix transaction handle leak in balance Btrfs: fix unprotected list move from unused_bgs to deleted_bgs list

Linus Torvalds committed 10 years ago

Commit fc315e32 parents 8b4414f 1d3a5a86 files · +29 −15Browse files

Unified · Split

6 files
  1. fs/btrfs/extent-tree.c +7 −3
  2. fs/btrfs/file.c +14 −4
  3. fs/btrfs/free-space-cache.c +6 −4
  4. fs/btrfs/transaction.c +0 −1
  5. fs/btrfs/transaction.h +1 −1
  6. fs/btrfs/volumes.c +1 −2
fs/btrfs/extent-tree.c+7−3
@@ -10480,11 +10480,15 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info) · 10479 unmodified lines
1048010480 * until transaction commit to do the actual discard.
1048110481 */
1048210482 if (trimming) {
10483− WARN_ON(!list_empty(&block_group->bg_list));
10484− spin_lock(&trans->transaction->deleted_bgs_lock);
10483+ spin_lock(&fs_info->unused_bgs_lock);
10484+ /*
10485+ * A concurrent scrub might have added us to the list
10486+ * fs_info->unused_bgs, so use a list_move operation
10487+ * to add the block group to the deleted_bgs list.
10488+ */
1048510489 list_move(&block_group->bg_list,
1048610490 &trans->transaction->deleted_bgs);
10487− spin_unlock(&trans->transaction->deleted_bgs_lock);
10491+ spin_unlock(&fs_info->unused_bgs_lock);
1048810492 btrfs_get_block_group(block_group);
1048910493 }
1049010494 end_trans:
fs/btrfs/file.c+14−4
@@ -1291,7 +1291,8 @@ out: · 1290 unmodified lines
12911291 * on error we return an unlocked page and the error value
12921292 * on success we return a locked page and 0
12931293 */
1294−static int prepare_uptodate_page(struct page *page, u64 pos,
1294+static int prepare_uptodate_page(struct inode *inode,
1295+ struct page *page, u64 pos,
12951296 bool force_uptodate)
12961297 {
12971298 int ret = 0;
@@ -1306,6 +1307,10 @@ static int prepare_uptodate_page(struct page *page, u64 pos, · 8 unmodified lines
13061307 unlock_page(page);
13071308 return -EIO;
13081309 }
1310+ if (page->mapping != inode->i_mapping) {
1311+ unlock_page(page);
1312+ return -EAGAIN;
1313+ }
13091314 }
13101315 return 0;
13111316 }
@@ -1324,6 +1329,7 @@ static noinline int prepare_pages(struct inode *inode, struct page **pages, · 12 unmodified lines
13241329 int faili;
13251330
13261331 for (i = 0; i < num_pages; i++) {
1332+again:
13271333 pages[i] = find_or_create_page(inode->i_mapping, index + i,
13281334 mask | __GFP_WRITE);
13291335 if (!pages[i]) {
@@ -1333,13 +1339,17 @@ static noinline int prepare_pages(struct inode *inode, struct page **pages, · 3 unmodified lines
13331339 }
13341340
13351341 if (i == 0)
1336− err = prepare_uptodate_page(pages[i], pos,
1342+ err = prepare_uptodate_page(inode, pages[i], pos,
13371343 force_uptodate);
1338− if (i == num_pages - 1)
1339− err = prepare_uptodate_page(pages[i],
1344+ if (!err && i == num_pages - 1)
1345+ err = prepare_uptodate_page(inode, pages[i],
13401346 pos + write_bytes, false);
13411347 if (err) {
13421348 page_cache_release(pages[i]);
1349+ if (err == -EAGAIN) {
1350+ err = 0;
1351+ goto again;
1352+ }
13431353 faili = i - 1;
13441354 goto fail;
13451355 }
fs/btrfs/free-space-cache.c+6−4
@@ -891,7 +891,7 @@ out: · 890 unmodified lines
891891 spin_unlock(&block_group->lock);
892892 ret = 0;
893893
894− btrfs_warn(fs_info, "failed to load free space cache for block group %llu, rebuild it now",
894+ btrfs_warn(fs_info, "failed to load free space cache for block group %llu, rebuilding it now",
895895 block_group->key.objectid);
896896 }
897897
@@ -2972,7 +2972,7 @@ setup_cluster_bitmap(struct btrfs_block_group_cache *block_group, · 2074 unmodified lines
29722972 u64 cont1_bytes, u64 min_bytes)
29732973 {
29742974 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
2975− struct btrfs_free_space *entry;
2975+ struct btrfs_free_space *entry = NULL;
29762976 int ret = -ENOSPC;
29772977 u64 bitmap_offset = offset_to_bitmap(ctl, offset);
29782978
@@ -2983,8 +2983,10 @@ setup_cluster_bitmap(struct btrfs_block_group_cache *block_group, · 4 unmodified lines
29832983 * The bitmap that covers offset won't be in the list unless offset
29842984 * is just its start offset.
29852985 */
2986− entry = list_first_entry(bitmaps, struct btrfs_free_space, list);
2987− if (entry->offset != bitmap_offset) {
2986+ if (!list_empty(bitmaps))
2987+ entry = list_first_entry(bitmaps, struct btrfs_free_space, list);
2988+
2989+ if (!entry || entry->offset != bitmap_offset) {
29882990 entry = tree_search_offset(ctl, bitmap_offset, 1, 0);
29892991 if (entry && list_empty(&entry->list))
29902992 list_add(&entry->list, bitmaps);
fs/btrfs/transaction.c+0−1
@@ -274,7 +274,6 @@ loop: · 273 unmodified lines
274274 cur_trans->num_dirty_bgs = 0;
275275 spin_lock_init(&cur_trans->dirty_bgs_lock);
276276 INIT_LIST_HEAD(&cur_trans->deleted_bgs);
277− spin_lock_init(&cur_trans->deleted_bgs_lock);
278277 spin_lock_init(&cur_trans->dropped_roots_lock);
279278 list_add_tail(&cur_trans->list, &fs_info->trans_list);
280279 extent_io_tree_init(&cur_trans->dirty_pages,
fs/btrfs/transaction.h+1−1
@@ -77,8 +77,8 @@ struct btrfs_transaction { · 76 unmodified lines
7777 */
7878 struct mutex cache_write_mutex;
7979 spinlock_t dirty_bgs_lock;
80+ /* Protected by spin lock fs_info->unused_bgs_lock. */
8081 struct list_head deleted_bgs;
81− spinlock_t deleted_bgs_lock;
8282 spinlock_t dropped_roots_lock;
8383 struct btrfs_delayed_ref_root delayed_refs;
8484 int aborted;
fs/btrfs/volumes.c+1−2
@@ -3548,12 +3548,11 @@ again: · 3547 unmodified lines
35483548
35493549 ret = btrfs_force_chunk_alloc(trans, chunk_root,
35503550 BTRFS_BLOCK_GROUP_DATA);
3551+ btrfs_end_transaction(trans, chunk_root);
35513552 if (ret < 0) {
35523553 mutex_unlock(&fs_info->delete_unused_bgs_mutex);
35533554 goto error;
35543555 }
3555−
3556− btrfs_end_transaction(trans, chunk_root);
35573556 chunk_reserved = 1;
35583557 }
35593558

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t