Skip to content

Commit

Permalink
Merge tag 'vfs-6.11.pg_error' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/git/vfs/vfs

Pull PG_error removal updates from Christian Brauner:
 "This contains work to remove almost all remaining users of PG_error
  from filesystems and filesystem helper libraries. An additional patch
  will be coming in via the jfs tree which tests the PG_error bit.

  Afterwards nothing will be testing it anymore and it's safe to remove
  all places which set or clear the PG_error bit.

  The goal is to fully remove PG_error by the next merge window"

* tag 'vfs-6.11.pg_error' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
  buffer: Remove calls to set and clear the folio error flag
  iomap: Remove calls to set and clear folio error flag
  vboxsf: Convert vboxsf_read_folio() to use a folio
  ufs: Remove call to set the folio error flag
  romfs: Convert romfs_read_folio() to use a folio
  reiserfs: Remove call to folio_set_error()
  orangefs: Remove calls to set/clear the error flag
  nfs: Remove calls to folio_set_error
  jffs2: Remove calls to set/clear the folio error flag
  hostfs: Convert hostfs_read_folio() to use a folio
  isofs: Convert rock_ridge_symlink_read_folio to use a folio
  hpfs: Convert hpfs_symlink_read_folio to use a folio
  efs: Convert efs_symlink_read_folio to use a folio
  cramfs: Convert cramfs_read_folio to use a folio
  coda: Convert coda_symlink_filler() to use folio_end_read()
  befs: Convert befs_symlink_read_folio() to use folio_end_read()
  • Loading branch information
torvalds committed Jul 15, 2024
2 parents b051320 + 7ad635e commit aff3133
Show file tree
Hide file tree
Showing 20 changed files with 60 additions and 168 deletions.
10 changes: 4 additions & 6 deletions fs/befs/linuxvfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ static int befs_symlink_read_folio(struct file *unused, struct folio *folio)
befs_data_stream *data = &befs_ino->i_data.ds;
befs_off_t len = data->size;
char *link = folio_address(folio);
int err = -EIO;

if (len == 0 || len > PAGE_SIZE) {
befs_error(sb, "Long symlink with illegal length");
Expand All @@ -487,13 +488,10 @@ static int befs_symlink_read_folio(struct file *unused, struct folio *folio)
goto fail;
}
link[len - 1] = '\0';
folio_mark_uptodate(folio);
folio_unlock(folio);
return 0;
err = 0;
fail:
folio_set_error(folio);
folio_unlock(folio);
return -EIO;
folio_end_read(folio, err == 0);
return err;
}

/*
Expand Down
7 changes: 1 addition & 6 deletions fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
} else {
clear_buffer_uptodate(bh);
buffer_io_error(bh, ", async page read");
folio_set_error(folio);
}

/*
Expand Down Expand Up @@ -391,7 +390,6 @@ static void end_buffer_async_write(struct buffer_head *bh, int uptodate)
buffer_io_error(bh, ", lost async page write");
mark_buffer_write_io_error(bh);
clear_buffer_uptodate(bh);
folio_set_error(folio);
}

first = folio_buffers(folio);
Expand Down Expand Up @@ -1960,7 +1958,6 @@ int __block_write_full_folio(struct inode *inode, struct folio *folio,
clear_buffer_dirty(bh);
}
} while ((bh = bh->b_this_page) != head);
folio_set_error(folio);
BUG_ON(folio_test_writeback(folio));
mapping_set_error(folio->mapping, err);
folio_start_writeback(folio);
Expand Down Expand Up @@ -2405,10 +2402,8 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
if (iblock < lblock) {
WARN_ON(bh->b_size != blocksize);
err = get_block(inode, iblock, bh, 0);
if (err) {
folio_set_error(folio);
if (err)
page_error = true;
}
}
if (!buffer_mapped(bh)) {
folio_zero_range(folio, i * blocksize,
Expand Down
10 changes: 1 addition & 9 deletions fs/coda/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ static int coda_symlink_filler(struct file *file, struct folio *folio)
cii = ITOC(inode);

error = venus_readlink(inode->i_sb, &cii->c_fid, p, &len);
if (error)
goto fail;
folio_mark_uptodate(folio);
folio_unlock(folio);
return 0;

fail:
folio_set_error(folio);
folio_unlock(folio);
folio_end_read(folio, error == 0);
return error;
}

Expand Down
25 changes: 10 additions & 15 deletions fs/cramfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,19 +811,19 @@ static struct dentry *cramfs_lookup(struct inode *dir, struct dentry *dentry, un

static int cramfs_read_folio(struct file *file, struct folio *folio)
{
struct page *page = &folio->page;
struct inode *inode = page->mapping->host;
struct inode *inode = folio->mapping->host;
u32 maxblock;
int bytes_filled;
void *pgdata;
bool success = false;

maxblock = (inode->i_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
bytes_filled = 0;
pgdata = kmap_local_page(page);
pgdata = kmap_local_folio(folio, 0);

if (page->index < maxblock) {
if (folio->index < maxblock) {
struct super_block *sb = inode->i_sb;
u32 blkptr_offset = OFFSET(inode) + page->index * 4;
u32 blkptr_offset = OFFSET(inode) + folio->index * 4;
u32 block_ptr, block_start, block_len;
bool uncompressed, direct;

Expand All @@ -844,7 +844,7 @@ static int cramfs_read_folio(struct file *file, struct folio *folio)
if (uncompressed) {
block_len = PAGE_SIZE;
/* if last block: cap to file length */
if (page->index == maxblock - 1)
if (folio->index == maxblock - 1)
block_len =
offset_in_page(inode->i_size);
} else {
Expand All @@ -861,7 +861,7 @@ static int cramfs_read_folio(struct file *file, struct folio *folio)
* from the previous block's pointer.
*/
block_start = OFFSET(inode) + maxblock * 4;
if (page->index)
if (folio->index)
block_start = *(u32 *)
cramfs_read(sb, blkptr_offset - 4, 4);
/* Beware... previous ptr might be a direct ptr */
Expand Down Expand Up @@ -906,17 +906,12 @@ static int cramfs_read_folio(struct file *file, struct folio *folio)
}

