Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NTFS: Fix page_has_buffers()/page_buffers() handling in fs/ntfs/aops.c.

Signed-off-by: Anton Altaparmakov <aia21@cantab.net>

+22 -17
+1
fs/ntfs/ChangeLog
··· 85 85 removal of the get_bh()/put_bh() pairs for each buffer. 86 86 - Fix fs/ntfs/aops.c::ntfs_{read,write}_block() to handle the case 87 87 where a concurrent truncate has truncated the runlist under our feet. 88 + - Fix page_has_buffers()/page_buffers() handling in fs/ntfs/aops.c. 88 89 89 90 2.1.23 - Implement extension of resident files and make writing safe as well as 90 91 many bug fixes, cleanups, and enhancements...
+21 -17
fs/ntfs/aops.c
··· 185 185 blocksize_bits = VFS_I(ni)->i_blkbits; 186 186 blocksize = 1 << blocksize_bits; 187 187 188 - if (!page_has_buffers(page)) 188 + if (!page_has_buffers(page)) { 189 189 create_empty_buffers(page, blocksize, 0); 190 - bh = head = page_buffers(page); 191 - if (unlikely(!bh)) { 192 - unlock_page(page); 193 - return -ENOMEM; 190 + if (unlikely(!page_has_buffers(page))) { 191 + unlock_page(page); 192 + return -ENOMEM; 193 + } 194 194 } 195 + bh = head = page_buffers(page); 196 + BUG_ON(!bh); 195 197 196 198 iblock = (s64)page->index << (PAGE_CACHE_SHIFT - blocksize_bits); 197 199 read_lock_irqsave(&ni->size_lock, flags); ··· 532 530 BUG_ON(!PageUptodate(page)); 533 531 create_empty_buffers(page, blocksize, 534 532 (1 << BH_Uptodate) | (1 << BH_Dirty)); 533 + if (unlikely(!page_has_buffers(page))) { 534 + ntfs_warning(vol->sb, "Error allocating page " 535 + "buffers. Redirtying page so we try " 536 + "again later."); 537 + /* 538 + * Put the page back on mapping->dirty_pages, but leave 539 + * its buffers' dirty state as-is. 540 + */ 541 + redirty_page_for_writepage(wbc, page); 542 + unlock_page(page); 543 + return 0; 544 + } 535 545 } 536 546 bh = head = page_buffers(page); 537 - if (unlikely(!bh)) { 538 - ntfs_warning(vol->sb, "Error allocating page buffers. " 539 - "Redirtying page so we try again later."); 540 - /* 541 - * Put the page back on mapping->dirty_pages, but leave its 542 - * buffer's dirty state as-is. 543 - */ 544 - redirty_page_for_writepage(wbc, page); 545 - unlock_page(page); 546 - return 0; 547 - } 547 + BUG_ON(!bh); 548 548 549 549 /* NOTE: Different naming scheme to ntfs_read_block()! */ 550 550 ··· 914 910 sync = (wbc->sync_mode == WB_SYNC_ALL); 915 911 916 912 /* Make sure we have mapped buffers. */ 917 - BUG_ON(!page_has_buffers(page)); 918 913 bh = head = page_buffers(page); 919 914 BUG_ON(!bh); 920 915 ··· 2400 2397 buffers_to_free = bh; 2401 2398 } 2402 2399 bh = head = page_buffers(page); 2400 + BUG_ON(!bh); 2403 2401 do { 2404 2402 bh_ofs = bh_offset(bh); 2405 2403 if (bh_ofs + bh_size <= ofs)