* [PATCH] cifs: Remove cifs_truncate_page() as it should be superfluous
@ 2025-04-01 15:01 David Howells
2025-04-02 15:23 ` Paulo Alcantara
0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2025-04-01 15:01 UTC (permalink / raw)
To: Steve French
Cc: dhowells, Paulo Alcantara, Matthew Wilcox, linux-cifs, netfs,
linux-fsdevel, linux-kernel
The calls to cifs_truncate_page() should be superfluous as the places that
call it also call truncate_setsize() or cifs_setsize() and therefore
truncate_pagecache() which should also clear the tail part of the folio
containing the EOF marker.
Further, smb3_simple_falloc() calls both cifs_setsize() and
truncate_setsize() in addition to cifs_truncate_page().
Remove the superfluous calls.
This gets rid of another function referring to struct page.
[Should cifs_setsize() also set inode->i_blocks?]
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Steve French <stfrench@microsoft.com>
cc: Paulo Alcantara (Red Hat) <pc@manguebit.com>
cc: Matthew Wilcox <willy@infradead.org>
cc: linux-cifs@vger.kernel.org
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
---
fs/smb/client/cifsfs.h | 1 -
fs/smb/client/inode.c | 19 -------------------
fs/smb/client/smb2ops.c | 2 --
3 files changed, 22 deletions(-)
diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
index 8dea0cf3a8de..a769fa7ceece 100644
--- a/fs/smb/client/cifsfs.h
+++ b/fs/smb/client/cifsfs.h
@@ -135,7 +135,6 @@ extern ssize_t cifs_file_copychunk_range(unsigned int xid,
extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
extern void cifs_setsize(struct inode *inode, loff_t offset);
-extern int cifs_truncate_page(struct address_space *mapping, loff_t from);
struct smb3_fs_context;
extern struct dentry *cifs_smb3_do_mount(struct file_system_type *fs_type,
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 3bb21aa58474..a00a9d91d0da 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -2901,23 +2901,6 @@ int cifs_fiemap(struct inode *inode, struct fiemap_extent_info *fei, u64 start,
return -EOPNOTSUPP;
}
-int cifs_truncate_page(struct address_space *mapping, loff_t from)
-{
- pgoff_t index = from >> PAGE_SHIFT;
- unsigned offset = from & (PAGE_SIZE - 1);
- struct page *page;
- int rc = 0;
-
- page = grab_cache_page(mapping, index);
- if (!page)
- return -ENOMEM;
-
- zero_user_segment(page, offset, PAGE_SIZE);
- unlock_page(page);
- put_page(page);
- return rc;
-}
-
void cifs_setsize(struct inode *inode, loff_t offset)
{
struct cifsInodeInfo *cifs_i = CIFS_I(inode);
@@ -3012,8 +2995,6 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
*/
attrs->ia_ctime = attrs->ia_mtime = current_time(inode);
attrs->ia_valid |= ATTR_CTIME | ATTR_MTIME;
-
- cifs_truncate_page(inode->i_mapping, inode->i_size);
}
return rc;
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 4dd11eafb69d..13d060e0fc33 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -3526,8 +3526,6 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
if (rc == 0) {
netfs_resize_file(&cifsi->netfs, new_eof, true);
cifs_setsize(inode, new_eof);
- cifs_truncate_page(inode->i_mapping, inode->i_size);
- truncate_setsize(inode, new_eof);
}
goto out;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cifs: Remove cifs_truncate_page() as it should be superfluous
2025-04-01 15:01 [PATCH] cifs: Remove cifs_truncate_page() as it should be superfluous David Howells
@ 2025-04-02 15:23 ` Paulo Alcantara
0 siblings, 0 replies; 2+ messages in thread
From: Paulo Alcantara @ 2025-04-02 15:23 UTC (permalink / raw)
To: David Howells, Steve French
Cc: dhowells, Matthew Wilcox, linux-cifs, netfs, linux-fsdevel,
linux-kernel
David Howells <dhowells@redhat.com> writes:
> The calls to cifs_truncate_page() should be superfluous as the places that
> call it also call truncate_setsize() or cifs_setsize() and therefore
> truncate_pagecache() which should also clear the tail part of the folio
> containing the EOF marker.
>
> Further, smb3_simple_falloc() calls both cifs_setsize() and
> truncate_setsize() in addition to cifs_truncate_page().
>
> Remove the superfluous calls.
>
> This gets rid of another function referring to struct page.
>
> [Should cifs_setsize() also set inode->i_blocks?]
I don't think that's necessary as the current inode will be marked for
revalidation (e.g. cifsInodeInfo::time is set to 0), so next call to
cifs_fattr_to_inode() will update inode->i_blocks. If it isn't being
updated, then I'm missing something else.
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Steve French <stfrench@microsoft.com>
> cc: Paulo Alcantara (Red Hat) <pc@manguebit.com>
> cc: Matthew Wilcox <willy@infradead.org>
> cc: linux-cifs@vger.kernel.org
> cc: netfs@lists.linux.dev
> cc: linux-fsdevel@vger.kernel.org
> ---
> fs/smb/client/cifsfs.h | 1 -
> fs/smb/client/inode.c | 19 -------------------
> fs/smb/client/smb2ops.c | 2 --
> 3 files changed, 22 deletions(-)
Looks good,
Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-02 15:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01 15:01 [PATCH] cifs: Remove cifs_truncate_page() as it should be superfluous David Howells
2025-04-02 15:23 ` Paulo Alcantara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).