Skip to content

Commit 0f7c0f3

Browse files
committed
cifs: Use alternative invalidation to using launder_folio
Use writepages-based flushing invalidation instead of invalidate_inode_pages2() and ->launder_folio(). This will allow ->launder_folio() to be removed eventually. Signed-off-by: David Howells <dhowells@redhat.com> cc: Steve French <sfrench@samba.org> cc: Shyam Prasad N <nspmangalore@gmail.com> cc: Rohith Surabattula <rohiths.msft@gmail.com> cc: Jeff Layton <jlayton@kernel.org> cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org
1 parent 1ecb146 commit 0f7c0f3

3 files changed

Lines changed: 5 additions & 143 deletions

File tree

fs/smb/client/cifsfs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ extern int cifs_revalidate_file_attr(struct file *filp);
6969
extern int cifs_revalidate_dentry_attr(struct dentry *);
7070
extern int cifs_revalidate_file(struct file *filp);
7171
extern int cifs_revalidate_dentry(struct dentry *);
72-
extern int cifs_invalidate_mapping(struct inode *inode);
7372
extern int cifs_revalidate_mapping(struct inode *inode);
7473
extern int cifs_zap_mapping(struct inode *inode);
7574
extern int cifs_getattr(struct mnt_idmap *, const struct path *,

fs/smb/client/file.c

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,64 +2655,6 @@ struct cifs_writedata *cifs_writedata_alloc(work_func_t complete)
26552655
return wdata;
26562656
}
26572657

2658-
static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
2659-
{
2660-
struct address_space *mapping = page->mapping;
2661-
loff_t offset = (loff_t)page->index << PAGE_SHIFT;
2662-
char *write_data;
2663-
int rc = -EFAULT;
2664-
int bytes_written = 0;
2665-
struct inode *inode;
2666-
struct cifsFileInfo *open_file;
2667-
2668-
if (!mapping || !mapping->host)
2669-
return -EFAULT;
2670-
2671-
inode = page->mapping->host;
2672-
2673-
offset += (loff_t)from;
2674-
write_data = kmap(page);
2675-
write_data += from;
2676-
2677-
if ((to > PAGE_SIZE) || (from > to)) {
2678-
kunmap(page);
2679-
return -EIO;
2680-
}
2681-
2682-
/* racing with truncate? */
2683-
if (offset > mapping->host->i_size) {
2684-
kunmap(page);
2685-
return 0; /* don't care */
2686-
}
2687-
2688-
/* check to make sure that we are not extending the file */
2689-
if (mapping->host->i_size - offset < (loff_t)to)
2690-
to = (unsigned)(mapping->host->i_size - offset);
2691-
2692-
rc = cifs_get_writable_file(CIFS_I(mapping->host), FIND_WR_ANY,
2693-
&open_file);
2694-
if (!rc) {
2695-
bytes_written = cifs_write(open_file, open_file->pid,
2696-
write_data, to - from, &offset);
2697-
cifsFileInfo_put(open_file);
2698-
/* Does mm or vfs already set times? */
2699-
simple_inode_init_ts(inode);
2700-
if ((bytes_written > 0) && (offset))
2701-
rc = 0;
2702-
else if (bytes_written < 0)
2703-
rc = bytes_written;
2704-
else
2705-
rc = -EFAULT;
2706-
} else {
2707-
cifs_dbg(FYI, "No writable handle for write page rc=%d\n", rc);
2708-
if (!is_retryable_error(rc))
2709-
rc = -EIO;
2710-
}
2711-
2712-
kunmap(page);
2713-
return rc;
2714-
}
2715-
27162658
/*
27172659
* Extend the region to be written back to include subsequent contiguously
27182660
* dirty pages if possible, but don't sleep while doing so.
@@ -3126,47 +3068,6 @@ static int cifs_writepages(struct address_space *mapping,
31263068
return ret;
31273069
}
31283070

3129-
static int
3130-
cifs_writepage_locked(struct page *page, struct writeback_control *wbc)
3131-
{
3132-
int rc;
3133-
unsigned int xid;
3134-
3135-
xid = get_xid();
3136-
/* BB add check for wbc flags */
3137-
get_page(page);
3138-
if (!PageUptodate(page))
3139-
cifs_dbg(FYI, "ppw - page not up to date\n");
3140-
3141-
/*
3142-
* Set the "writeback" flag, and clear "dirty" in the radix tree.
3143-
*
3144-
* A writepage() implementation always needs to do either this,
3145-
* or re-dirty the page with "redirty_page_for_writepage()" in
3146-
* the case of a failure.
3147-
*
3148-
* Just unlocking the page will cause the radix tree tag-bits
3149-
* to fail to update with the state of the page correctly.
3150-
*/
3151-
set_page_writeback(page);
3152-
retry_write:
3153-
rc = cifs_partialpagewrite(page, 0, PAGE_SIZE);
3154-
if (is_retryable_error(rc)) {
3155-
if (wbc->sync_mode == WB_SYNC_ALL && rc == -EAGAIN)
3156-
goto retry_write;
3157-
redirty_page_for_writepage(wbc, page);
3158-
} else if (rc != 0) {
3159-
SetPageError(page);
3160-
mapping_set_error(page->mapping, rc);
3161-
} else {
3162-
SetPageUptodate(page);
3163-
}
3164-
end_page_writeback(page);
3165-
put_page(page);
3166-
free_xid(xid);
3167-
return rc;
3168-
}
3169-
31703071
static int cifs_write_end(struct file *file, struct address_space *mapping,
31713072
loff_t pos, unsigned len, unsigned copied,
31723073
struct page *page, void *fsdata)
@@ -4992,27 +4893,6 @@ static void cifs_invalidate_folio(struct folio *folio, size_t offset,
49924893
folio_wait_private_2(folio); /* [DEPRECATED] */
49934894
}
49944895