memset(pgdata + bytes_filled, 0, PAGE_SIZE - bytes_filled);
flush_dcache_page(page);
kunmap_local(pgdata);
SetPageUptodate(page);
unlock_page(page);
return 0;
flush_dcache_folio(folio);

success = true;
err:
kunmap_local(pgdata);
ClearPageUptodate(page);
SetPageError(page);
unlock_page(page);
folio_end_read(folio, success);
return 0;
}

Expand Down
14 changes: 5 additions & 9 deletions fs/efs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

static int efs_symlink_read_folio(struct file *file, struct folio *folio)
{
struct page *page = &folio->page;
char *link = page_address(page);
struct buffer_head * bh;
struct inode * inode = page->mapping->host;
char *link = folio_address(folio);
struct buffer_head *bh;
struct inode *inode = folio->mapping->host;
efs_block_t size = inode->i_size;
int err;

Expand All @@ -40,12 +39,9 @@ static int efs_symlink_read_folio(struct file *file, struct folio *folio)
brelse(bh);
}
link[size] = '\0';
SetPageUptodate(page);
unlock_page(page);
return 0;
err = 0;
fail:
SetPageError(page);
unlock_page(page);
folio_end_read(folio, err == 0);
return err;
}

Expand Down
23 changes: 6 additions & 17 deletions fs/hostfs/hostfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,31 +432,20 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc)

static int hostfs_read_folio(struct file *file, struct folio *folio)
{
struct page *page = &folio->page;
char *buffer;
loff_t start = page_offset(page);
loff_t start = folio_pos(folio);
int bytes_read, ret = 0;

buffer = kmap_local_page(page);
buffer = kmap_local_folio(folio, 0);
bytes_read = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer,
PAGE_SIZE);
if (bytes_read < 0) {
ClearPageUptodate(page);
SetPageError(page);
if (bytes_read < 0)
ret = bytes_read;
goto out;
}

memset(buffer + bytes_read, 0, PAGE_SIZE - bytes_read);

ClearPageError(page);
SetPageUptodate(page);

out:
flush_dcache_page(page);
else
buffer = folio_zero_tail(folio, bytes_read, buffer);
kunmap_local(buffer);
unlock_page(page);

folio_end_read(folio, ret == 0);
return ret;
}

Expand Down
15 changes: 3 additions & 12 deletions fs/hpfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)

static int hpfs_symlink_read_folio(struct file *file, struct folio *folio)
{
struct page *page = &folio->page;
char *link = page_address(page);
struct inode *i = page->mapping->host;
char *link = folio_address(folio);
struct inode *i = folio->mapping->host;
struct fnode *fnode;
struct buffer_head *bh;
int err;
Expand All @@ -485,17 +484,9 @@ static int hpfs_symlink_read_folio(struct file *file, struct folio *folio)
goto fail;
err = hpfs_read_ea(i->i_sb, fnode, "SYMLINK", link, PAGE_SIZE);
brelse(bh);
if (err)
goto fail;
hpfs_unlock(i->i_sb);
SetPageUptodate(page);
unlock_page(page);
return 0;

fail:
hpfs_unlock(i->i_sb);
SetPageError(page);
unlock_page(page);
folio_end_read(folio, err == 0);
return err;
}

Expand Down
8 changes: 0 additions & 8 deletions fs/iomap/buffered-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ static void iomap_finish_folio_read(struct folio *folio, size_t off,
spin_unlock_irqrestore(&ifs->state_lock, flags);
}

