From efd012db6d58f541c417607595c1394c2ed65cd7 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Tue, 12 Oct 2004 11:27:35 +0100 Subject: [PATCH] NTFS: Provide exclusion between opening an inode / mapping an mft record and accessing the mft record in fs/ntfs/mft.c::ntfs_mft_writepage() by setting the page not uptodate throughout ntfs_mft_writepage(). Signed-off-by: Anton Altaparmakov --- fs/ntfs/ChangeLog | 3 +++ fs/ntfs/mft.c | 20 +++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index a3ded99e9a028..a59525b281520 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -82,6 +82,9 @@ ToDo/Notes: extend the initialized size. - Map the page instead of using page_address() before writing to it in fs/ntfs/aops.c::ntfs_mft_writepage(). + - Provide exclusion between opening an inode / mapping an mft record + and accessing the mft record in fs/ntfs/mft.c::ntfs_mft_writepage() + by setting the page not uptodate throughout ntfs_mft_writepage(). 2.1.20 - Fix two stupid bugs introduced in 2.1.18 release. diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 32580f2f3e2e3..60ffcb1a12216 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c @@ -724,18 +724,9 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync) */ if (!NInoTestClearDirty(ni)) goto done; - /* Make sure we have mapped buffers. */ - if (!page_has_buffers(page)) { -no_buffers_err_out: - ntfs_error(vol->sb, "Writing mft records without existing " - "buffers is not implemented yet. %s", - ntfs_please_email); - err = -EOPNOTSUPP; - goto err_out; - } + BUG_ON(!page_has_buffers(page)); bh = head = page_buffers(page); - if (!bh) - goto no_buffers_err_out; + BUG_ON(!bh); nr_bhs = 0; block_start = 0; m_start = ni->page_ofs; @@ -892,6 +883,12 @@ static int ntfs_mft_writepage(struct page *page, struct writeback_control *wbc) ntfs_debug("Entering for %i inodes starting at 0x%lx.", nr, mft_no); /* Iterate over the mft records in the page looking for a dirty one. */ maddr = (u8*)kmap(page); + /* + * Clear the page uptodate flag. This will cause anyone trying to get + * hold of the page to block on the page lock in read_cache_page(). + */ + BUG_ON(!PageUptodate(page)); + ClearPageUptodate(page); for (i = 0; i < nr; ++i, ++mft_no, maddr += vol->mft_record_size) { struct inode *vi; ntfs_inode *ni, *eni; @@ -1034,6 +1031,7 @@ static int ntfs_mft_writepage(struct page *page, struct writeback_control *wbc) up(&ni->extent_lock); iput(vi); } + SetPageUptodate(page); kunmap(page); /* If a dirty mft record was found, redirty the page. */ if (is_dirty) { -- 2.53.0