4995-
static int cifs_launder_folio(struct folio *folio)
4996-
{
4997-
int rc = 0;
4998-
loff_t range_start = folio_pos(folio);
4999-
loff_t range_end = range_start + folio_size(folio);
5000-
struct writeback_control wbc = {
5001-
.sync_mode = WB_SYNC_ALL,
5002-
.nr_to_write = 0,
5003-
.range_start = range_start,
5004-
.range_end = range_end,
5005-
};
5006-
5007-
cifs_dbg(FYI, "Launder page: %lu\n", folio->index);
5008-
5009-
if (folio_clear_dirty_for_io(folio))
5010-
rc = cifs_writepage_locked(&folio->page, &wbc);
5011-
5012-
folio_wait_private_2(folio); /* [DEPRECATED] */
5013-
return rc;
5014-
}
5015-
50164896
void cifs_oplock_break(struct work_struct *work)
50174897
{
50184898
struct cifsFileInfo *cfile = container_of(work, struct cifsFileInfo,
@@ -5191,7 +5071,6 @@ const struct address_space_operations cifs_addr_ops = {
51915071
.release_folio = cifs_release_folio,
51925072
.direct_IO = cifs_direct_io,
51935073
.invalidate_folio = cifs_invalidate_folio,
5194-
.launder_folio = cifs_launder_folio,
51955074
.migrate_folio = filemap_migrate_folio,
51965075
/*
51975076
* TODO: investigate and if useful we could add an is_dirty_writeback
@@ -5214,6 +5093,5 @@ const struct address_space_operations cifs_addr_ops_smallbuf = {
52145093
.dirty_folio = netfs_dirty_folio,
52155094
.release_folio = cifs_release_folio,
52165095
.invalidate_folio = cifs_invalidate_folio,
5217-
.launder_folio = cifs_launder_folio,
52185096
.migrate_folio = filemap_migrate_folio,
52195097
};

fs/smb/client/inode.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,24 +2431,6 @@ cifs_dentry_needs_reval(struct dentry *dentry)
24312431
return false;
24322432
}
24332433

2434-
/*
2435-
* Zap the cache. Called when invalid_mapping flag is set.
2436-
*/
2437-
int
2438-
cifs_invalidate_mapping(struct inode *inode)
2439-
{
2440-
int rc = 0;
2441-
2442-
if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
2443-
rc = invalidate_inode_pages2(inode->i_mapping);
2444-
if (rc)
2445-
cifs_dbg(VFS, "%s: invalidate inode %p failed with rc %d\n",
2446-
__func__, inode, rc);
2447-
}
2448-
2449-
return rc;
2450-
}
2451-
24522434
/**
24532435
* cifs_wait_bit_killable - helper for functions that are sleeping on bit locks
24542436
*
@@ -2485,9 +2467,12 @@ cifs_revalidate_mapping(struct inode *inode)
24852467
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE)
24862468
goto skip_invalidate;
24872469

2488-
rc = cifs_invalidate_mapping(inode);
2489-
if (rc)
2470+
rc = filemap_invalidate_inode(inode, true, 0, LLONG_MAX);
2471+
if (rc) {
2472+
cifs_dbg(VFS, "%s: invalidate inode %p failed with rc %d\n",
2473+
__func__, inode, rc);
24902474
set_bit(CIFS_INO_INVALID_MAPPING, flags);
2475+
}
24912476
}
24922477

24932478
skip_invalidate:

0 commit comments

Comments
 (0)