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 buf->content, in cachefiles_set_object_xattr()
82 if (ret != -ENOMEM) in cachefiles_set_object_xattr()
87 trace_cachefiles_coherency(object, file_inode(file)->i_ino, in cachefiles_set_object_xattr()
88 buf->content, in cachefiles_set_object_xattr()
98 * check the consistency between the backing cache and the FS-Cache cookie
103 struct dentry *dentry = file->f_path.dentry; in cachefiles_check_auxdata()
104 unsigned int len = object->cookie->aux_len, tlen; in cachefiles_check_auxdata()
105 const void *p = fscache_get_aux(object->cookie); in cachefiles_check_auxdata()
107 ssize_t xlen; in cachefiles_check_auxdata() local
108 int ret = -ESTALE; in cachefiles_check_auxdata()
113 return -ENOMEM; in cachefiles_check_auxdata()
115 xlen = cachefiles_inject_read_error(); in cachefiles_check_auxdata()
116 if (xlen == 0) in cachefiles_check_auxdata()
117 xlen = vfs_getxattr(&nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, tlen); in cachefiles_check_auxdata()
118 if (xlen != tlen) { in cachefiles_check_auxdata()
119 if (xlen < 0) { in cachefiles_check_auxdata()
120 ret = xlen; in cachefiles_check_auxdata()
121 trace_cachefiles_vfs_error(object, file_inode(file), xlen, in cachefiles_check_auxdata()
124 if (xlen == -EIO) in cachefiles_check_auxdata()
127 "Failed to read aux with error %zd", xlen); in cachefiles_check_auxdata()
129 } else if (buf->type != CACHEFILES_COOKIE_TYPE_DATA) { in cachefiles_check_auxdata()
131 } else if (memcmp(buf->data, p, len) != 0) { in cachefiles_check_auxdata()
133 } else if (be64_to_cpu(buf->object_size) != object->cookie->object_size) { in cachefiles_check_auxdata()
135 } else if (buf->content == CACHEFILES_CONTENT_DIRTY) { in cachefiles_check_auxdata()
144 trace_cachefiles_coherency(object, file_inode(file)->i_ino, in cachefiles_check_auxdata()
145 buf->content, why); in cachefiles_check_auxdata()
161 ret = mnt_want_write(cache->mnt); in cachefiles_remove_object_xattr()
165 mnt_drop_write(cache->mnt); in cachefiles_remove_object_xattr()
171 if (ret == -ENOENT || ret == -ENODATA) in cachefiles_remove_object_xattr()
173 else if (ret != -ENOMEM) in cachefiles_remove_object_xattr()
177 d_backing_inode(dentry)->i_ino, -ret); in cachefiles_remove_object_xattr()
190 struct cachefiles_object *object = cookie->cache_priv; in cachefiles_prepare_to_write()
191 struct cachefiles_cache *cache = object->volume->cache; in cachefiles_prepare_to_write()
193 _enter("c=%08x", object->cookie->debug_id); in cachefiles_prepare_to_write()
195 if (!test_bit(CACHEFILES_OBJECT_USING_TMPFILE, &object->flags)) { in cachefiles_prepare_to_write()
208 unsigned int len = volume->vcookie->coherency_len; in cachefiles_set_volume_xattr()
209 const void *p = volume->vcookie->coherency; in cachefiles_set_volume_xattr()
210 struct dentry *dentry = volume->dentry; in cachefiles_set_volume_xattr()
213 _enter("%x,#%d", volume->vcookie->debug_id, len); in cachefiles_set_volume_xattr()
219 buf->reserved = cpu_to_be32(0); in cachefiles_set_volume_xattr()
220 memcpy(buf->data, p, volume->vcookie->coherency_len); in cachefiles_set_volume_xattr()
224 ret = mnt_want_write(volume->cache->mnt); in cachefiles_set_volume_xattr()
229 mnt_drop_write(volume->cache->mnt); in cachefiles_set_volume_xattr()
235 trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino, in cachefiles_set_volume_xattr()
237 if (ret != -ENOMEM) in cachefiles_set_volume_xattr()
239 volume->cache, "Failed to set xattr with error %d", ret); in cachefiles_set_volume_xattr()
241 trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino, in cachefiles_set_volume_xattr()
256 struct dentry *dentry = volume->dentry; in cachefiles_check_volume_xattr()
257 unsigned int len = volume->vcookie->coherency_len; in cachefiles_check_volume_xattr()
258 const void *p = volume->vcookie->coherency; in cachefiles_check_volume_xattr()
260 ssize_t xlen; in cachefiles_check_volume_xattr() local
261 int ret = -ESTALE; in cachefiles_check_volume_xattr()
268 return -ENOMEM; in cachefiles_check_volume_xattr()
270 xlen = cachefiles_inject_read_error(); in cachefiles_check_volume_xattr()
271 if (xlen == 0) in cachefiles_check_volume_xattr()
272 xlen = vfs_getxattr(&nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, len); in cachefiles_check_volume_xattr()
273 if (xlen != len) { in cachefiles_check_volume_xattr()
274 if (xlen < 0) { in cachefiles_check_volume_xattr()
275 ret = xlen; in cachefiles_check_volume_xattr()
276 trace_cachefiles_vfs_error(NULL, d_inode(dentry), xlen, in cachefiles_check_volume_xattr()
278 if (xlen == -EIO) in cachefiles_check_volume_xattr()
280 volume->cache, in cachefiles_check_volume_xattr()
281 "Failed to read xattr with error %zd", xlen); in cachefiles_check_volume_xattr()
284 } else if (buf->reserved != cpu_to_be32(0)) { in cachefiles_check_volume_xattr()
286 } else if (memcmp(buf->data, p, len - sizeof(*buf)) != 0) { in cachefiles_check_volume_xattr()
293 trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino, why); in cachefiles_check_volume_xattr()