Skip to content

Commit 69c3c02

Browse files
committed
cifs: Implement netfslib hooks
Provide implementation of the netfslib hooks that will be used by netfslib to ask cifs to set up and perform operations. Of particular note are (*) cifs_clamp_length() - This is used to negotiate the size of the next subrequest in a read request, taking into account the credit available and the rsize. The credits are attached to the subrequest. (*) cifs_req_issue_read() - This is used to issue a subrequest that has been set up and clamped. (*) cifs_prepare_write() - This prepares to fill a subrequest by picking a channel, reopening the file and requesting credits so that we can set the maximum size of the subrequest and also sets the maximum number of segments if we're doing RDMA. (*) cifs_issue_write() - This releases any unneeded credits and issues an asynchronous data write for the contiguous slice of file covered by the subrequest. This should possibly be folded in to all ->async_writev() ops and that called directly. (*) cifs_begin_writeback() - This gets the cached writable handle through which we do writeback (this does not affect writethrough, unbuffered or direct writes). At this point, cifs is not wired up to actually *use* netfslib; that will be done in a subsequent patch. Signed-off-by: David Howells <[email protected]> cc: Steve French <[email protected]> cc: Shyam Prasad N <[email protected]> cc: Rohith Surabattula <[email protected]> cc: Jeff Layton <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected]
1 parent c20c0d7 commit 69c3c02

File tree

8 files changed

+345
-10
lines changed

8 files changed

+345
-10
lines changed

fs/netfs/buffered_write.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
405405
} while (iov_iter_count(iter));
406406

407407
out:
408+
if (likely(written) && ctx->ops->post_modify)
409+
ctx->ops->post_modify(inode);
410+
408411
if (unlikely(wreq)) {
409412
ret2 = netfs_end_writethrough(wreq, &wbc, writethrough);
410413
wbc_detach_inode(&wbc);
@@ -521,6 +524,7 @@ vm_fault_t netfs_page_mkwrite(struct vm_fault *vmf, struct netfs_group *netfs_gr
521524
struct folio *folio = page_folio(vmf->page);
522525
struct file *file = vmf->vma->vm_file;
523526
struct inode *inode = file_inode(file);
527+
struct netfs_inode *ictx = netfs_inode(inode);
524528
vm_fault_t ret = VM_FAULT_RETRY;
525529
int err;
526530

@@ -567,6 +571,8 @@ vm_fault_t netfs_page_mkwrite(struct vm_fault *vmf, struct netfs_group *netfs_gr
567571
trace_netfs_folio(folio, netfs_folio_trace_mkwrite);
568572
netfs_set_group(folio, netfs_group);
569573
file_update_time(file);
574+
if (ictx->ops->post_modify)
575+
ictx->ops->post_modify(inode);
570576
ret = VM_FAULT_LOCKED;
571577
out:
572578
sb_end_pagefault(inode->i_sb);

fs/smb/client/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
config CIFS
33
tristate "SMB3 and CIFS support (advanced network filesystem)"
44
depends on INET
5+
select NETFS_SUPPORT
56
select NLS
67
select NLS_UCS2_UTILS
78
select CRYPTO

fs/smb/client/cifsfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,7 @@ static int cifs_init_netfs(void)
17581758
{
17591759
cifs_io_request_cachep =
17601760
kmem_cache_create("cifs_io_request",
1761-
sizeof(struct netfs_io_request), 0,
1761+
sizeof(struct cifs_io_request), 0,
17621762
SLAB_HWCACHE_ALIGN, NULL);
17631763
if (!cifs_io_request_cachep)
17641764
goto nomem_req;

fs/smb/client/cifsfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extern const struct inode_operations cifs_namespace_inode_operations;
8484

8585

8686
/* Functions related to files and directories */
87+
extern const struct netfs_request_ops cifs_req_ops;
8788
extern const struct file_operations cifs_file_ops;
8889
extern const struct file_operations cifs_file_direct_ops; /* if directio mnt */
8990
extern const struct file_operations cifs_file_strict_ops; /* if strictio mnt */

fs/smb/client/cifsglob.h

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,31 +1491,41 @@ struct cifs_aio_ctx {
14911491
bool direct_io;
14921492
};
14931493

1494+
struct cifs_io_request {
1495+
struct netfs_io_request rreq;
1496+
struct cifsFileInfo *cfile;
1497+
};
1498+
14941499
/* asynchronous read support */
14951500
struct cifs_io_subrequest {
1496-
struct netfs_io_subrequest subreq;
1497-
struct cifsFileInfo *cfile;
1498-
struct address_space *mapping;
1499-
struct cifs_aio_ctx *ctx;
1501+
union {
1502+
struct netfs_io_subrequest subreq;
1503+
struct netfs_io_request *rreq;
1504+
struct cifs_io_request *req;
1505+
};
15001506
ssize_t got_bytes;
15011507
pid_t pid;
1508+
unsigned int xid;
15021509
int result;
1510+
bool have_xid;
1511+
bool replay;
15031512
struct kvec iov[2];
15041513
struct TCP_Server_Info *server;
15051514
#ifdef CONFIG_CIFS_SMB_DIRECT
15061515
struct smbd_mr *mr;
15071516
#endif
15081517
struct cifs_credits credits;
15091518

1510-
enum writeback_sync_modes sync_mode;
1511-
bool uncached;
1512-
bool replay;
1513-
struct bio_vec *bv;
1514-
15151519
// TODO: Remove following elements
15161520
struct list_head list;
15171521
struct completion done;
15181522
struct work_struct work;
1523+
struct cifsFileInfo *cfile;
1524+
struct address_space *mapping;
1525+
struct cifs_aio_ctx *ctx;
1526+
enum writeback_sync_modes sync_mode;
1527+
bool uncached;
1528+
struct bio_vec *bv;
15191529
};
15201530

15211531
/*

0 commit comments

Comments
 (0)