Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cifs: Add some helper functions

Add some helper functions to manipulate the folio marks by iterating
through a list of folios held in an xarray rather than using a page list.

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

Link: https://lore.kernel.org/r/164928616583.457102.15157033997163988344.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/165211418840.3154751.3090684430628501879.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/165348878940.2106726.204291614267188735.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/165364825674.3334034.3356201708659748648.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/166126394799.708021.10637797063862600488.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/166697258147.61150.9940790486999562110.stgit@warthog.procyon.org.uk/ # rfc
Link: https://lore.kernel.org/r/166732030314.3186319.9209944805565413627.stgit@warthog.procyon.org.uk/ # rfc
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

David Howells and committed by
Steve French
b8713c4d 39bc5820

+96
+3
fs/cifs/cifsfs.h
··· 113 113 extern const struct file_operations cifs_dir_ops; 114 114 extern int cifs_dir_open(struct inode *inode, struct file *file); 115 115 extern int cifs_readdir(struct file *file, struct dir_context *ctx); 116 + extern void cifs_pages_written_back(struct inode *inode, loff_t start, unsigned int len); 117 + extern void cifs_pages_write_failed(struct inode *inode, loff_t start, unsigned int len); 118 + extern void cifs_pages_write_redirty(struct inode *inode, loff_t start, unsigned int len); 116 119 117 120 /* Functions related to dir entries */ 118 121 extern const struct dentry_operations cifs_dentry_ops;
+93
fs/cifs/file.c
··· 37 37 #include "cached_dir.h" 38 38 39 39 /* 40 + * Completion of write to server. 41 + */ 42 + void cifs_pages_written_back(struct inode *inode, loff_t start, unsigned int len) 43 + { 44 + struct address_space *mapping = inode->i_mapping; 45 + struct folio *folio; 46 + pgoff_t end; 47 + 48 + XA_STATE(xas, &mapping->i_pages, start / PAGE_SIZE); 49 + 50 + if (!len) 51 + return; 52 + 53 + rcu_read_lock(); 54 + 55 + end = (start + len - 1) / PAGE_SIZE; 56 + xas_for_each(&xas, folio, end) { 57 + if (!folio_test_writeback(folio)) { 58 + WARN_ONCE(1, "bad %x @%llx page %lx %lx\n", 59 + len, start, folio_index(folio), end); 60 + continue; 61 + } 62 + 63 + folio_detach_private(folio); 64 + folio_end_writeback(folio); 65 + } 66 + 67 + rcu_read_unlock(); 68 + } 69 + 70 + /* 71 + * Failure of write to server. 72 + */ 73 + void cifs_pages_write_failed(struct inode *inode, loff_t start, unsigned int len) 74 + { 75 + struct address_space *mapping = inode->i_mapping; 76 + struct folio *folio; 77 + pgoff_t end; 78 + 79 + XA_STATE(xas, &mapping->i_pages, start / PAGE_SIZE); 80 + 81 + if (!len) 82 + return; 83 + 84 + rcu_read_lock(); 85 + 86 + end = (start + len - 1) / PAGE_SIZE; 87 + xas_for_each(&xas, folio, end) { 88 + if (!folio_test_writeback(folio)) { 89 + WARN_ONCE(1, "bad %x @%llx page %lx %lx\n", 90 + len, start, folio_index(folio), end); 91 + continue; 92 + } 93 + 94 + folio_set_error(folio); 95 + folio_end_writeback(folio); 96 + } 97 + 98 + rcu_read_unlock(); 99 + } 100 + 101 + /* 102 + * Redirty pages after a temporary failure. 103 + */ 104 + void cifs_pages_write_redirty(struct inode *inode, loff_t start, unsigned int len) 105 + { 106 + struct address_space *mapping = inode->i_mapping; 107 + struct folio *folio; 108 + pgoff_t end; 109 + 110 + XA_STATE(xas, &mapping->i_pages, start / PAGE_SIZE); 111 + 112 + if (!len) 113 + return; 114 + 115 + rcu_read_lock(); 116 + 117 + end = (start + len - 1) / PAGE_SIZE; 118 + xas_for_each(&xas, folio, end) { 119 + if (!folio_test_writeback(folio)) { 120 + WARN_ONCE(1, "bad %x @%llx page %lx %lx\n", 121 + len, start, folio_index(folio), end); 122 + continue; 123 + } 124 + 125 + filemap_dirty_folio(folio->mapping, folio); 126 + folio_end_writeback(folio); 127 + } 128 + 129 + rcu_read_unlock(); 130 + } 131 + 132 + /* 40 133 * Mark as invalid, all open files on tree connections since they 41 134 * were closed when session to server was lost. 42 135 */