Suresh Jayaraman | 488f1d2d | 2010-07-05 18:12:15 +0530 | [diff] [blame] | 1 | /* |
| 2 | * fs/cifs/fscache.c - CIFS filesystem cache interface |
| 3 | * |
| 4 | * Copyright (c) 2010 Novell, Inc. |
Suresh Jayaraman | b81209d | 2010-11-24 17:49:06 +0530 | [diff] [blame] | 5 | * Author(s): Suresh Jayaraman <sjayaraman@suse.de> |
Suresh Jayaraman | 488f1d2d | 2010-07-05 18:12:15 +0530 | [diff] [blame] | 6 | * |
| 7 | * This library is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU Lesser General Public License as published |
| 9 | * by the Free Software Foundation; either version 2.1 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 15 | * the GNU Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public License |
| 18 | * along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | #include "fscache.h" |
| 22 | #include "cifsglob.h" |
| 23 | #include "cifs_debug.h" |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 24 | #include "cifs_fs_sb.h" |
Suresh Jayaraman | 488f1d2d | 2010-07-05 18:12:15 +0530 | [diff] [blame] | 25 | |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 26 | /* |
| 27 | * Key layout of CIFS server cache index object |
| 28 | */ |
| 29 | struct cifs_server_key { |
| 30 | struct { |
| 31 | uint16_t family; /* address family */ |
| 32 | __be16 port; /* IP port */ |
| 33 | } hdr; |
| 34 | union { |
| 35 | struct in_addr ipv4_addr; |
| 36 | struct in6_addr ipv6_addr; |
| 37 | }; |
| 38 | } __packed; |
| 39 | |
| 40 | /* |
| 41 | * Get a cookie for a server object keyed by {IPaddress,port,family} tuple |
| 42 | */ |
Suresh Jayaraman | 488f1d2d | 2010-07-05 18:12:15 +0530 | [diff] [blame] | 43 | void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server) |
| 44 | { |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 45 | const struct sockaddr *sa = (struct sockaddr *) &server->dstaddr; |
| 46 | const struct sockaddr_in *addr = (struct sockaddr_in *) sa; |
| 47 | const struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) sa; |
| 48 | struct cifs_server_key key; |
| 49 | uint16_t key_len = sizeof(key.hdr); |
| 50 | |
| 51 | memset(&key, 0, sizeof(key)); |
| 52 | |
| 53 | /* |
| 54 | * Should not be a problem as sin_family/sin6_family overlays |
| 55 | * sa_family field |
| 56 | */ |
| 57 | key.hdr.family = sa->sa_family; |
| 58 | switch (sa->sa_family) { |
| 59 | case AF_INET: |
| 60 | key.hdr.port = addr->sin_port; |
| 61 | key.ipv4_addr = addr->sin_addr; |
| 62 | key_len += sizeof(key.ipv4_addr); |
| 63 | break; |
| 64 | |
| 65 | case AF_INET6: |
| 66 | key.hdr.port = addr6->sin6_port; |
| 67 | key.ipv6_addr = addr6->sin6_addr; |
| 68 | key_len += sizeof(key.ipv6_addr); |
| 69 | break; |
| 70 | |
| 71 | default: |
| 72 | cifs_dbg(VFS, "Unknown network family '%d'\n", sa->sa_family); |
| 73 | server->fscache = NULL; |
| 74 | return; |
| 75 | } |
| 76 | |
Suresh Jayaraman | 488f1d2d | 2010-07-05 18:12:15 +0530 | [diff] [blame] | 77 | server->fscache = |
| 78 | fscache_acquire_cookie(cifs_fscache_netfs.primary_index, |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 79 | &cifs_fscache_server_index_def, |
| 80 | &key, key_len, |
| 81 | NULL, 0, |
David Howells | ee1235a | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 82 | server, 0, true); |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 83 | cifs_dbg(FYI, "%s: (0x%p/0x%p)\n", |
| 84 | __func__, server, server->fscache); |
Suresh Jayaraman | 488f1d2d | 2010-07-05 18:12:15 +0530 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | void cifs_fscache_release_client_cookie(struct TCP_Server_Info *server) |
| 88 | { |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 89 | cifs_dbg(FYI, "%s: (0x%p/0x%p)\n", |
| 90 | __func__, server, server->fscache); |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 91 | fscache_relinquish_cookie(server->fscache, NULL, false); |
Suresh Jayaraman | 488f1d2d | 2010-07-05 18:12:15 +0530 | [diff] [blame] | 92 | server->fscache = NULL; |
| 93 | } |
| 94 | |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 95 | void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon) |
Suresh Jayaraman | d03382c | 2010-07-05 18:12:27 +0530 | [diff] [blame] | 96 | { |
| 97 | struct TCP_Server_Info *server = tcon->ses->server; |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 98 | char *sharename; |
| 99 | |
| 100 | sharename = extract_sharename(tcon->treeName); |
| 101 | if (IS_ERR(sharename)) { |
| 102 | cifs_dbg(FYI, "%s: couldn't extract sharename\n", __func__); |
| 103 | tcon->fscache = NULL; |
| 104 | return; |
| 105 | } |
Suresh Jayaraman | d03382c | 2010-07-05 18:12:27 +0530 | [diff] [blame] | 106 | |
| 107 | tcon->fscache = |
| 108 | fscache_acquire_cookie(server->fscache, |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 109 | &cifs_fscache_super_index_def, |
| 110 | sharename, strlen(sharename), |
| 111 | &tcon->resource_id, sizeof(tcon->resource_id), |
David Howells | ee1235a | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 112 | tcon, 0, true); |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 113 | kfree(sharename); |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 114 | cifs_dbg(FYI, "%s: (0x%p/0x%p)\n", |
| 115 | __func__, server->fscache, tcon->fscache); |
Suresh Jayaraman | d03382c | 2010-07-05 18:12:27 +0530 | [diff] [blame] | 116 | } |
| 117 | |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 118 | void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon) |
Suresh Jayaraman | d03382c | 2010-07-05 18:12:27 +0530 | [diff] [blame] | 119 | { |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 120 | cifs_dbg(FYI, "%s: (0x%p)\n", __func__, tcon->fscache); |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 121 | fscache_relinquish_cookie(tcon->fscache, &tcon->resource_id, false); |
Suresh Jayaraman | d03382c | 2010-07-05 18:12:27 +0530 | [diff] [blame] | 122 | tcon->fscache = NULL; |
| 123 | } |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 124 | |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 125 | static void cifs_fscache_acquire_inode_cookie(struct cifsInodeInfo *cifsi, |
| 126 | struct cifs_tcon *tcon) |
| 127 | { |
| 128 | struct cifs_fscache_inode_auxdata auxdata; |
| 129 | |
| 130 | memset(&auxdata, 0, sizeof(auxdata)); |
| 131 | auxdata.eof = cifsi->server_eof; |
Arnd Bergmann | cbedead | 2018-06-19 17:27:59 +0200 | [diff] [blame] | 132 | auxdata.last_write_time_sec = cifsi->vfs_inode.i_mtime.tv_sec; |
| 133 | auxdata.last_change_time_sec = cifsi->vfs_inode.i_ctime.tv_sec; |
| 134 | auxdata.last_write_time_nsec = cifsi->vfs_inode.i_mtime.tv_nsec; |
| 135 | auxdata.last_change_time_nsec = cifsi->vfs_inode.i_ctime.tv_nsec; |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 136 | |
| 137 | cifsi->fscache = |
| 138 | fscache_acquire_cookie(tcon->fscache, |
| 139 | &cifs_fscache_inode_object_def, |
| 140 | &cifsi->uniqueid, sizeof(cifsi->uniqueid), |
| 141 | &auxdata, sizeof(auxdata), |
David Howells | ee1235a | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 142 | cifsi, cifsi->vfs_inode.i_size, true); |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 143 | } |
| 144 | |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 145 | static void cifs_fscache_enable_inode_cookie(struct inode *inode) |
| 146 | { |
| 147 | struct cifsInodeInfo *cifsi = CIFS_I(inode); |
| 148 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 149 | struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 150 | |
| 151 | if (cifsi->fscache) |
| 152 | return; |
| 153 | |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 154 | if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE)) |
| 155 | return; |
| 156 | |
| 157 | cifs_fscache_acquire_inode_cookie(cifsi, tcon); |
| 158 | |
| 159 | cifs_dbg(FYI, "%s: got FH cookie (0x%p/0x%p)\n", |
| 160 | __func__, tcon->fscache, cifsi->fscache); |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | void cifs_fscache_release_inode_cookie(struct inode *inode) |
| 164 | { |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 165 | struct cifs_fscache_inode_auxdata auxdata; |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 166 | struct cifsInodeInfo *cifsi = CIFS_I(inode); |
| 167 | |
| 168 | if (cifsi->fscache) { |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 169 | memset(&auxdata, 0, sizeof(auxdata)); |
| 170 | auxdata.eof = cifsi->server_eof; |
Arnd Bergmann | cbedead | 2018-06-19 17:27:59 +0200 | [diff] [blame] | 171 | auxdata.last_write_time_sec = cifsi->vfs_inode.i_mtime.tv_sec; |
| 172 | auxdata.last_change_time_sec = cifsi->vfs_inode.i_ctime.tv_sec; |
| 173 | auxdata.last_write_time_nsec = cifsi->vfs_inode.i_mtime.tv_nsec; |
| 174 | auxdata.last_change_time_nsec = cifsi->vfs_inode.i_ctime.tv_nsec; |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 175 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 176 | cifs_dbg(FYI, "%s: (0x%p)\n", __func__, cifsi->fscache); |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 177 | fscache_relinquish_cookie(cifsi->fscache, &auxdata, false); |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 178 | cifsi->fscache = NULL; |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | static void cifs_fscache_disable_inode_cookie(struct inode *inode) |
| 183 | { |
| 184 | struct cifsInodeInfo *cifsi = CIFS_I(inode); |
| 185 | |
| 186 | if (cifsi->fscache) { |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 187 | cifs_dbg(FYI, "%s: (0x%p)\n", __func__, cifsi->fscache); |
David Howells | c902ce1 | 2011-07-07 12:19:48 +0100 | [diff] [blame] | 188 | fscache_uncache_all_inode_pages(cifsi->fscache, inode); |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 189 | fscache_relinquish_cookie(cifsi->fscache, NULL, true); |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 190 | cifsi->fscache = NULL; |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | void cifs_fscache_set_inode_cookie(struct inode *inode, struct file *filp) |
| 195 | { |
| 196 | if ((filp->f_flags & O_ACCMODE) != O_RDONLY) |
| 197 | cifs_fscache_disable_inode_cookie(inode); |
Suresh Jayaraman | b81209d | 2010-11-24 17:49:06 +0530 | [diff] [blame] | 198 | else |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 199 | cifs_fscache_enable_inode_cookie(inode); |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | void cifs_fscache_reset_inode_cookie(struct inode *inode) |
| 203 | { |
| 204 | struct cifsInodeInfo *cifsi = CIFS_I(inode); |
| 205 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 206 | struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 207 | struct fscache_cookie *old = cifsi->fscache; |
| 208 | |
| 209 | if (cifsi->fscache) { |
| 210 | /* retire the current fscache cache and get a new one */ |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 211 | fscache_relinquish_cookie(cifsi->fscache, NULL, true); |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 212 | |
David Howells | 402cb8d | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 213 | cifs_fscache_acquire_inode_cookie(cifsi, tcon); |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 214 | cifs_dbg(FYI, "%s: new cookie 0x%p oldcookie 0x%p\n", |
| 215 | __func__, cifsi->fscache, old); |
Suresh Jayaraman | 9451a9a | 2010-07-05 18:12:45 +0530 | [diff] [blame] | 216 | } |
| 217 | } |
Suresh Jayaraman | 85f2d6b | 2010-07-05 18:13:00 +0530 | [diff] [blame] | 218 | |
| 219 | int cifs_fscache_release_page(struct page *page, gfp_t gfp) |
| 220 | { |
| 221 | if (PageFsCache(page)) { |
| 222 | struct inode *inode = page->mapping->host; |
| 223 | struct cifsInodeInfo *cifsi = CIFS_I(inode); |
| 224 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 225 | cifs_dbg(FYI, "%s: (0x%p/0x%p)\n", |
| 226 | __func__, page, cifsi->fscache); |
Suresh Jayaraman | 85f2d6b | 2010-07-05 18:13:00 +0530 | [diff] [blame] | 227 | if (!fscache_maybe_release_page(cifsi->fscache, page, gfp)) |
| 228 | return 0; |
| 229 | } |
| 230 | |
| 231 | return 1; |
| 232 | } |
| 233 | |
Suresh Jayaraman | 56698236 | 2010-07-05 18:13:25 +0530 | [diff] [blame] | 234 | static void cifs_readpage_from_fscache_complete(struct page *page, void *ctx, |
| 235 | int error) |
| 236 | { |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 237 | cifs_dbg(FYI, "%s: (0x%p/%d)\n", __func__, page, error); |
Suresh Jayaraman | 56698236 | 2010-07-05 18:13:25 +0530 | [diff] [blame] | 238 | if (!error) |
| 239 | SetPageUptodate(page); |
| 240 | unlock_page(page); |
| 241 | } |
| 242 | |
| 243 | /* |
| 244 | * Retrieve a page from FS-Cache |
| 245 | */ |
| 246 | int __cifs_readpage_from_fscache(struct inode *inode, struct page *page) |
| 247 | { |
| 248 | int ret; |
| 249 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 250 | cifs_dbg(FYI, "%s: (fsc:%p, p:%p, i:0x%p\n", |
| 251 | __func__, CIFS_I(inode)->fscache, page, inode); |
Suresh Jayaraman | 56698236 | 2010-07-05 18:13:25 +0530 | [diff] [blame] | 252 | ret = fscache_read_or_alloc_page(CIFS_I(inode)->fscache, page, |
| 253 | cifs_readpage_from_fscache_complete, |
| 254 | NULL, |
| 255 | GFP_KERNEL); |
| 256 | switch (ret) { |
| 257 | |
| 258 | case 0: /* page found in fscache, read submitted */ |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 259 | cifs_dbg(FYI, "%s: submitted\n", __func__); |
Suresh Jayaraman | 56698236 | 2010-07-05 18:13:25 +0530 | [diff] [blame] | 260 | return ret; |
| 261 | case -ENOBUFS: /* page won't be cached */ |
| 262 | case -ENODATA: /* page not in cache */ |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 263 | cifs_dbg(FYI, "%s: %d\n", __func__, ret); |
Suresh Jayaraman | 56698236 | 2010-07-05 18:13:25 +0530 | [diff] [blame] | 264 | return 1; |
| 265 | |
| 266 | default: |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 267 | cifs_dbg(VFS, "unknown error ret = %d\n", ret); |
Suresh Jayaraman | 56698236 | 2010-07-05 18:13:25 +0530 | [diff] [blame] | 268 | } |
| 269 | return ret; |
| 270 | } |
| 271 | |
| 272 | /* |
| 273 | * Retrieve a set of pages from FS-Cache |
| 274 | */ |
| 275 | int __cifs_readpages_from_fscache(struct inode *inode, |
| 276 | struct address_space *mapping, |
| 277 | struct list_head *pages, |
| 278 | unsigned *nr_pages) |
| 279 | { |
| 280 | int ret; |
| 281 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 282 | cifs_dbg(FYI, "%s: (0x%p/%u/0x%p)\n", |
| 283 | __func__, CIFS_I(inode)->fscache, *nr_pages, inode); |
Suresh Jayaraman | 56698236 | 2010-07-05 18:13:25 +0530 | [diff] [blame] | 284 | ret = fscache_read_or_alloc_pages(CIFS_I(inode)->fscache, mapping, |
| 285 | pages, nr_pages, |
| 286 | cifs_readpage_from_fscache_complete, |
| 287 | NULL, |
| 288 | mapping_gfp_mask(mapping)); |
| 289 | switch (ret) { |
| 290 | case 0: /* read submitted to the cache for all pages */ |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 291 | cifs_dbg(FYI, "%s: submitted\n", __func__); |
Suresh Jayaraman | 56698236 | 2010-07-05 18:13:25 +0530 | [diff] [blame] | 292 | return ret; |
| 293 | |
| 294 | case -ENOBUFS: /* some pages are not cached and can't be */ |
| 295 | case -ENODATA: /* some pages are not cached */ |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 296 | cifs_dbg(FYI, "%s: no page\n", __func__); |
Suresh Jayaraman | 56698236 | 2010-07-05 18:13:25 +0530 | [diff] [blame] | 297 | return 1; |
| 298 | |
| 299 | default: |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 300 | cifs_dbg(FYI, "unknown error ret = %d\n", ret); |
Suresh Jayaraman | 56698236 | 2010-07-05 18:13:25 +0530 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | return ret; |
| 304 | } |
| 305 | |
Suresh Jayaraman | 9dc0655 | 2010-07-05 18:13:11 +0530 | [diff] [blame] | 306 | void __cifs_readpage_to_fscache(struct inode *inode, struct page *page) |
| 307 | { |
David Howells | ee1235a | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 308 | struct cifsInodeInfo *cifsi = CIFS_I(inode); |
Suresh Jayaraman | 9dc0655 | 2010-07-05 18:13:11 +0530 | [diff] [blame] | 309 | int ret; |
| 310 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 311 | cifs_dbg(FYI, "%s: (fsc: %p, p: %p, i: %p)\n", |
David Howells | ee1235a | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 312 | __func__, cifsi->fscache, page, inode); |
| 313 | ret = fscache_write_page(cifsi->fscache, page, |
| 314 | cifsi->vfs_inode.i_size, GFP_KERNEL); |
Suresh Jayaraman | 9dc0655 | 2010-07-05 18:13:11 +0530 | [diff] [blame] | 315 | if (ret != 0) |
David Howells | ee1235a | 2018-04-04 13:41:28 +0100 | [diff] [blame] | 316 | fscache_uncache_page(cifsi->fscache, page); |
Suresh Jayaraman | 9dc0655 | 2010-07-05 18:13:11 +0530 | [diff] [blame] | 317 | } |
| 318 | |
David Howells | 54afa99 | 2013-09-04 17:10:39 +0000 | [diff] [blame] | 319 | void __cifs_fscache_readpages_cancel(struct inode *inode, struct list_head *pages) |
| 320 | { |
| 321 | cifs_dbg(FYI, "%s: (fsc: %p, i: %p)\n", |
| 322 | __func__, CIFS_I(inode)->fscache, inode); |
| 323 | fscache_readpages_cancel(CIFS_I(inode)->fscache, pages); |
| 324 | } |
| 325 | |
Suresh Jayaraman | 85f2d6b | 2010-07-05 18:13:00 +0530 | [diff] [blame] | 326 | void __cifs_fscache_invalidate_page(struct page *page, struct inode *inode) |
| 327 | { |
| 328 | struct cifsInodeInfo *cifsi = CIFS_I(inode); |
| 329 | struct fscache_cookie *cookie = cifsi->fscache; |
| 330 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 331 | cifs_dbg(FYI, "%s: (0x%p/0x%p)\n", __func__, page, cookie); |
Suresh Jayaraman | 85f2d6b | 2010-07-05 18:13:00 +0530 | [diff] [blame] | 332 | fscache_wait_on_page_write(cookie, page); |
| 333 | fscache_uncache_page(cookie, page); |
| 334 | } |