Commit db14fecd authored by Anton Altaparmakov's avatar Anton Altaparmakov

NTFS: Update __ntfs_index_entry_mark_dirty() so it makes sure that the

      page has buffers.  Otherwise we could end up with a dirty page
      without buffers and our set_page_dirty() would not mark the buffers
      dirty when they are created and thus they would not be written out
      and the dirty records would be lost.
Signed-off-by: default avatarAnton Altaparmakov <aia21@cantab.net>
parent a97689d2
......@@ -478,13 +478,15 @@ int ntfs_index_lookup(const void *key, const int key_len,
*/
void __ntfs_index_entry_mark_dirty(ntfs_index_context *ictx)
{
struct address_space *mapping;
struct page *page;
ntfs_inode *ni;
struct page *page;
struct buffer_head *bh, *head;
unsigned int rec_start, rec_end, bh_size, bh_start, bh_end;
BUG_ON(ictx->is_in_root);
ni = ictx->idx_ni;
page = ictx->page;
BUG_ON(!page_has_buffers(page));
/*
* If the index block is the same size as the page cache page, set all
* the buffers in the page, as well as the page itself, dirty.
......@@ -494,24 +496,17 @@ void __ntfs_index_entry_mark_dirty(ntfs_index_context *ictx)
return;
}
/* Set only the buffers in which the index block is located dirty. */
mapping = page->mapping;
if (page_has_buffers(page)) {
struct buffer_head *bh, *head;
unsigned int bh_start, bh_end, rec_start, rec_end;
unsigned int bh_size = ni->vol->sb->s_blocksize;
bh = head = page_buffers(page);
bh_start = 0;
rec_start = (unsigned int)((u8*)ictx->ia -
(u8*)page_address(page));
rec_start = (unsigned int)((u8*)ictx->ia - (u8*)page_address(page));
rec_end = rec_start + ni->itype.index.block_size;
bh_size = ni->vol->sb->s_blocksize;
bh_start = 0;
bh = head = page_buffers(page);
do {
bh_end = bh_start + bh_size;
if ((bh_start >= rec_start) && (bh_end <= rec_end))
set_buffer_dirty(bh);
bh_start = bh_end;
} while ((bh = bh->b_this_page) != head);
}
/* Finally, set the page itself dirty, too. */
__set_page_dirty_nobuffers(page);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment