smb3: reenable swapfiles over SMB3 mounts

With the changes to folios/netfs it is now easier to reenable
swapfile support over SMB3 which fixes various xfstests

Reviewed-by: David Howells <dhowells@redhat.com>
Suggested-by: David Howells <dhowells@redhat.com>
Fixes: e1209d3a7a67 ("mm: introduce ->swap_rw and use it for reads from SWP_FS_OPS swap-space")
Signed-off-by: Steve French <stfrench@microsoft.com>

+27 -1
+2 -1
fs/netfs/direct_write.c
··· 27 27 * Perform an unbuffered write where we may have to do an RMW operation on an 28 28 * encrypted file. This can also be used for direct I/O writes. 29 29 */ 30 - static ssize_t netfs_unbuffered_write_iter_locked(struct kiocb *iocb, struct iov_iter *iter, 30 + ssize_t netfs_unbuffered_write_iter_locked(struct kiocb *iocb, struct iov_iter *iter, 31 31 struct netfs_group *netfs_group) 32 32 { 33 33 struct netfs_io_request *wreq; ··· 117 117 netfs_put_request(wreq, false, netfs_rreq_trace_put_return); 118 118 return ret; 119 119 } 120 + EXPORT_SYMBOL(netfs_unbuffered_write_iter_locked); 120 121 121 122 /** 122 123 * netfs_unbuffered_write_iter - Unbuffered write to a file
+23
fs/smb/client/file.c
··· 3189 3189 /* do we need to unpin (or unlock) the file */ 3190 3190 } 3191 3191 3192 + /** 3193 + * cifs_swap_rw - SMB3 address space operation for swap I/O 3194 + * @iocb: target I/O control block 3195 + * @iter: I/O buffer 3196 + * 3197 + * Perform IO to the swap-file. This is much like direct IO. 3198 + */ 3199 + static int cifs_swap_rw(struct kiocb *iocb, struct iov_iter *iter) 3200 + { 3201 + ssize_t ret; 3202 + 3203 + WARN_ON_ONCE(iov_iter_count(iter) != PAGE_SIZE); 3204 + 3205 + if (iov_iter_rw(iter) == READ) 3206 + ret = netfs_unbuffered_read_iter_locked(iocb, iter); 3207 + else 3208 + ret = netfs_unbuffered_write_iter_locked(iocb, iter, NULL); 3209 + if (ret < 0) 3210 + return ret; 3211 + return 0; 3212 + } 3213 + 3192 3214 const struct address_space_operations cifs_addr_ops = { 3193 3215 .read_folio = netfs_read_folio, 3194 3216 .readahead = netfs_readahead, ··· 3226 3204 */ 3227 3205 .swap_activate = cifs_swap_activate, 3228 3206 .swap_deactivate = cifs_swap_deactivate, 3207 + .swap_rw = cifs_swap_rw, 3229 3208 }; 3230 3209 3231 3210 /*
+2
include/linux/netfs.h
··· 400 400 ssize_t netfs_buffered_write_iter_locked(struct kiocb *iocb, struct iov_iter *from, 401 401 struct netfs_group *netfs_group); 402 402 ssize_t netfs_unbuffered_write_iter(struct kiocb *iocb, struct iov_iter *from); 403 + ssize_t netfs_unbuffered_write_iter_locked(struct kiocb *iocb, struct iov_iter *iter, 404 + struct netfs_group *netfs_group); 403 405 ssize_t netfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from); 404 406 405 407 /* Address operations API */