Commit 3034a968 authored by Anton Altaparmakov's avatar Anton Altaparmakov

Merge ssh://linux-ntfs@bkbits.net/ntfs-2.6-devel

into cantab.net:/home/src/ntfs-2.6-devel
parents 35370417 efd012db
...@@ -76,6 +76,15 @@ ToDo/Notes: ...@@ -76,6 +76,15 @@ ToDo/Notes:
- Modify fs/ntfs/mft.c::write_mft_record_nolock() so that it only - Modify fs/ntfs/mft.c::write_mft_record_nolock() so that it only
writes the mft record if the buffers belonging to it are dirty. writes the mft record if the buffers belonging to it are dirty.
Otherwise we assume that it was written out by other means already. Otherwise we assume that it was written out by other means already.
- Attempting to write outside initialized size is _not_ a bug so remove
the bug check from fs/ntfs/aops.c::ntfs_write_mst_block(). It is in
fact required to write outside initialized size when preparing to
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. 2.1.20 - Fix two stupid bugs introduced in 2.1.18 release.
......
...@@ -892,8 +892,6 @@ static int ntfs_write_mst_block(struct writeback_control *wbc, ...@@ -892,8 +892,6 @@ static int ntfs_write_mst_block(struct writeback_control *wbc,
} }
BUG_ON(!rec_is_dirty); BUG_ON(!rec_is_dirty);
} }
/* Attempting to write outside the initialized size is a bug. */
BUG_ON(((block + 1) << bh_size_bits) > ni->initialized_size);
if (!buffer_mapped(bh)) { if (!buffer_mapped(bh)) {
ntfs_error(vol->sb, "Writing ntfs records without " ntfs_error(vol->sb, "Writing ntfs records without "
"existing mapped buffers is not " "existing mapped buffers is not "
...@@ -919,7 +917,7 @@ static int ntfs_write_mst_block(struct writeback_control *wbc, ...@@ -919,7 +917,7 @@ static int ntfs_write_mst_block(struct writeback_control *wbc,
if (!nr_bhs) if (!nr_bhs)
goto done; goto done;
/* Apply the mst protection fixups. */ /* Apply the mst protection fixups. */
kaddr = page_address(page); kaddr = kmap(page);
for (i = 0; i < nr_bhs; i++) { for (i = 0; i < nr_bhs; i++) {
if (!(i % bhs_per_rec)) { if (!(i % bhs_per_rec)) {
err = pre_write_mst_fixup((NTFS_RECORD*)(kaddr + err = pre_write_mst_fixup((NTFS_RECORD*)(kaddr +
...@@ -976,6 +974,7 @@ static int ntfs_write_mst_block(struct writeback_control *wbc, ...@@ -976,6 +974,7 @@ static int ntfs_write_mst_block(struct writeback_control *wbc,
bh_offset(bhs[i]))); bh_offset(bhs[i])));
} }
flush_dcache_page(page); flush_dcache_page(page);
kunmap(page);
if (unlikely(err)) { if (unlikely(err)) {
/* I/O error during writing. This is really bad! */ /* I/O error during writing. This is really bad! */
ntfs_error(vol->sb, "I/O error while writing ntfs record " ntfs_error(vol->sb, "I/O error while writing ntfs record "
...@@ -998,6 +997,7 @@ static int ntfs_write_mst_block(struct writeback_control *wbc, ...@@ -998,6 +997,7 @@ static int ntfs_write_mst_block(struct writeback_control *wbc,
post_write_mst_fixup((NTFS_RECORD*)(kaddr + post_write_mst_fixup((NTFS_RECORD*)(kaddr +
bh_offset(bhs[i]))); bh_offset(bhs[i])));
} }
kunmap(page);
cleanup_out: cleanup_out:
/* Clean the buffers. */ /* Clean the buffers. */
for (i = 0; i < nr_bhs; i++) for (i = 0; i < nr_bhs; i++)
......
...@@ -724,18 +724,9 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync) ...@@ -724,18 +724,9 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync)
*/ */
if (!NInoTestClearDirty(ni)) if (!NInoTestClearDirty(ni))
goto done; goto done;
/* Make sure we have mapped buffers. */ BUG_ON(!page_has_buffers(page));
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;
}
bh = head = page_buffers(page); bh = head = page_buffers(page);
if (!bh) BUG_ON(!bh);
goto no_buffers_err_out;
nr_bhs = 0; nr_bhs = 0;
block_start = 0; block_start = 0;
m_start = ni->page_ofs; m_start = ni->page_ofs;
...@@ -892,6 +883,12 @@ static int ntfs_mft_writepage(struct page *page, struct writeback_control *wbc) ...@@ -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); 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. */ /* Iterate over the mft records in the page looking for a dirty one. */
maddr = (u8*)kmap(page); 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) { for (i = 0; i < nr; ++i, ++mft_no, maddr += vol->mft_record_size) {
struct inode *vi; struct inode *vi;
ntfs_inode *ni, *eni; ntfs_inode *ni, *eni;
...@@ -1034,6 +1031,7 @@ static int ntfs_mft_writepage(struct page *page, struct writeback_control *wbc) ...@@ -1034,6 +1031,7 @@ static int ntfs_mft_writepage(struct page *page, struct writeback_control *wbc)
up(&ni->extent_lock); up(&ni->extent_lock);
iput(vi); iput(vi);
} }
SetPageUptodate(page);
kunmap(page); kunmap(page);
/* If a dirty mft record was found, redirty the page. */ /* If a dirty mft record was found, redirty the page. */
if (is_dirty) { if (is_dirty) {
......
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