Commit a40b73f6 authored by Konstantin Komarov's avatar Konstantin Komarov

fs/ntfs3: Correct use bh_read

Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
parent d1556170
...@@ -188,6 +188,7 @@ static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vbo_to) ...@@ -188,6 +188,7 @@ static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vbo_to)
u32 bh_next, bh_off, to; u32 bh_next, bh_off, to;
sector_t iblock; sector_t iblock;
struct folio *folio; struct folio *folio;
bool dirty = false;
for (; idx < idx_end; idx += 1, from = 0) { for (; idx < idx_end; idx += 1, from = 0) {
page_off = (loff_t)idx << PAGE_SHIFT; page_off = (loff_t)idx << PAGE_SHIFT;
...@@ -223,28 +224,26 @@ static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vbo_to) ...@@ -223,28 +224,26 @@ static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vbo_to)
/* Ok, it's mapped. Make sure it's up-to-date. */ /* Ok, it's mapped. Make sure it's up-to-date. */
if (folio_test_uptodate(folio)) if (folio_test_uptodate(folio))
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
else if (bh_read(bh, 0) < 0) {
if (!buffer_uptodate(bh)) { err = -EIO;
err = bh_read(bh, 0);
if (err < 0) {
folio_unlock(folio); folio_unlock(folio);
folio_put(folio); folio_put(folio);
goto out; goto out;
} }
}
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
} while (bh_off = bh_next, iblock += 1, } while (bh_off = bh_next, iblock += 1,
head != (bh = bh->b_this_page)); head != (bh = bh->b_this_page));
folio_zero_segment(folio, from, to); folio_zero_segment(folio, from, to);
dirty = true;
folio_unlock(folio); folio_unlock(folio);
folio_put(folio); folio_put(folio);
cond_resched(); cond_resched();
} }
out: out:
if (dirty)
mark_inode_dirty(inode); mark_inode_dirty(inode);
return err; return err;
} }
......
...@@ -345,9 +345,7 @@ static struct inode *ntfs_read_mft(struct inode *inode, ...@@ -345,9 +345,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,
inode->i_size = le16_to_cpu(rp.SymbolicLinkReparseBuffer inode->i_size = le16_to_cpu(rp.SymbolicLinkReparseBuffer
.PrintNameLength) / .PrintNameLength) /
sizeof(u16); sizeof(u16);
ni->i_valid = inode->i_size; ni->i_valid = inode->i_size;
/* Clear directory bit. */ /* Clear directory bit. */
if (ni->ni_flags & NI_FLAG_DIR) { if (ni->ni_flags & NI_FLAG_DIR) {
indx_clear(&ni->dir); indx_clear(&ni->dir);
...@@ -653,9 +651,10 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo, ...@@ -653,9 +651,10 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo,
off = vbo & (PAGE_SIZE - 1); off = vbo & (PAGE_SIZE - 1);
folio_set_bh(bh, folio, off); folio_set_bh(bh, folio, off);
err = bh_read(bh, 0); if (bh_read(bh, 0) < 0) {
if (err < 0) err = -EIO;
goto out; goto out;
}
folio_zero_segment(folio, off + voff, off + block_size); folio_zero_segment(folio, off + voff, off + block_size);
} }
} }
......
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