diff options
author | Anton Altaparmakov <aia21@cantab.net> | 2005-09-08 17:08:11 -0400 |
---|---|---|
committer | Anton Altaparmakov <aia21@cantab.net> | 2005-09-08 17:08:11 -0400 |
commit | a01ac532b519dc0e0b4d8bc4e12373e4e4cd1b1a (patch) | |
tree | 6d6021b5f951790b32f332d05106b9ff82ebb5a1 /fs/ntfs | |
parent | 311120eca0013083f5eb0aff13ffb8aa9fdd050c (diff) |
NTFS: Fix page_has_buffers()/page_buffers() handling in fs/ntfs/aops.c.
Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
Diffstat (limited to 'fs/ntfs')
-rw-r--r-- | fs/ntfs/ChangeLog | 1 | ||||
-rw-r--r-- | fs/ntfs/aops.c | 38 |
2 files changed, 22 insertions, 17 deletions
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index c3b510210743..029f856c56c0 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog | |||
@@ -85,6 +85,7 @@ ToDo/Notes: | |||
85 | removal of the get_bh()/put_bh() pairs for each buffer. | 85 | removal of the get_bh()/put_bh() pairs for each buffer. |
86 | - Fix fs/ntfs/aops.c::ntfs_{read,write}_block() to handle the case | 86 | - Fix fs/ntfs/aops.c::ntfs_{read,write}_block() to handle the case |
87 | where a concurrent truncate has truncated the runlist under our feet. | 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 | 2.1.23 - Implement extension of resident files and make writing safe as well as | 90 | 2.1.23 - Implement extension of resident files and make writing safe as well as |
90 | many bug fixes, cleanups, and enhancements... | 91 | many bug fixes, cleanups, and enhancements... |
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 2482b677a82a..52e1aff98b00 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c | |||
@@ -185,13 +185,15 @@ static int ntfs_read_block(struct page *page) | |||
185 | blocksize_bits = VFS_I(ni)->i_blkbits; | 185 | blocksize_bits = VFS_I(ni)->i_blkbits; |
186 | blocksize = 1 << blocksize_bits; | 186 | blocksize = 1 << blocksize_bits; |
187 | 187 | ||
188 | if (!page_has_buffers(page)) | 188 | if (!page_has_buffers(page)) { |
189 | create_empty_buffers(page, blocksize, 0); | 189 | create_empty_buffers(page, blocksize, 0); |
190 | bh = head = page_buffers(page); | 190 | if (unlikely(!page_has_buffers(page))) { |
191 | if (unlikely(!bh)) { | 191 | unlock_page(page); |
192 | unlock_page(page); | 192 | return -ENOMEM; |
193 | return -ENOMEM; | 193 | } |
194 | } | 194 | } |
195 | bh = head = page_buffers(page); | ||
196 | BUG_ON(!bh); | ||
195 | 197 | ||
196 | iblock = (s64)page->index << (PAGE_CACHE_SHIFT - blocksize_bits); | 198 | iblock = (s64)page->index << (PAGE_CACHE_SHIFT - blocksize_bits); |
197 | read_lock_irqsave(&ni->size_lock, flags); | 199 | read_lock_irqsave(&ni->size_lock, flags); |
@@ -530,19 +532,21 @@ static int ntfs_write_block(struct page *page, struct writeback_control *wbc) | |||
530 | BUG_ON(!PageUptodate(page)); | 532 | BUG_ON(!PageUptodate(page)); |
531 | create_empty_buffers(page, blocksize, | 533 | create_empty_buffers(page, blocksize, |
532 | (1 << BH_Uptodate) | (1 << BH_Dirty)); | 534 | (1 << BH_Uptodate) | (1 << BH_Dirty)); |
535 | if (unlikely(!page_has_buffers(page))) { | ||
536 | ntfs_warning(vol->sb, "Error allocating page " | ||
537 | "buffers. Redirtying page so we try " | ||
538 | "again later."); | ||
539 | /* | ||
540 | * Put the page back on mapping->dirty_pages, but leave | ||
541 | * its buffers' dirty state as-is. | ||
542 | */ | ||
543 | redirty_page_for_writepage(wbc, page); | ||
544 | unlock_page(page); | ||
545 | return 0; | ||
546 | } | ||
533 | } | 547 | } |
534 | bh = head = page_buffers(page); | 548 | bh = head = page_buffers(page); |
535 | if (unlikely(!bh)) { | 549 | BUG_ON(!bh); |
536 | ntfs_warning(vol->sb, "Error allocating page buffers. " | ||
537 | "Redirtying page so we try again later."); | ||
538 | /* | ||
539 | * Put the page back on mapping->dirty_pages, but leave its | ||
540 | * buffer's dirty state as-is. | ||
541 | */ | ||
542 | redirty_page_for_writepage(wbc, page); | ||
543 | unlock_page(page); | ||
544 | return 0; | ||
545 | } | ||
546 | 550 | ||
547 | /* NOTE: Different naming scheme to ntfs_read_block()! */ | 551 | /* NOTE: Different naming scheme to ntfs_read_block()! */ |
548 | 552 | ||
@@ -910,7 +914,6 @@ static int ntfs_write_mst_block(struct page *page, | |||
910 | sync = (wbc->sync_mode == WB_SYNC_ALL); | 914 | sync = (wbc->sync_mode == WB_SYNC_ALL); |
911 | 915 | ||
912 | /* Make sure we have mapped buffers. */ | 916 | /* Make sure we have mapped buffers. */ |
913 | BUG_ON(!page_has_buffers(page)); | ||
914 | bh = head = page_buffers(page); | 917 | bh = head = page_buffers(page); |
915 | BUG_ON(!bh); | 918 | BUG_ON(!bh); |
916 | 919 | ||
@@ -2397,6 +2400,7 @@ void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs) { | |||
2397 | buffers_to_free = bh; | 2400 | buffers_to_free = bh; |
2398 | } | 2401 | } |
2399 | bh = head = page_buffers(page); | 2402 | bh = head = page_buffers(page); |
2403 | BUG_ON(!bh); | ||
2400 | do { | 2404 | do { |
2401 | bh_ofs = bh_offset(bh); | 2405 | bh_ofs = bh_offset(bh); |
2402 | if (bh_ofs + bh_size <= ofs) | 2406 | if (bh_ofs + bh_size <= ofs) |