Lines Matching +full:xlen +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0-or-later
18 #define CACHEFILES_COOKIE_TYPE_DATA 1
43 struct file *file = object->file; in cachefiles_set_object_xattr()
44 unsigned int len = object->cookie->aux_len; in cachefiles_set_object_xattr()
48 return -ESTALE; in cachefiles_set_object_xattr()
49 dentry = file->f_path.dentry; in cachefiles_set_object_xattr()
51 _enter("%x,#%d", object->debug_id, len); in cachefiles_set_object_xattr()
55 return -ENOMEM; in cachefiles_set_object_xattr()
57 buf->object_size = cpu_to_be64(object->cookie->object_size); in cachefiles_set_object_xattr()
58 buf->zero_point = 0; in cachefiles_set_object_xattr()
59 buf->type = CACHEFILES_COOKIE_TYPE_DATA; in cachefiles_set_object_xattr()
60 buf->content = object->content_info; in cachefiles_set_object_xattr()
61 if (test_bit(FSCACHE_COOKIE_LOCAL_WRITE, &object->cookie->flags)) in cachefiles_set_object_xattr()
62 buf->content = CACHEFILES_CONTENT_DIRTY; in cachefiles_set_object_xattr()
64 memcpy(buf->data, fscache_get_aux(object->cookie), len); in cachefiles_set_object_xattr()
79 trace_cachefiles_coherency(object, file_inode(file)->i_ino, in cachefiles_set_object_xattr()
80 be64_to_cpup((__be64 *)buf->data), in cachefiles_set_object_xattr()
81 buf->content, in cachefiles_set_object_xattr()
83 if (ret != -ENOMEM) in cachefiles_set_object_xattr()
88 trace_cachefiles_coherency(object, file_inode(file)->i_ino, in cachefiles_set_object_xattr()
89 be64_to_cpup((__be64 *)buf->data), in cachefiles_set_object_xattr()
90 buf->content, in cachefiles_set_object_xattr()
100 * check the consistency between the backing cache and the FS-Cache cookie
105 struct dentry *dentry = file->f_path.dentry; in cachefiles_check_auxdata()
106 unsigned int len = object->cookie->aux_len, tlen; in cachefiles_check_auxdata()
107 const void *p = fscache_get_aux(object->cookie); in cachefiles_check_auxdata()
109 ssize_t xlen; in cachefiles_check_auxdata() local
110 int ret = -ESTALE; in cachefiles_check_auxdata()
115 return -ENOMEM; in cachefiles_check_auxdata()
117 xlen = cachefiles_inject_read_error(); in cachefiles_check_auxdata()
118 if (xlen == 0) in cachefiles_check_auxdata()
119 xlen = vfs_getxattr(&nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, tlen); in cachefiles_check_auxdata()
120 if (xlen != tlen) { in cachefiles_check_auxdata()
121 if (xlen < 0) { in cachefiles_check_auxdata()
122 ret = xlen; in cachefiles_check_auxdata()
123 trace_cachefiles_vfs_error(object, file_inode(file), xlen, in cachefiles_check_auxdata()
126 if (xlen == -EIO) in cachefiles_check_auxdata()
129 "Failed to read aux with error %zd", xlen); in cachefiles_check_auxdata()
134 if (buf->type != CACHEFILES_COOKIE_TYPE_DATA) { in cachefiles_check_auxdata()
136 } else if (memcmp(buf->data, p, len) != 0) { in cachefiles_check_auxdata()
138 } else if (be64_to_cpu(buf->object_size) != object->cookie->object_size) { in cachefiles_check_auxdata()
140 } else if (buf->content == CACHEFILES_CONTENT_DIRTY) { in cachefiles_check_auxdata()
150 trace_cachefiles_coherency(object, file_inode(file)->i_ino, in cachefiles_check_auxdata()
151 be64_to_cpup((__be64 *)buf->data), in cachefiles_check_auxdata()
152 buf->content, why); in cachefiles_check_auxdata()
168 ret = mnt_want_write(cache->mnt); in cachefiles_remove_object_xattr()
172 mnt_drop_write(cache->mnt); in cachefiles_remove_object_xattr()
178 if (ret == -ENOENT || ret == -ENODATA) in cachefiles_remove_object_xattr()
180 else if (ret != -ENOMEM) in cachefiles_remove_object_xattr()
184 d_backing_inode(dentry)->i_ino, -ret); in cachefiles_remove_object_xattr()
197 struct cachefiles_object *object = cookie->cache_priv; in cachefiles_prepare_to_write()
198 struct cachefiles_cache *cache = object->volume->cache; in cachefiles_prepare_to_write()
200 _enter("c=%08x", object->cookie->debug_id); in cachefiles_prepare_to_write()
202 if (!test_bit(CACHEFILES_OBJECT_USING_TMPFILE, &object->flags)) { in cachefiles_prepare_to_write()
215 unsigned int len = volume->vcookie->coherency_len; in cachefiles_set_volume_xattr()
216 const void *p = volume->vcookie->coherency; in cachefiles_set_volume_xattr()
217 struct dentry *dentry = volume->dentry; in cachefiles_set_volume_xattr()
220 _enter("%x,#%d", volume->vcookie->debug_id, len); in cachefiles_set_volume_xattr()
226 buf->reserved = cpu_to_be32(0); in cachefiles_set_volume_xattr()
227 memcpy(buf->data, p, volume->vcookie->coherency_len); in cachefiles_set_volume_xattr()
231 ret = mnt_want_write(volume->cache->mnt); in cachefiles_set_volume_xattr()
236 mnt_drop_write(volume->cache->mnt); in cachefiles_set_volume_xattr()
242 trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino, in cachefiles_set_volume_xattr()
244 if (ret != -ENOMEM) in cachefiles_set_volume_xattr()
246 volume->cache, "Failed to set xattr with error %d", ret); in cachefiles_set_volume_xattr()
248 trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino, in cachefiles_set_volume_xattr()
263 struct dentry *dentry = volume->dentry; in cachefiles_check_volume_xattr()
264 unsigned int len = volume->vcookie->coherency_len; in cachefiles_check_volume_xattr()
265 const void *p = volume->vcookie->coherency; in cachefiles_check_volume_xattr()
267 ssize_t xlen; in cachefiles_check_volume_xattr() local
268 int ret = -ESTALE; in cachefiles_check_volume_xattr()
275 return -ENOMEM; in cachefiles_check_volume_xattr()
277 xlen = cachefiles_inject_read_error(); in cachefiles_check_volume_xattr()
278 if (xlen == 0) in cachefiles_check_volume_xattr()
279 xlen = vfs_getxattr(&nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, len); in cachefiles_check_volume_xattr()
280 if (xlen != len) { in cachefiles_check_volume_xattr()
281 if (xlen < 0) { in cachefiles_check_volume_xattr()
282 ret = xlen; in cachefiles_check_volume_xattr()
283 trace_cachefiles_vfs_error(NULL, d_inode(dentry), xlen, in cachefiles_check_volume_xattr()
285 if (xlen == -EIO) in cachefiles_check_volume_xattr()
287 volume->cache, in cachefiles_check_volume_xattr()
288 "Failed to read xattr with error %zd", xlen); in cachefiles_check_volume_xattr()
291 } else if (buf->reserved != cpu_to_be32(0)) { in cachefiles_check_volume_xattr()
293 } else if (memcmp(buf->data, p, len - sizeof(*buf)) != 0) { in cachefiles_check_volume_xattr()
300 trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino, why); in cachefiles_check_volume_xattr()