if (error)
folio_set_error(folio);
if (finished)
folio_end_read(folio, uptodate);
}
Expand Down Expand Up @@ -461,9 +459,6 @@ int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops)
while ((ret = iomap_iter(&iter, ops)) > 0)
iter.processed = iomap_readpage_iter(&iter, &ctx, 0);

if (ret < 0)
folio_set_error(folio);

if (ctx.bio) {
submit_bio(ctx.bio);
WARN_ON_ONCE(!ctx.cur_folio_in_bio);
Expand Down Expand Up @@ -698,7 +693,6 @@ static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos,

if (folio_test_uptodate(folio))
return 0;
folio_clear_error(folio);

do {
iomap_adjust_read_range(iter->inode, folio, &block_start,
Expand Down Expand Up @@ -1539,8 +1533,6 @@ iomap_finish_ioend(struct iomap_ioend *ioend, int error)

/* walk all folios in bio, ending page IO on them */
bio_for_each_folio_all(fi, bio) {
if (error)
folio_set_error(fi.folio);
iomap_finish_folio_write(inode, fi.folio, fi.length);
folio_count++;
}
Expand Down
17 changes: 8 additions & 9 deletions fs/isofs/rock.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,10 @@ int parse_rock_ridge_inode(struct iso_directory_record *de, struct inode *inode,
*/
static int rock_ridge_symlink_read_folio(struct file *file, struct folio *folio)
{
struct page *page = &folio->page;
struct inode *inode = page->mapping->host;
struct inode *inode = folio->mapping->host;
struct iso_inode_info *ei = ISOFS_I(inode);
struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb);
char *link = page_address(page);
char *link = folio_address(folio);
unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
struct buffer_head *bh;
char *rpnt = link;
Expand Down Expand Up @@ -779,9 +778,10 @@ static int rock_ridge_symlink_read_folio(struct file *file, struct folio *folio)
goto fail;
brelse(bh);
*rpnt = '\0';
SetPageUptodate(page);
unlock_page(page);
return 0;
ret = 0;
end:
folio_end_read(folio, ret == 0);
return ret;

/* error exit from macro */
out:
Expand All @@ -795,9 +795,8 @@ static int rock_ridge_symlink_read_folio(struct file *file, struct folio *folio)
fail:
brelse(bh);
error:
SetPageError(page);
unlock_page(page);
return -EIO;
ret = -EIO;
goto end;
}

const struct address_space_operations isofs_symlink_aops = {
Expand Down
14 changes: 3 additions & 11 deletions fs/jffs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,8 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg)
ret = jffs2_read_inode_range(c, f, pg_buf, pg->index << PAGE_SHIFT,
PAGE_SIZE);

if (ret) {
ClearPageUptodate(pg);
SetPageError(pg);
} else {
if (!ret)
SetPageUptodate(pg);
ClearPageError(pg);
}

flush_dcache_page(pg);
kunmap(pg);
Expand Down Expand Up @@ -304,10 +299,8 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,

kunmap(pg);

if (ret) {
/* There was an error writing. */
SetPageError(pg);
}
if (ret)
mapping_set_error(mapping, ret);

/* Adjust writtenlen for the padding we did, so we don't confuse our caller */
writtenlen -= min(writtenlen, (start - aligned_start));
Expand All @@ -330,7 +323,6 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
it gets reread */
jffs2_dbg(1, "%s(): Not all bytes written. Marking page !uptodate\n",
__func__);
SetPageError(pg);
ClearPageUptodate(pg);
}

Expand Down
13 changes: 3 additions & 10 deletions fs/mpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,8 @@ static void mpage_read_end_io(struct bio *bio)
struct folio_iter fi;
int err = blk_status_to_errno(bio->bi_status);

bio_for_each_folio_all(fi, bio) {
if (err)
folio_set_error(fi.folio);
else
folio_mark_uptodate(fi.folio);
folio_unlock(fi.folio);
}
bio_for_each_folio_all(fi, bio)
folio_end_read(fi.folio, err == 0);

bio_put(bio);
}
Expand All @@ -65,10 +60,8 @@ static void mpage_write_end_io(struct bio *bio)
int err = blk_status_to_errno(bio->bi_status);

bio_for_each_folio_all(fi, bio) {
if (err) {
folio_set_error(fi.folio);
if (err)
mapping_set_error(fi.folio->mapping, err);
}
folio_end_writeback(fi.folio);
}

Expand Down
2 changes: 0 additions & 2 deletions fs/nfs/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ static void nfs_readpage_release(struct nfs_page *req, int error)
{
struct folio *folio = nfs_page_to_folio(req);

if (nfs_error_is_fatal_on_server(error) && error != -ETIMEDOUT)
folio_set_error(folio);
if (nfs_page_group_sync_on_bit(req, PG_UNLOCKPAGE))
if (nfs_netfs_folio_unlock(folio))
folio_unlock(folio);
Expand Down
Loading

0 comments on commit aff3133

Please sign in to comment.