Commit db675409 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Jan Kara

udf: Convert udf_expand_file_adinicb() to use a folio

Use the folio APIs throughout this function.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Fixes: 1eeceaec ("udf: Convert udf_expand_file_adinicb() to avoid kmap_atomic()")
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Message-Id: <20240417150416.752929-4-willy@infradead.org>
parent d08f069c
...@@ -342,7 +342,7 @@ const struct address_space_operations udf_aops = { ...@@ -342,7 +342,7 @@ const struct address_space_operations udf_aops = {
*/ */
int udf_expand_file_adinicb(struct inode *inode) int udf_expand_file_adinicb(struct inode *inode)
{ {
struct page *page; struct folio *folio;
struct udf_inode_info *iinfo = UDF_I(inode); struct udf_inode_info *iinfo = UDF_I(inode);
int err; int err;
...@@ -358,12 +358,13 @@ int udf_expand_file_adinicb(struct inode *inode) ...@@ -358,12 +358,13 @@ int udf_expand_file_adinicb(struct inode *inode)
return 0; return 0;
} }
page = find_or_create_page(inode->i_mapping, 0, GFP_KERNEL); folio = __filemap_get_folio(inode->i_mapping, 0,
if (!page) FGP_LOCK | FGP_ACCESSED | FGP_CREAT, GFP_KERNEL);
return -ENOMEM; if (IS_ERR(folio))
return PTR_ERR(folio);
if (!PageUptodate(page)) if (!folio_test_uptodate(folio))
udf_adinicb_readpage(page); udf_adinicb_readpage(&folio->page);
down_write(&iinfo->i_data_sem); down_write(&iinfo->i_data_sem);
memset(iinfo->i_data + iinfo->i_lenEAttr, 0x00, memset(iinfo->i_data + iinfo->i_lenEAttr, 0x00,
iinfo->i_lenAlloc); iinfo->i_lenAlloc);
...@@ -372,22 +373,22 @@ int udf_expand_file_adinicb(struct inode *inode) ...@@ -372,22 +373,22 @@ int udf_expand_file_adinicb(struct inode *inode)
iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT; iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;
else else
iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG; iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;
set_page_dirty(page); folio_mark_dirty(folio);
unlock_page(page); folio_unlock(folio);
up_write(&iinfo->i_data_sem); up_write(&iinfo->i_data_sem);
err = filemap_fdatawrite(inode->i_mapping); err = filemap_fdatawrite(inode->i_mapping);
if (err) { if (err) {
/* Restore everything back so that we don't lose data... */ /* Restore everything back so that we don't lose data... */
lock_page(page); folio_lock(folio);
down_write(&iinfo->i_data_sem); down_write(&iinfo->i_data_sem);
memcpy_to_page(page, 0, iinfo->i_data + iinfo->i_lenEAttr, memcpy_from_folio(iinfo->i_data + iinfo->i_lenEAttr,
inode->i_size); folio, 0, inode->i_size);
unlock_page(page); folio_unlock(folio);
iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;
iinfo->i_lenAlloc = inode->i_size; iinfo->i_lenAlloc = inode->i_size;
up_write(&iinfo->i_data_sem); up_write(&iinfo->i_data_sem);
} }
put_page(page); folio_put(folio);
mark_inode_dirty(inode); mark_inode_dirty(inode);
return err; return err;
......
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