| .. | .. |
|---|
| 10 | 10 | |
|---|
| 11 | 11 | #include <linux/pagemap.h> |
|---|
| 12 | 12 | #include <linux/file.h> |
|---|
| 13 | +#include <linux/fs_context.h> |
|---|
| 13 | 14 | #include <linux/sched.h> |
|---|
| 14 | 15 | #include <linux/namei.h> |
|---|
| 15 | 16 | #include <linux/slab.h> |
|---|
| 16 | 17 | #include <linux/xattr.h> |
|---|
| 18 | +#include <linux/iversion.h> |
|---|
| 17 | 19 | #include <linux/posix_acl.h> |
|---|
| 18 | | - |
|---|
| 19 | | -static bool fuse_use_readdirplus(struct inode *dir, struct dir_context *ctx) |
|---|
| 20 | | -{ |
|---|
| 21 | | - struct fuse_conn *fc = get_fuse_conn(dir); |
|---|
| 22 | | - struct fuse_inode *fi = get_fuse_inode(dir); |
|---|
| 23 | | - |
|---|
| 24 | | - if (!fc->do_readdirplus) |
|---|
| 25 | | - return false; |
|---|
| 26 | | - if (!fc->readdirplus_auto) |
|---|
| 27 | | - return true; |
|---|
| 28 | | - if (test_and_clear_bit(FUSE_I_ADVISE_RDPLUS, &fi->state)) |
|---|
| 29 | | - return true; |
|---|
| 30 | | - if (ctx->pos == 0) |
|---|
| 31 | | - return true; |
|---|
| 32 | | - return false; |
|---|
| 33 | | -} |
|---|
| 34 | 20 | |
|---|
| 35 | 21 | static void fuse_advise_use_readdirplus(struct inode *dir) |
|---|
| 36 | 22 | { |
|---|
| .. | .. |
|---|
| 39 | 25 | set_bit(FUSE_I_ADVISE_RDPLUS, &fi->state); |
|---|
| 40 | 26 | } |
|---|
| 41 | 27 | |
|---|
| 28 | +#if BITS_PER_LONG >= 64 |
|---|
| 29 | +static inline void __fuse_dentry_settime(struct dentry *entry, u64 time) |
|---|
| 30 | +{ |
|---|
| 31 | + entry->d_fsdata = (void *) time; |
|---|
| 32 | +} |
|---|
| 33 | + |
|---|
| 34 | +static inline u64 fuse_dentry_time(const struct dentry *entry) |
|---|
| 35 | +{ |
|---|
| 36 | + return (u64)entry->d_fsdata; |
|---|
| 37 | +} |
|---|
| 38 | + |
|---|
| 39 | +#else |
|---|
| 42 | 40 | union fuse_dentry { |
|---|
| 43 | 41 | u64 time; |
|---|
| 44 | 42 | struct rcu_head rcu; |
|---|
| 45 | 43 | }; |
|---|
| 46 | 44 | |
|---|
| 47 | | -static inline void fuse_dentry_settime(struct dentry *entry, u64 time) |
|---|
| 45 | +static inline void __fuse_dentry_settime(struct dentry *dentry, u64 time) |
|---|
| 48 | 46 | { |
|---|
| 49 | | - ((union fuse_dentry *) entry->d_fsdata)->time = time; |
|---|
| 47 | + ((union fuse_dentry *) dentry->d_fsdata)->time = time; |
|---|
| 50 | 48 | } |
|---|
| 51 | 49 | |
|---|
| 52 | | -static inline u64 fuse_dentry_time(struct dentry *entry) |
|---|
| 50 | +static inline u64 fuse_dentry_time(const struct dentry *entry) |
|---|
| 53 | 51 | { |
|---|
| 54 | 52 | return ((union fuse_dentry *) entry->d_fsdata)->time; |
|---|
| 53 | +} |
|---|
| 54 | +#endif |
|---|
| 55 | + |
|---|
| 56 | +static void fuse_dentry_settime(struct dentry *dentry, u64 time) |
|---|
| 57 | +{ |
|---|
| 58 | + struct fuse_conn *fc = get_fuse_conn_super(dentry->d_sb); |
|---|
| 59 | + bool delete = !time && fc->delete_stale; |
|---|
| 60 | + /* |
|---|
| 61 | + * Mess with DCACHE_OP_DELETE because dput() will be faster without it. |
|---|
| 62 | + * Don't care about races, either way it's just an optimization |
|---|
| 63 | + */ |
|---|
| 64 | + if ((!delete && (dentry->d_flags & DCACHE_OP_DELETE)) || |
|---|
| 65 | + (delete && !(dentry->d_flags & DCACHE_OP_DELETE))) { |
|---|
| 66 | + spin_lock(&dentry->d_lock); |
|---|
| 67 | + if (!delete) |
|---|
| 68 | + dentry->d_flags &= ~DCACHE_OP_DELETE; |
|---|
| 69 | + else |
|---|
| 70 | + dentry->d_flags |= DCACHE_OP_DELETE; |
|---|
| 71 | + spin_unlock(&dentry->d_lock); |
|---|
| 72 | + } |
|---|
| 73 | + |
|---|
| 74 | + __fuse_dentry_settime(dentry, time); |
|---|
| 55 | 75 | } |
|---|
| 56 | 76 | |
|---|
| 57 | 77 | /* |
|---|
| .. | .. |
|---|
| 80 | 100 | * Set dentry and possibly attribute timeouts from the lookup/mk* |
|---|
| 81 | 101 | * replies |
|---|
| 82 | 102 | */ |
|---|
| 83 | | -static void fuse_change_entry_timeout(struct dentry *entry, |
|---|
| 84 | | - struct fuse_entry_out *o) |
|---|
| 103 | +void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o) |
|---|
| 85 | 104 | { |
|---|
| 86 | 105 | fuse_dentry_settime(entry, |
|---|
| 87 | 106 | time_to_jiffies(o->entry_valid, o->entry_valid_nsec)); |
|---|
| .. | .. |
|---|
| 92 | 111 | return time_to_jiffies(o->attr_valid, o->attr_valid_nsec); |
|---|
| 93 | 112 | } |
|---|
| 94 | 113 | |
|---|
| 95 | | -static u64 entry_attr_timeout(struct fuse_entry_out *o) |
|---|
| 114 | +u64 entry_attr_timeout(struct fuse_entry_out *o) |
|---|
| 96 | 115 | { |
|---|
| 97 | 116 | return time_to_jiffies(o->attr_valid, o->attr_valid_nsec); |
|---|
| 117 | +} |
|---|
| 118 | + |
|---|
| 119 | +static void fuse_invalidate_attr_mask(struct inode *inode, u32 mask) |
|---|
| 120 | +{ |
|---|
| 121 | + set_mask_bits(&get_fuse_inode(inode)->inval_mask, 0, mask); |
|---|
| 98 | 122 | } |
|---|
| 99 | 123 | |
|---|
| 100 | 124 | /* |
|---|
| .. | .. |
|---|
| 103 | 127 | */ |
|---|
| 104 | 128 | void fuse_invalidate_attr(struct inode *inode) |
|---|
| 105 | 129 | { |
|---|
| 106 | | - get_fuse_inode(inode)->i_time = 0; |
|---|
| 130 | + fuse_invalidate_attr_mask(inode, STATX_BASIC_STATS); |
|---|
| 131 | +} |
|---|
| 132 | + |
|---|
| 133 | +static void fuse_dir_changed(struct inode *dir) |
|---|
| 134 | +{ |
|---|
| 135 | + fuse_invalidate_attr(dir); |
|---|
| 136 | + inode_maybe_inc_iversion(dir, false); |
|---|
| 107 | 137 | } |
|---|
| 108 | 138 | |
|---|
| 109 | 139 | /** |
|---|
| .. | .. |
|---|
| 113 | 143 | void fuse_invalidate_atime(struct inode *inode) |
|---|
| 114 | 144 | { |
|---|
| 115 | 145 | if (!IS_RDONLY(inode)) |
|---|
| 116 | | - fuse_invalidate_attr(inode); |
|---|
| 146 | + fuse_invalidate_attr_mask(inode, STATX_ATIME); |
|---|
| 117 | 147 | } |
|---|
| 118 | 148 | |
|---|
| 119 | 149 | /* |
|---|
| .. | .. |
|---|
| 144 | 174 | struct fuse_entry_out *outarg) |
|---|
| 145 | 175 | { |
|---|
| 146 | 176 | memset(outarg, 0, sizeof(struct fuse_entry_out)); |
|---|
| 147 | | - args->in.h.opcode = FUSE_LOOKUP; |
|---|
| 148 | | - args->in.h.nodeid = nodeid; |
|---|
| 149 | | - args->in.numargs = 1; |
|---|
| 150 | | - args->in.args[0].size = name->len + 1; |
|---|
| 151 | | - args->in.args[0].value = name->name; |
|---|
| 152 | | - args->out.numargs = 1; |
|---|
| 153 | | - args->out.args[0].size = sizeof(struct fuse_entry_out); |
|---|
| 154 | | - args->out.args[0].value = outarg; |
|---|
| 155 | | -} |
|---|
| 156 | | - |
|---|
| 157 | | -u64 fuse_get_attr_version(struct fuse_conn *fc) |
|---|
| 158 | | -{ |
|---|
| 159 | | - u64 curr_version; |
|---|
| 160 | | - |
|---|
| 161 | | - /* |
|---|
| 162 | | - * The spin lock isn't actually needed on 64bit archs, but we |
|---|
| 163 | | - * don't yet care too much about such optimizations. |
|---|
| 164 | | - */ |
|---|
| 165 | | - spin_lock(&fc->lock); |
|---|
| 166 | | - curr_version = fc->attr_version; |
|---|
| 167 | | - spin_unlock(&fc->lock); |
|---|
| 168 | | - |
|---|
| 169 | | - return curr_version; |
|---|
| 177 | + args->opcode = FUSE_LOOKUP; |
|---|
| 178 | + args->nodeid = nodeid; |
|---|
| 179 | + args->in_numargs = 1; |
|---|
| 180 | + args->in_args[0].size = name->len + 1; |
|---|
| 181 | + args->in_args[0].value = name->name; |
|---|
| 182 | + args->out_numargs = 1; |
|---|
| 183 | + args->out_args[0].size = sizeof(struct fuse_entry_out); |
|---|
| 184 | + args->out_args[0].value = outarg; |
|---|
| 170 | 185 | } |
|---|
| 171 | 186 | |
|---|
| 172 | 187 | /* |
|---|
| .. | .. |
|---|
| 182 | 197 | { |
|---|
| 183 | 198 | struct inode *inode; |
|---|
| 184 | 199 | struct dentry *parent; |
|---|
| 185 | | - struct fuse_conn *fc; |
|---|
| 200 | + struct fuse_mount *fm; |
|---|
| 186 | 201 | struct fuse_inode *fi; |
|---|
| 187 | 202 | int ret; |
|---|
| 188 | 203 | |
|---|
| .. | .. |
|---|
| 190 | 205 | if (inode && fuse_is_bad(inode)) |
|---|
| 191 | 206 | goto invalid; |
|---|
| 192 | 207 | else if (time_before64(fuse_dentry_time(entry), get_jiffies_64()) || |
|---|
| 193 | | - (flags & LOOKUP_REVAL)) { |
|---|
| 208 | + (flags & (LOOKUP_EXCL | LOOKUP_REVAL))) { |
|---|
| 194 | 209 | struct fuse_entry_out outarg; |
|---|
| 195 | 210 | FUSE_ARGS(args); |
|---|
| 196 | 211 | struct fuse_forget_link *forget; |
|---|
| .. | .. |
|---|
| 204 | 219 | if (flags & LOOKUP_RCU) |
|---|
| 205 | 220 | goto out; |
|---|
| 206 | 221 | |
|---|
| 207 | | - fc = get_fuse_conn(inode); |
|---|
| 222 | + fm = get_fuse_mount(inode); |
|---|
| 208 | 223 | |
|---|
| 209 | 224 | forget = fuse_alloc_forget(); |
|---|
| 210 | 225 | ret = -ENOMEM; |
|---|
| 211 | 226 | if (!forget) |
|---|
| 212 | 227 | goto out; |
|---|
| 213 | 228 | |
|---|
| 214 | | - attr_version = fuse_get_attr_version(fc); |
|---|
| 229 | + attr_version = fuse_get_attr_version(fm->fc); |
|---|
| 215 | 230 | |
|---|
| 216 | 231 | parent = dget_parent(entry); |
|---|
| 217 | | - fuse_lookup_init(fc, &args, get_node_id(d_inode(parent)), |
|---|
| 232 | + fuse_lookup_init(fm->fc, &args, get_node_id(d_inode(parent)), |
|---|
| 218 | 233 | &entry->d_name, &outarg); |
|---|
| 219 | | - ret = fuse_simple_request(fc, &args); |
|---|
| 234 | + ret = fuse_simple_request(fm, &args); |
|---|
| 220 | 235 | dput(parent); |
|---|
| 221 | 236 | /* Zero nodeid is same as -ENOENT */ |
|---|
| 222 | 237 | if (!ret && !outarg.nodeid) |
|---|
| 223 | 238 | ret = -ENOENT; |
|---|
| 224 | 239 | if (!ret) { |
|---|
| 225 | 240 | fi = get_fuse_inode(inode); |
|---|
| 226 | | - if (outarg.nodeid != get_node_id(inode)) { |
|---|
| 227 | | - fuse_queue_forget(fc, forget, outarg.nodeid, 1); |
|---|
| 241 | + if (outarg.nodeid != get_node_id(inode) || |
|---|
| 242 | + (bool) IS_AUTOMOUNT(inode) != (bool) (outarg.attr.flags & FUSE_ATTR_SUBMOUNT)) { |
|---|
| 243 | + fuse_queue_forget(fm->fc, forget, |
|---|
| 244 | + outarg.nodeid, 1); |
|---|
| 228 | 245 | goto invalid; |
|---|
| 229 | 246 | } |
|---|
| 230 | | - spin_lock(&fc->lock); |
|---|
| 247 | + spin_lock(&fi->lock); |
|---|
| 231 | 248 | fi->nlookup++; |
|---|
| 232 | | - spin_unlock(&fc->lock); |
|---|
| 249 | + spin_unlock(&fi->lock); |
|---|
| 233 | 250 | } |
|---|
| 234 | 251 | kfree(forget); |
|---|
| 235 | 252 | if (ret == -ENOMEM) |
|---|
| 236 | 253 | goto out; |
|---|
| 237 | 254 | if (ret || fuse_invalid_attr(&outarg.attr) || |
|---|
| 238 | | - (outarg.attr.mode ^ inode->i_mode) & S_IFMT) |
|---|
| 255 | + fuse_stale_inode(inode, outarg.generation, &outarg.attr)) |
|---|
| 239 | 256 | goto invalid; |
|---|
| 240 | 257 | |
|---|
| 241 | 258 | forget_all_cached_acls(inode); |
|---|
| .. | .. |
|---|
| 263 | 280 | goto out; |
|---|
| 264 | 281 | } |
|---|
| 265 | 282 | |
|---|
| 266 | | -static int invalid_nodeid(u64 nodeid) |
|---|
| 267 | | -{ |
|---|
| 268 | | - return !nodeid || nodeid == FUSE_ROOT_ID; |
|---|
| 269 | | -} |
|---|
| 270 | | - |
|---|
| 283 | +#if BITS_PER_LONG < 64 |
|---|
| 271 | 284 | static int fuse_dentry_init(struct dentry *dentry) |
|---|
| 272 | 285 | { |
|---|
| 273 | | - dentry->d_fsdata = kzalloc(sizeof(union fuse_dentry), GFP_KERNEL); |
|---|
| 286 | + dentry->d_fsdata = kzalloc(sizeof(union fuse_dentry), |
|---|
| 287 | + GFP_KERNEL_ACCOUNT | __GFP_RECLAIMABLE); |
|---|
| 274 | 288 | |
|---|
| 275 | 289 | return dentry->d_fsdata ? 0 : -ENOMEM; |
|---|
| 276 | 290 | } |
|---|
| .. | .. |
|---|
| 279 | 293 | union fuse_dentry *fd = dentry->d_fsdata; |
|---|
| 280 | 294 | |
|---|
| 281 | 295 | kfree_rcu(fd, rcu); |
|---|
| 296 | +} |
|---|
| 297 | +#endif |
|---|
| 298 | + |
|---|
| 299 | +static int fuse_dentry_delete(const struct dentry *dentry) |
|---|
| 300 | +{ |
|---|
| 301 | + return time_before64(fuse_dentry_time(dentry), get_jiffies_64()); |
|---|
| 302 | +} |
|---|
| 303 | + |
|---|
| 304 | +/* |
|---|
| 305 | + * Create a fuse_mount object with a new superblock (with path->dentry |
|---|
| 306 | + * as the root), and return that mount so it can be auto-mounted on |
|---|
| 307 | + * @path. |
|---|
| 308 | + */ |
|---|
| 309 | +static struct vfsmount *fuse_dentry_automount(struct path *path) |
|---|
| 310 | +{ |
|---|
| 311 | + struct fs_context *fsc; |
|---|
| 312 | + struct fuse_mount *parent_fm = get_fuse_mount_super(path->mnt->mnt_sb); |
|---|
| 313 | + struct fuse_conn *fc = parent_fm->fc; |
|---|
| 314 | + struct fuse_mount *fm; |
|---|
| 315 | + struct vfsmount *mnt; |
|---|
| 316 | + struct fuse_inode *mp_fi = get_fuse_inode(d_inode(path->dentry)); |
|---|
| 317 | + struct super_block *sb; |
|---|
| 318 | + int err; |
|---|
| 319 | + |
|---|
| 320 | + fsc = fs_context_for_submount(path->mnt->mnt_sb->s_type, path->dentry); |
|---|
| 321 | + if (IS_ERR(fsc)) { |
|---|
| 322 | + err = PTR_ERR(fsc); |
|---|
| 323 | + goto out; |
|---|
| 324 | + } |
|---|
| 325 | + |
|---|
| 326 | + err = -ENOMEM; |
|---|
| 327 | + fm = kzalloc(sizeof(struct fuse_mount), GFP_KERNEL); |
|---|
| 328 | + if (!fm) |
|---|
| 329 | + goto out_put_fsc; |
|---|
| 330 | + |
|---|
| 331 | + refcount_set(&fm->count, 1); |
|---|
| 332 | + fsc->s_fs_info = fm; |
|---|
| 333 | + sb = sget_fc(fsc, NULL, set_anon_super_fc); |
|---|
| 334 | + if (IS_ERR(sb)) { |
|---|
| 335 | + err = PTR_ERR(sb); |
|---|
| 336 | + fuse_mount_put(fm); |
|---|
| 337 | + goto out_put_fsc; |
|---|
| 338 | + } |
|---|
| 339 | + fm->fc = fuse_conn_get(fc); |
|---|
| 340 | + |
|---|
| 341 | + /* Initialize superblock, making @mp_fi its root */ |
|---|
| 342 | + err = fuse_fill_super_submount(sb, mp_fi); |
|---|
| 343 | + if (err) { |
|---|
| 344 | + fuse_conn_put(fc); |
|---|
| 345 | + kfree(fm); |
|---|
| 346 | + sb->s_fs_info = NULL; |
|---|
| 347 | + goto out_put_sb; |
|---|
| 348 | + } |
|---|
| 349 | + |
|---|
| 350 | + down_write(&fc->killsb); |
|---|
| 351 | + list_add_tail(&fm->fc_entry, &fc->mounts); |
|---|
| 352 | + up_write(&fc->killsb); |
|---|
| 353 | + |
|---|
| 354 | + sb->s_flags |= SB_ACTIVE; |
|---|
| 355 | + fsc->root = dget(sb->s_root); |
|---|
| 356 | + |
|---|
| 357 | + /* |
|---|
| 358 | + * FIXME: setting SB_BORN requires a write barrier for |
|---|
| 359 | + * super_cache_count(). We should actually come |
|---|
| 360 | + * up with a proper ->get_tree() implementation |
|---|
| 361 | + * for submounts and call vfs_get_tree() to take |
|---|
| 362 | + * care of the write barrier. |
|---|
| 363 | + */ |
|---|
| 364 | + smp_wmb(); |
|---|
| 365 | + sb->s_flags |= SB_BORN; |
|---|
| 366 | + |
|---|
| 367 | + /* We are done configuring the superblock, so unlock it */ |
|---|
| 368 | + up_write(&sb->s_umount); |
|---|
| 369 | + |
|---|
| 370 | + /* Create the submount */ |
|---|
| 371 | + mnt = vfs_create_mount(fsc); |
|---|
| 372 | + if (IS_ERR(mnt)) { |
|---|
| 373 | + err = PTR_ERR(mnt); |
|---|
| 374 | + goto out_put_fsc; |
|---|
| 375 | + } |
|---|
| 376 | + mntget(mnt); |
|---|
| 377 | + put_fs_context(fsc); |
|---|
| 378 | + return mnt; |
|---|
| 379 | + |
|---|
| 380 | +out_put_sb: |
|---|
| 381 | + /* |
|---|
| 382 | + * Only jump here when fsc->root is NULL and sb is still locked |
|---|
| 383 | + * (otherwise put_fs_context() will put the superblock) |
|---|
| 384 | + */ |
|---|
| 385 | + deactivate_locked_super(sb); |
|---|
| 386 | +out_put_fsc: |
|---|
| 387 | + put_fs_context(fsc); |
|---|
| 388 | +out: |
|---|
| 389 | + return ERR_PTR(err); |
|---|
| 282 | 390 | } |
|---|
| 283 | 391 | |
|---|
| 284 | 392 | /* |
|---|
| .. | .. |
|---|
| 291 | 399 | struct path *canonical_path) |
|---|
| 292 | 400 | { |
|---|
| 293 | 401 | struct inode *inode = d_inode(path->dentry); |
|---|
| 294 | | - struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 402 | + //struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 403 | + struct fuse_mount *fm = get_fuse_mount_super(path->mnt->mnt_sb); |
|---|
| 295 | 404 | FUSE_ARGS(args); |
|---|
| 296 | 405 | char *path_name; |
|---|
| 297 | 406 | int err; |
|---|
| 298 | 407 | |
|---|
| 299 | | - path_name = (char *)__get_free_page(GFP_KERNEL); |
|---|
| 408 | + path_name = (char *)get_zeroed_page(GFP_KERNEL); |
|---|
| 300 | 409 | if (!path_name) |
|---|
| 301 | 410 | goto default_path; |
|---|
| 302 | 411 | |
|---|
| 303 | | - args.in.h.opcode = FUSE_CANONICAL_PATH; |
|---|
| 304 | | - args.in.h.nodeid = get_node_id(inode); |
|---|
| 305 | | - args.in.numargs = 0; |
|---|
| 306 | | - args.out.numargs = 1; |
|---|
| 307 | | - args.out.args[0].size = PATH_MAX; |
|---|
| 308 | | - args.out.args[0].value = path_name; |
|---|
| 309 | | - args.out.argvar = 1; |
|---|
| 310 | | - args.out.canonical_path = canonical_path; |
|---|
| 412 | + args.opcode = FUSE_CANONICAL_PATH; |
|---|
| 413 | + args.nodeid = get_node_id(inode); |
|---|
| 414 | + args.in_numargs = 0; |
|---|
| 415 | + args.out_numargs = 1; |
|---|
| 416 | + args.out_args[0].size = PATH_MAX; |
|---|
| 417 | + args.out_args[0].value = path_name; |
|---|
| 418 | + args.canonical_path = canonical_path; |
|---|
| 419 | + args.out_argvar = 1; |
|---|
| 311 | 420 | |
|---|
| 312 | | - err = fuse_simple_request(fc, &args); |
|---|
| 421 | + err = fuse_simple_request(fm, &args); |
|---|
| 313 | 422 | free_page((unsigned long)path_name); |
|---|
| 314 | 423 | if (err > 0) |
|---|
| 315 | 424 | return; |
|---|
| .. | .. |
|---|
| 321 | 430 | |
|---|
| 322 | 431 | const struct dentry_operations fuse_dentry_operations = { |
|---|
| 323 | 432 | .d_revalidate = fuse_dentry_revalidate, |
|---|
| 433 | + .d_delete = fuse_dentry_delete, |
|---|
| 434 | +#if BITS_PER_LONG < 64 |
|---|
| 324 | 435 | .d_init = fuse_dentry_init, |
|---|
| 325 | 436 | .d_release = fuse_dentry_release, |
|---|
| 437 | +#endif |
|---|
| 438 | + .d_automount = fuse_dentry_automount, |
|---|
| 326 | 439 | .d_canonical_path = fuse_dentry_canonical_path, |
|---|
| 327 | 440 | }; |
|---|
| 328 | 441 | |
|---|
| 329 | 442 | const struct dentry_operations fuse_root_dentry_operations = { |
|---|
| 443 | +#if BITS_PER_LONG < 64 |
|---|
| 330 | 444 | .d_init = fuse_dentry_init, |
|---|
| 331 | 445 | .d_release = fuse_dentry_release, |
|---|
| 446 | +#endif |
|---|
| 332 | 447 | }; |
|---|
| 333 | 448 | |
|---|
| 334 | 449 | int fuse_valid_type(int m) |
|---|
| .. | .. |
|---|
| 346 | 461 | int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name, |
|---|
| 347 | 462 | struct fuse_entry_out *outarg, struct inode **inode) |
|---|
| 348 | 463 | { |
|---|
| 349 | | - struct fuse_conn *fc = get_fuse_conn_super(sb); |
|---|
| 464 | + struct fuse_mount *fm = get_fuse_mount_super(sb); |
|---|
| 350 | 465 | FUSE_ARGS(args); |
|---|
| 351 | 466 | struct fuse_forget_link *forget; |
|---|
| 352 | 467 | u64 attr_version; |
|---|
| .. | .. |
|---|
| 363 | 478 | if (!forget) |
|---|
| 364 | 479 | goto out; |
|---|
| 365 | 480 | |
|---|
| 366 | | - attr_version = fuse_get_attr_version(fc); |
|---|
| 481 | + attr_version = fuse_get_attr_version(fm->fc); |
|---|
| 367 | 482 | |
|---|
| 368 | | - fuse_lookup_init(fc, &args, nodeid, name, outarg); |
|---|
| 369 | | - err = fuse_simple_request(fc, &args); |
|---|
| 483 | + fuse_lookup_init(fm->fc, &args, nodeid, name, outarg); |
|---|
| 484 | + err = fuse_simple_request(fm, &args); |
|---|
| 370 | 485 | /* Zero nodeid is same as -ENOENT, but with valid timeout */ |
|---|
| 371 | 486 | if (err || !outarg->nodeid) |
|---|
| 372 | 487 | goto out_put_forget; |
|---|
| .. | .. |
|---|
| 382 | 497 | attr_version); |
|---|
| 383 | 498 | err = -ENOMEM; |
|---|
| 384 | 499 | if (!*inode) { |
|---|
| 385 | | - fuse_queue_forget(fc, forget, outarg->nodeid, 1); |
|---|
| 500 | + fuse_queue_forget(fm->fc, forget, outarg->nodeid, 1); |
|---|
| 386 | 501 | goto out; |
|---|
| 387 | 502 | } |
|---|
| 388 | 503 | err = 0; |
|---|
| .. | .. |
|---|
| 432 | 547 | else |
|---|
| 433 | 548 | fuse_invalidate_entry_cache(entry); |
|---|
| 434 | 549 | |
|---|
| 435 | | - fuse_advise_use_readdirplus(dir); |
|---|
| 550 | + if (inode) |
|---|
| 551 | + fuse_advise_use_readdirplus(dir); |
|---|
| 436 | 552 | return newent; |
|---|
| 437 | 553 | |
|---|
| 438 | 554 | out_iput: |
|---|
| .. | .. |
|---|
| 454 | 570 | int err; |
|---|
| 455 | 571 | struct inode *inode; |
|---|
| 456 | 572 | struct fuse_conn *fc = get_fuse_conn(dir); |
|---|
| 573 | + struct fuse_mount *fm = get_fuse_mount(dir); |
|---|
| 457 | 574 | FUSE_ARGS(args); |
|---|
| 458 | 575 | struct fuse_forget_link *forget; |
|---|
| 459 | 576 | struct fuse_create_in inarg; |
|---|
| 460 | 577 | struct fuse_open_out outopen; |
|---|
| 461 | 578 | struct fuse_entry_out outentry; |
|---|
| 579 | + struct fuse_inode *fi; |
|---|
| 462 | 580 | struct fuse_file *ff; |
|---|
| 463 | 581 | |
|---|
| 464 | 582 | /* Userspace expects S_IFREG in create mode */ |
|---|
| .. | .. |
|---|
| 470 | 588 | goto out_err; |
|---|
| 471 | 589 | |
|---|
| 472 | 590 | err = -ENOMEM; |
|---|
| 473 | | - ff = fuse_file_alloc(fc); |
|---|
| 591 | + ff = fuse_file_alloc(fm); |
|---|
| 474 | 592 | if (!ff) |
|---|
| 475 | 593 | goto out_put_forget_req; |
|---|
| 476 | 594 | |
|---|
| 477 | | - if (!fc->dont_mask) |
|---|
| 595 | + if (!fm->fc->dont_mask) |
|---|
| 478 | 596 | mode &= ~current_umask(); |
|---|
| 479 | 597 | |
|---|
| 480 | 598 | flags &= ~O_NOCTTY; |
|---|
| .. | .. |
|---|
| 483 | 601 | inarg.flags = flags; |
|---|
| 484 | 602 | inarg.mode = mode; |
|---|
| 485 | 603 | inarg.umask = current_umask(); |
|---|
| 486 | | - args.in.h.opcode = FUSE_CREATE; |
|---|
| 487 | | - args.in.h.nodeid = get_node_id(dir); |
|---|
| 488 | | - args.in.numargs = 2; |
|---|
| 489 | | - args.in.args[0].size = sizeof(inarg); |
|---|
| 490 | | - args.in.args[0].value = &inarg; |
|---|
| 491 | | - args.in.args[1].size = entry->d_name.len + 1; |
|---|
| 492 | | - args.in.args[1].value = entry->d_name.name; |
|---|
| 493 | | - args.out.numargs = 2; |
|---|
| 494 | | - args.out.args[0].size = sizeof(outentry); |
|---|
| 495 | | - args.out.args[0].value = &outentry; |
|---|
| 496 | | - args.out.args[1].size = sizeof(outopen); |
|---|
| 497 | | - args.out.args[1].value = &outopen; |
|---|
| 498 | | - err = fuse_simple_request(fc, &args); |
|---|
| 604 | + args.opcode = FUSE_CREATE; |
|---|
| 605 | + args.nodeid = get_node_id(dir); |
|---|
| 606 | + args.in_numargs = 2; |
|---|
| 607 | + args.in_args[0].size = sizeof(inarg); |
|---|
| 608 | + args.in_args[0].value = &inarg; |
|---|
| 609 | + args.in_args[1].size = entry->d_name.len + 1; |
|---|
| 610 | + args.in_args[1].value = entry->d_name.name; |
|---|
| 611 | + args.out_numargs = 2; |
|---|
| 612 | + args.out_args[0].size = sizeof(outentry); |
|---|
| 613 | + args.out_args[0].value = &outentry; |
|---|
| 614 | + args.out_args[1].size = sizeof(outopen); |
|---|
| 615 | + args.out_args[1].value = &outopen; |
|---|
| 616 | + err = fuse_simple_request(fm, &args); |
|---|
| 499 | 617 | if (err) |
|---|
| 500 | 618 | goto out_free_ff; |
|---|
| 501 | 619 | |
|---|
| .. | .. |
|---|
| 507 | 625 | ff->fh = outopen.fh; |
|---|
| 508 | 626 | ff->nodeid = outentry.nodeid; |
|---|
| 509 | 627 | ff->open_flags = outopen.open_flags; |
|---|
| 628 | + fuse_passthrough_setup(fc, ff, &outopen); |
|---|
| 510 | 629 | inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation, |
|---|
| 511 | 630 | &outentry.attr, entry_attr_timeout(&outentry), 0); |
|---|
| 512 | 631 | if (!inode) { |
|---|
| 513 | 632 | flags &= ~(O_CREAT | O_EXCL | O_TRUNC); |
|---|
| 514 | | - fuse_sync_release(ff, flags); |
|---|
| 515 | | - fuse_queue_forget(fc, forget, outentry.nodeid, 1); |
|---|
| 633 | + fuse_sync_release(NULL, ff, flags); |
|---|
| 634 | + fuse_queue_forget(fm->fc, forget, outentry.nodeid, 1); |
|---|
| 516 | 635 | err = -ENOMEM; |
|---|
| 517 | 636 | goto out_err; |
|---|
| 518 | 637 | } |
|---|
| 519 | 638 | kfree(forget); |
|---|
| 520 | 639 | d_instantiate(entry, inode); |
|---|
| 521 | 640 | fuse_change_entry_timeout(entry, &outentry); |
|---|
| 522 | | - fuse_invalidate_attr(dir); |
|---|
| 641 | + fuse_dir_changed(dir); |
|---|
| 523 | 642 | err = finish_open(file, entry, generic_file_open); |
|---|
| 524 | 643 | if (err) { |
|---|
| 525 | | - fuse_sync_release(ff, flags); |
|---|
| 644 | + fi = get_fuse_inode(inode); |
|---|
| 645 | + fuse_sync_release(fi, ff, flags); |
|---|
| 526 | 646 | } else { |
|---|
| 527 | 647 | file->private_data = ff; |
|---|
| 528 | 648 | fuse_finish_open(inode, file); |
|---|
| .. | .. |
|---|
| 587 | 707 | /* |
|---|
| 588 | 708 | * Code shared between mknod, mkdir, symlink and link |
|---|
| 589 | 709 | */ |
|---|
| 590 | | -static int create_new_entry(struct fuse_conn *fc, struct fuse_args *args, |
|---|
| 710 | +static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args, |
|---|
| 591 | 711 | struct inode *dir, struct dentry *entry, |
|---|
| 592 | 712 | umode_t mode) |
|---|
| 593 | 713 | { |
|---|
| .. | .. |
|---|
| 605 | 725 | return -ENOMEM; |
|---|
| 606 | 726 | |
|---|
| 607 | 727 | memset(&outarg, 0, sizeof(outarg)); |
|---|
| 608 | | - args->in.h.nodeid = get_node_id(dir); |
|---|
| 609 | | - args->out.numargs = 1; |
|---|
| 610 | | - args->out.args[0].size = sizeof(outarg); |
|---|
| 611 | | - args->out.args[0].value = &outarg; |
|---|
| 612 | | - err = fuse_simple_request(fc, args); |
|---|
| 728 | + args->nodeid = get_node_id(dir); |
|---|
| 729 | + args->out_numargs = 1; |
|---|
| 730 | + args->out_args[0].size = sizeof(outarg); |
|---|
| 731 | + args->out_args[0].value = &outarg; |
|---|
| 732 | + err = fuse_simple_request(fm, args); |
|---|
| 613 | 733 | if (err) |
|---|
| 614 | 734 | goto out_put_forget_req; |
|---|
| 615 | 735 | |
|---|
| .. | .. |
|---|
| 623 | 743 | inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, |
|---|
| 624 | 744 | &outarg.attr, entry_attr_timeout(&outarg), 0); |
|---|
| 625 | 745 | if (!inode) { |
|---|
| 626 | | - fuse_queue_forget(fc, forget, outarg.nodeid, 1); |
|---|
| 746 | + fuse_queue_forget(fm->fc, forget, outarg.nodeid, 1); |
|---|
| 627 | 747 | return -ENOMEM; |
|---|
| 628 | 748 | } |
|---|
| 629 | 749 | kfree(forget); |
|---|
| .. | .. |
|---|
| 639 | 759 | } else { |
|---|
| 640 | 760 | fuse_change_entry_timeout(entry, &outarg); |
|---|
| 641 | 761 | } |
|---|
| 642 | | - fuse_invalidate_attr(dir); |
|---|
| 762 | + fuse_dir_changed(dir); |
|---|
| 643 | 763 | return 0; |
|---|
| 644 | 764 | |
|---|
| 645 | 765 | out_put_forget_req: |
|---|
| .. | .. |
|---|
| 651 | 771 | dev_t rdev) |
|---|
| 652 | 772 | { |
|---|
| 653 | 773 | struct fuse_mknod_in inarg; |
|---|
| 654 | | - struct fuse_conn *fc = get_fuse_conn(dir); |
|---|
| 774 | + struct fuse_mount *fm = get_fuse_mount(dir); |
|---|
| 655 | 775 | FUSE_ARGS(args); |
|---|
| 656 | 776 | |
|---|
| 657 | | - if (!fc->dont_mask) |
|---|
| 777 | + if (!fm->fc->dont_mask) |
|---|
| 658 | 778 | mode &= ~current_umask(); |
|---|
| 659 | 779 | |
|---|
| 660 | 780 | memset(&inarg, 0, sizeof(inarg)); |
|---|
| 661 | 781 | inarg.mode = mode; |
|---|
| 662 | 782 | inarg.rdev = new_encode_dev(rdev); |
|---|
| 663 | 783 | inarg.umask = current_umask(); |
|---|
| 664 | | - args.in.h.opcode = FUSE_MKNOD; |
|---|
| 665 | | - args.in.numargs = 2; |
|---|
| 666 | | - args.in.args[0].size = sizeof(inarg); |
|---|
| 667 | | - args.in.args[0].value = &inarg; |
|---|
| 668 | | - args.in.args[1].size = entry->d_name.len + 1; |
|---|
| 669 | | - args.in.args[1].value = entry->d_name.name; |
|---|
| 670 | | - return create_new_entry(fc, &args, dir, entry, mode); |
|---|
| 784 | + args.opcode = FUSE_MKNOD; |
|---|
| 785 | + args.in_numargs = 2; |
|---|
| 786 | + args.in_args[0].size = sizeof(inarg); |
|---|
| 787 | + args.in_args[0].value = &inarg; |
|---|
| 788 | + args.in_args[1].size = entry->d_name.len + 1; |
|---|
| 789 | + args.in_args[1].value = entry->d_name.name; |
|---|
| 790 | + return create_new_entry(fm, &args, dir, entry, mode); |
|---|
| 671 | 791 | } |
|---|
| 672 | 792 | |
|---|
| 673 | 793 | static int fuse_create(struct inode *dir, struct dentry *entry, umode_t mode, |
|---|
| .. | .. |
|---|
| 679 | 799 | static int fuse_mkdir(struct inode *dir, struct dentry *entry, umode_t mode) |
|---|
| 680 | 800 | { |
|---|
| 681 | 801 | struct fuse_mkdir_in inarg; |
|---|
| 682 | | - struct fuse_conn *fc = get_fuse_conn(dir); |
|---|
| 802 | + struct fuse_mount *fm = get_fuse_mount(dir); |
|---|
| 683 | 803 | FUSE_ARGS(args); |
|---|
| 684 | 804 | |
|---|
| 685 | | - if (!fc->dont_mask) |
|---|
| 805 | + if (!fm->fc->dont_mask) |
|---|
| 686 | 806 | mode &= ~current_umask(); |
|---|
| 687 | 807 | |
|---|
| 688 | 808 | memset(&inarg, 0, sizeof(inarg)); |
|---|
| 689 | 809 | inarg.mode = mode; |
|---|
| 690 | 810 | inarg.umask = current_umask(); |
|---|
| 691 | | - args.in.h.opcode = FUSE_MKDIR; |
|---|
| 692 | | - args.in.numargs = 2; |
|---|
| 693 | | - args.in.args[0].size = sizeof(inarg); |
|---|
| 694 | | - args.in.args[0].value = &inarg; |
|---|
| 695 | | - args.in.args[1].size = entry->d_name.len + 1; |
|---|
| 696 | | - args.in.args[1].value = entry->d_name.name; |
|---|
| 697 | | - return create_new_entry(fc, &args, dir, entry, S_IFDIR); |
|---|
| 811 | + args.opcode = FUSE_MKDIR; |
|---|
| 812 | + args.in_numargs = 2; |
|---|
| 813 | + args.in_args[0].size = sizeof(inarg); |
|---|
| 814 | + args.in_args[0].value = &inarg; |
|---|
| 815 | + args.in_args[1].size = entry->d_name.len + 1; |
|---|
| 816 | + args.in_args[1].value = entry->d_name.name; |
|---|
| 817 | + return create_new_entry(fm, &args, dir, entry, S_IFDIR); |
|---|
| 698 | 818 | } |
|---|
| 699 | 819 | |
|---|
| 700 | 820 | static int fuse_symlink(struct inode *dir, struct dentry *entry, |
|---|
| 701 | 821 | const char *link) |
|---|
| 702 | 822 | { |
|---|
| 703 | | - struct fuse_conn *fc = get_fuse_conn(dir); |
|---|
| 823 | + struct fuse_mount *fm = get_fuse_mount(dir); |
|---|
| 704 | 824 | unsigned len = strlen(link) + 1; |
|---|
| 705 | 825 | FUSE_ARGS(args); |
|---|
| 706 | 826 | |
|---|
| 707 | | - args.in.h.opcode = FUSE_SYMLINK; |
|---|
| 708 | | - args.in.numargs = 2; |
|---|
| 709 | | - args.in.args[0].size = entry->d_name.len + 1; |
|---|
| 710 | | - args.in.args[0].value = entry->d_name.name; |
|---|
| 711 | | - args.in.args[1].size = len; |
|---|
| 712 | | - args.in.args[1].value = link; |
|---|
| 713 | | - return create_new_entry(fc, &args, dir, entry, S_IFLNK); |
|---|
| 827 | + args.opcode = FUSE_SYMLINK; |
|---|
| 828 | + args.in_numargs = 2; |
|---|
| 829 | + args.in_args[0].size = entry->d_name.len + 1; |
|---|
| 830 | + args.in_args[0].value = entry->d_name.name; |
|---|
| 831 | + args.in_args[1].size = len; |
|---|
| 832 | + args.in_args[1].value = link; |
|---|
| 833 | + return create_new_entry(fm, &args, dir, entry, S_IFLNK); |
|---|
| 834 | +} |
|---|
| 835 | + |
|---|
| 836 | +void fuse_flush_time_update(struct inode *inode) |
|---|
| 837 | +{ |
|---|
| 838 | + int err = sync_inode_metadata(inode, 1); |
|---|
| 839 | + |
|---|
| 840 | + mapping_set_error(inode->i_mapping, err); |
|---|
| 714 | 841 | } |
|---|
| 715 | 842 | |
|---|
| 716 | 843 | void fuse_update_ctime(struct inode *inode) |
|---|
| .. | .. |
|---|
| 718 | 845 | if (!IS_NOCMTIME(inode)) { |
|---|
| 719 | 846 | inode->i_ctime = current_time(inode); |
|---|
| 720 | 847 | mark_inode_dirty_sync(inode); |
|---|
| 848 | + fuse_flush_time_update(inode); |
|---|
| 721 | 849 | } |
|---|
| 722 | 850 | } |
|---|
| 723 | 851 | |
|---|
| 724 | 852 | static int fuse_unlink(struct inode *dir, struct dentry *entry) |
|---|
| 725 | 853 | { |
|---|
| 726 | 854 | int err; |
|---|
| 727 | | - struct fuse_conn *fc = get_fuse_conn(dir); |
|---|
| 855 | + struct fuse_mount *fm = get_fuse_mount(dir); |
|---|
| 728 | 856 | FUSE_ARGS(args); |
|---|
| 729 | 857 | |
|---|
| 730 | 858 | if (fuse_is_bad(dir)) |
|---|
| 731 | 859 | return -EIO; |
|---|
| 732 | 860 | |
|---|
| 733 | | - args.in.h.opcode = FUSE_UNLINK; |
|---|
| 734 | | - args.in.h.nodeid = get_node_id(dir); |
|---|
| 735 | | - args.in.numargs = 1; |
|---|
| 736 | | - args.in.args[0].size = entry->d_name.len + 1; |
|---|
| 737 | | - args.in.args[0].value = entry->d_name.name; |
|---|
| 738 | | - err = fuse_simple_request(fc, &args); |
|---|
| 861 | + args.opcode = FUSE_UNLINK; |
|---|
| 862 | + args.nodeid = get_node_id(dir); |
|---|
| 863 | + args.in_numargs = 1; |
|---|
| 864 | + args.in_args[0].size = entry->d_name.len + 1; |
|---|
| 865 | + args.in_args[0].value = entry->d_name.name; |
|---|
| 866 | + err = fuse_simple_request(fm, &args); |
|---|
| 739 | 867 | if (!err) { |
|---|
| 740 | 868 | struct inode *inode = d_inode(entry); |
|---|
| 741 | 869 | struct fuse_inode *fi = get_fuse_inode(inode); |
|---|
| 742 | 870 | |
|---|
| 743 | | - spin_lock(&fc->lock); |
|---|
| 744 | | - fi->attr_version = ++fc->attr_version; |
|---|
| 871 | + spin_lock(&fi->lock); |
|---|
| 872 | + fi->attr_version = atomic64_inc_return(&fm->fc->attr_version); |
|---|
| 745 | 873 | /* |
|---|
| 746 | 874 | * If i_nlink == 0 then unlink doesn't make sense, yet this can |
|---|
| 747 | 875 | * happen if userspace filesystem is careless. It would be |
|---|
| .. | .. |
|---|
| 750 | 878 | */ |
|---|
| 751 | 879 | if (inode->i_nlink > 0) |
|---|
| 752 | 880 | drop_nlink(inode); |
|---|
| 753 | | - spin_unlock(&fc->lock); |
|---|
| 881 | + spin_unlock(&fi->lock); |
|---|
| 754 | 882 | fuse_invalidate_attr(inode); |
|---|
| 755 | | - fuse_invalidate_attr(dir); |
|---|
| 883 | + fuse_dir_changed(dir); |
|---|
| 756 | 884 | fuse_invalidate_entry_cache(entry); |
|---|
| 757 | 885 | fuse_update_ctime(inode); |
|---|
| 758 | 886 | } else if (err == -EINTR) |
|---|
| .. | .. |
|---|
| 763 | 891 | static int fuse_rmdir(struct inode *dir, struct dentry *entry) |
|---|
| 764 | 892 | { |
|---|
| 765 | 893 | int err; |
|---|
| 766 | | - struct fuse_conn *fc = get_fuse_conn(dir); |
|---|
| 894 | + struct fuse_mount *fm = get_fuse_mount(dir); |
|---|
| 767 | 895 | FUSE_ARGS(args); |
|---|
| 768 | 896 | |
|---|
| 769 | 897 | if (fuse_is_bad(dir)) |
|---|
| 770 | 898 | return -EIO; |
|---|
| 771 | 899 | |
|---|
| 772 | | - args.in.h.opcode = FUSE_RMDIR; |
|---|
| 773 | | - args.in.h.nodeid = get_node_id(dir); |
|---|
| 774 | | - args.in.numargs = 1; |
|---|
| 775 | | - args.in.args[0].size = entry->d_name.len + 1; |
|---|
| 776 | | - args.in.args[0].value = entry->d_name.name; |
|---|
| 777 | | - err = fuse_simple_request(fc, &args); |
|---|
| 900 | + args.opcode = FUSE_RMDIR; |
|---|
| 901 | + args.nodeid = get_node_id(dir); |
|---|
| 902 | + args.in_numargs = 1; |
|---|
| 903 | + args.in_args[0].size = entry->d_name.len + 1; |
|---|
| 904 | + args.in_args[0].value = entry->d_name.name; |
|---|
| 905 | + err = fuse_simple_request(fm, &args); |
|---|
| 778 | 906 | if (!err) { |
|---|
| 779 | 907 | clear_nlink(d_inode(entry)); |
|---|
| 780 | | - fuse_invalidate_attr(dir); |
|---|
| 908 | + fuse_dir_changed(dir); |
|---|
| 781 | 909 | fuse_invalidate_entry_cache(entry); |
|---|
| 782 | 910 | } else if (err == -EINTR) |
|---|
| 783 | 911 | fuse_invalidate_entry(entry); |
|---|
| .. | .. |
|---|
| 790 | 918 | { |
|---|
| 791 | 919 | int err; |
|---|
| 792 | 920 | struct fuse_rename2_in inarg; |
|---|
| 793 | | - struct fuse_conn *fc = get_fuse_conn(olddir); |
|---|
| 921 | + struct fuse_mount *fm = get_fuse_mount(olddir); |
|---|
| 794 | 922 | FUSE_ARGS(args); |
|---|
| 795 | 923 | |
|---|
| 796 | 924 | memset(&inarg, 0, argsize); |
|---|
| 797 | 925 | inarg.newdir = get_node_id(newdir); |
|---|
| 798 | 926 | inarg.flags = flags; |
|---|
| 799 | | - args.in.h.opcode = opcode; |
|---|
| 800 | | - args.in.h.nodeid = get_node_id(olddir); |
|---|
| 801 | | - args.in.numargs = 3; |
|---|
| 802 | | - args.in.args[0].size = argsize; |
|---|
| 803 | | - args.in.args[0].value = &inarg; |
|---|
| 804 | | - args.in.args[1].size = oldent->d_name.len + 1; |
|---|
| 805 | | - args.in.args[1].value = oldent->d_name.name; |
|---|
| 806 | | - args.in.args[2].size = newent->d_name.len + 1; |
|---|
| 807 | | - args.in.args[2].value = newent->d_name.name; |
|---|
| 808 | | - err = fuse_simple_request(fc, &args); |
|---|
| 927 | + args.opcode = opcode; |
|---|
| 928 | + args.nodeid = get_node_id(olddir); |
|---|
| 929 | + args.in_numargs = 3; |
|---|
| 930 | + args.in_args[0].size = argsize; |
|---|
| 931 | + args.in_args[0].value = &inarg; |
|---|
| 932 | + args.in_args[1].size = oldent->d_name.len + 1; |
|---|
| 933 | + args.in_args[1].value = oldent->d_name.name; |
|---|
| 934 | + args.in_args[2].size = newent->d_name.len + 1; |
|---|
| 935 | + args.in_args[2].value = newent->d_name.name; |
|---|
| 936 | + err = fuse_simple_request(fm, &args); |
|---|
| 809 | 937 | if (!err) { |
|---|
| 810 | 938 | /* ctime changes */ |
|---|
| 811 | 939 | fuse_invalidate_attr(d_inode(oldent)); |
|---|
| .. | .. |
|---|
| 816 | 944 | fuse_update_ctime(d_inode(newent)); |
|---|
| 817 | 945 | } |
|---|
| 818 | 946 | |
|---|
| 819 | | - fuse_invalidate_attr(olddir); |
|---|
| 947 | + fuse_dir_changed(olddir); |
|---|
| 820 | 948 | if (olddir != newdir) |
|---|
| 821 | | - fuse_invalidate_attr(newdir); |
|---|
| 949 | + fuse_dir_changed(newdir); |
|---|
| 822 | 950 | |
|---|
| 823 | 951 | /* newent will end up negative */ |
|---|
| 824 | 952 | if (!(flags & RENAME_EXCHANGE) && d_really_is_positive(newent)) { |
|---|
| .. | .. |
|---|
| 850 | 978 | if (fuse_is_bad(olddir)) |
|---|
| 851 | 979 | return -EIO; |
|---|
| 852 | 980 | |
|---|
| 853 | | - if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE)) |
|---|
| 981 | + if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT)) |
|---|
| 854 | 982 | return -EINVAL; |
|---|
| 855 | 983 | |
|---|
| 856 | 984 | if (flags) { |
|---|
| .. | .. |
|---|
| 879 | 1007 | int err; |
|---|
| 880 | 1008 | struct fuse_link_in inarg; |
|---|
| 881 | 1009 | struct inode *inode = d_inode(entry); |
|---|
| 882 | | - struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 1010 | + struct fuse_mount *fm = get_fuse_mount(inode); |
|---|
| 883 | 1011 | FUSE_ARGS(args); |
|---|
| 884 | 1012 | |
|---|
| 885 | 1013 | memset(&inarg, 0, sizeof(inarg)); |
|---|
| 886 | 1014 | inarg.oldnodeid = get_node_id(inode); |
|---|
| 887 | | - args.in.h.opcode = FUSE_LINK; |
|---|
| 888 | | - args.in.numargs = 2; |
|---|
| 889 | | - args.in.args[0].size = sizeof(inarg); |
|---|
| 890 | | - args.in.args[0].value = &inarg; |
|---|
| 891 | | - args.in.args[1].size = newent->d_name.len + 1; |
|---|
| 892 | | - args.in.args[1].value = newent->d_name.name; |
|---|
| 893 | | - err = create_new_entry(fc, &args, newdir, newent, inode->i_mode); |
|---|
| 1015 | + args.opcode = FUSE_LINK; |
|---|
| 1016 | + args.in_numargs = 2; |
|---|
| 1017 | + args.in_args[0].size = sizeof(inarg); |
|---|
| 1018 | + args.in_args[0].value = &inarg; |
|---|
| 1019 | + args.in_args[1].size = newent->d_name.len + 1; |
|---|
| 1020 | + args.in_args[1].value = newent->d_name.name; |
|---|
| 1021 | + err = create_new_entry(fm, &args, newdir, newent, inode->i_mode); |
|---|
| 894 | 1022 | /* Contrary to "normal" filesystems it can happen that link |
|---|
| 895 | 1023 | makes two "logical" inodes point to the same "physical" |
|---|
| 896 | 1024 | inode. We invalidate the attributes of the old one, so it |
|---|
| .. | .. |
|---|
| 900 | 1028 | if (!err) { |
|---|
| 901 | 1029 | struct fuse_inode *fi = get_fuse_inode(inode); |
|---|
| 902 | 1030 | |
|---|
| 903 | | - spin_lock(&fc->lock); |
|---|
| 904 | | - fi->attr_version = ++fc->attr_version; |
|---|
| 1031 | + spin_lock(&fi->lock); |
|---|
| 1032 | + fi->attr_version = atomic64_inc_return(&fm->fc->attr_version); |
|---|
| 905 | 1033 | if (likely(inode->i_nlink < UINT_MAX)) |
|---|
| 906 | 1034 | inc_nlink(inode); |
|---|
| 907 | | - spin_unlock(&fc->lock); |
|---|
| 1035 | + spin_unlock(&fi->lock); |
|---|
| 908 | 1036 | fuse_invalidate_attr(inode); |
|---|
| 909 | 1037 | fuse_update_ctime(inode); |
|---|
| 910 | 1038 | } else if (err == -EINTR) { |
|---|
| .. | .. |
|---|
| 958 | 1086 | int err; |
|---|
| 959 | 1087 | struct fuse_getattr_in inarg; |
|---|
| 960 | 1088 | struct fuse_attr_out outarg; |
|---|
| 961 | | - struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 1089 | + struct fuse_mount *fm = get_fuse_mount(inode); |
|---|
| 962 | 1090 | FUSE_ARGS(args); |
|---|
| 963 | 1091 | u64 attr_version; |
|---|
| 964 | 1092 | |
|---|
| 965 | | - attr_version = fuse_get_attr_version(fc); |
|---|
| 1093 | + attr_version = fuse_get_attr_version(fm->fc); |
|---|
| 966 | 1094 | |
|---|
| 967 | 1095 | memset(&inarg, 0, sizeof(inarg)); |
|---|
| 968 | 1096 | memset(&outarg, 0, sizeof(outarg)); |
|---|
| .. | .. |
|---|
| 973 | 1101 | inarg.getattr_flags |= FUSE_GETATTR_FH; |
|---|
| 974 | 1102 | inarg.fh = ff->fh; |
|---|
| 975 | 1103 | } |
|---|
| 976 | | - args.in.h.opcode = FUSE_GETATTR; |
|---|
| 977 | | - args.in.h.nodeid = get_node_id(inode); |
|---|
| 978 | | - args.in.numargs = 1; |
|---|
| 979 | | - args.in.args[0].size = sizeof(inarg); |
|---|
| 980 | | - args.in.args[0].value = &inarg; |
|---|
| 981 | | - args.out.numargs = 1; |
|---|
| 982 | | - args.out.args[0].size = sizeof(outarg); |
|---|
| 983 | | - args.out.args[0].value = &outarg; |
|---|
| 984 | | - err = fuse_simple_request(fc, &args); |
|---|
| 1104 | + args.opcode = FUSE_GETATTR; |
|---|
| 1105 | + args.nodeid = get_node_id(inode); |
|---|
| 1106 | + args.in_numargs = 1; |
|---|
| 1107 | + args.in_args[0].size = sizeof(inarg); |
|---|
| 1108 | + args.in_args[0].value = &inarg; |
|---|
| 1109 | + args.out_numargs = 1; |
|---|
| 1110 | + args.out_args[0].size = sizeof(outarg); |
|---|
| 1111 | + args.out_args[0].value = &outarg; |
|---|
| 1112 | + err = fuse_simple_request(fm, &args); |
|---|
| 985 | 1113 | if (!err) { |
|---|
| 986 | 1114 | if (fuse_invalid_attr(&outarg.attr) || |
|---|
| 987 | | - (inode->i_mode ^ outarg.attr.mode) & S_IFMT) { |
|---|
| 1115 | + inode_wrong_type(inode, outarg.attr.mode)) { |
|---|
| 988 | 1116 | fuse_make_bad(inode); |
|---|
| 989 | 1117 | err = -EIO; |
|---|
| 990 | 1118 | } else { |
|---|
| .. | .. |
|---|
| 999 | 1127 | } |
|---|
| 1000 | 1128 | |
|---|
| 1001 | 1129 | static int fuse_update_get_attr(struct inode *inode, struct file *file, |
|---|
| 1002 | | - struct kstat *stat, unsigned int flags) |
|---|
| 1130 | + struct kstat *stat, u32 request_mask, |
|---|
| 1131 | + unsigned int flags) |
|---|
| 1003 | 1132 | { |
|---|
| 1004 | 1133 | struct fuse_inode *fi = get_fuse_inode(inode); |
|---|
| 1005 | 1134 | int err = 0; |
|---|
| .. | .. |
|---|
| 1009 | 1138 | sync = true; |
|---|
| 1010 | 1139 | else if (flags & AT_STATX_DONT_SYNC) |
|---|
| 1011 | 1140 | sync = false; |
|---|
| 1141 | + else if (request_mask & READ_ONCE(fi->inval_mask)) |
|---|
| 1142 | + sync = true; |
|---|
| 1012 | 1143 | else |
|---|
| 1013 | 1144 | sync = time_before64(fi->i_time, get_jiffies_64()); |
|---|
| 1014 | 1145 | |
|---|
| .. | .. |
|---|
| 1026 | 1157 | |
|---|
| 1027 | 1158 | int fuse_update_attributes(struct inode *inode, struct file *file) |
|---|
| 1028 | 1159 | { |
|---|
| 1029 | | - return fuse_update_get_attr(inode, file, NULL, 0); |
|---|
| 1160 | + /* Do *not* need to get atime for internal purposes */ |
|---|
| 1161 | + return fuse_update_get_attr(inode, file, NULL, |
|---|
| 1162 | + STATX_BASIC_STATS & ~STATX_ATIME, 0); |
|---|
| 1030 | 1163 | } |
|---|
| 1031 | 1164 | |
|---|
| 1032 | | -int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid, |
|---|
| 1165 | +int fuse_reverse_inval_entry(struct fuse_conn *fc, u64 parent_nodeid, |
|---|
| 1033 | 1166 | u64 child_nodeid, struct qstr *name) |
|---|
| 1034 | 1167 | { |
|---|
| 1035 | 1168 | int err = -ENOTDIR; |
|---|
| .. | .. |
|---|
| 1037 | 1170 | struct dentry *dir; |
|---|
| 1038 | 1171 | struct dentry *entry; |
|---|
| 1039 | 1172 | |
|---|
| 1040 | | - parent = ilookup5(sb, parent_nodeid, fuse_inode_eq, &parent_nodeid); |
|---|
| 1173 | + parent = fuse_ilookup(fc, parent_nodeid, NULL); |
|---|
| 1041 | 1174 | if (!parent) |
|---|
| 1042 | 1175 | return -ENOENT; |
|---|
| 1043 | 1176 | |
|---|
| .. | .. |
|---|
| 1056 | 1189 | if (!entry) |
|---|
| 1057 | 1190 | goto unlock; |
|---|
| 1058 | 1191 | |
|---|
| 1059 | | - fuse_invalidate_attr(parent); |
|---|
| 1192 | + fuse_dir_changed(parent); |
|---|
| 1060 | 1193 | fuse_invalidate_entry(entry); |
|---|
| 1061 | 1194 | |
|---|
| 1062 | 1195 | if (child_nodeid != 0 && d_really_is_positive(entry)) { |
|---|
| .. | .. |
|---|
| 1129 | 1262 | |
|---|
| 1130 | 1263 | static int fuse_access(struct inode *inode, int mask) |
|---|
| 1131 | 1264 | { |
|---|
| 1132 | | - struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 1265 | + struct fuse_mount *fm = get_fuse_mount(inode); |
|---|
| 1133 | 1266 | FUSE_ARGS(args); |
|---|
| 1134 | 1267 | struct fuse_access_in inarg; |
|---|
| 1135 | 1268 | int err; |
|---|
| 1136 | 1269 | |
|---|
| 1137 | 1270 | BUG_ON(mask & MAY_NOT_BLOCK); |
|---|
| 1138 | 1271 | |
|---|
| 1139 | | - if (fc->no_access) |
|---|
| 1272 | + if (fm->fc->no_access) |
|---|
| 1140 | 1273 | return 0; |
|---|
| 1141 | 1274 | |
|---|
| 1142 | 1275 | memset(&inarg, 0, sizeof(inarg)); |
|---|
| 1143 | 1276 | inarg.mask = mask & (MAY_READ | MAY_WRITE | MAY_EXEC); |
|---|
| 1144 | | - args.in.h.opcode = FUSE_ACCESS; |
|---|
| 1145 | | - args.in.h.nodeid = get_node_id(inode); |
|---|
| 1146 | | - args.in.numargs = 1; |
|---|
| 1147 | | - args.in.args[0].size = sizeof(inarg); |
|---|
| 1148 | | - args.in.args[0].value = &inarg; |
|---|
| 1149 | | - err = fuse_simple_request(fc, &args); |
|---|
| 1277 | + args.opcode = FUSE_ACCESS; |
|---|
| 1278 | + args.nodeid = get_node_id(inode); |
|---|
| 1279 | + args.in_numargs = 1; |
|---|
| 1280 | + args.in_args[0].size = sizeof(inarg); |
|---|
| 1281 | + args.in_args[0].value = &inarg; |
|---|
| 1282 | + err = fuse_simple_request(fm, &args); |
|---|
| 1150 | 1283 | if (err == -ENOSYS) { |
|---|
| 1151 | | - fc->no_access = 1; |
|---|
| 1284 | + fm->fc->no_access = 1; |
|---|
| 1152 | 1285 | err = 0; |
|---|
| 1153 | 1286 | } |
|---|
| 1154 | 1287 | return err; |
|---|
| .. | .. |
|---|
| 1194 | 1327 | if (fc->default_permissions || |
|---|
| 1195 | 1328 | ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))) { |
|---|
| 1196 | 1329 | struct fuse_inode *fi = get_fuse_inode(inode); |
|---|
| 1330 | + u32 perm_mask = STATX_MODE | STATX_UID | STATX_GID; |
|---|
| 1197 | 1331 | |
|---|
| 1198 | | - if (time_before64(fi->i_time, get_jiffies_64())) { |
|---|
| 1332 | + if (perm_mask & READ_ONCE(fi->inval_mask) || |
|---|
| 1333 | + time_before64(fi->i_time, get_jiffies_64())) { |
|---|
| 1199 | 1334 | refreshed = true; |
|---|
| 1200 | 1335 | |
|---|
| 1201 | 1336 | err = fuse_perm_getattr(inode, mask); |
|---|
| .. | .. |
|---|
| 1235 | 1370 | return err; |
|---|
| 1236 | 1371 | } |
|---|
| 1237 | 1372 | |
|---|
| 1238 | | -static int parse_dirfile(char *buf, size_t nbytes, struct file *file, |
|---|
| 1239 | | - struct dir_context *ctx) |
|---|
| 1373 | +static int fuse_readlink_page(struct inode *inode, struct page *page) |
|---|
| 1240 | 1374 | { |
|---|
| 1241 | | - while (nbytes >= FUSE_NAME_OFFSET) { |
|---|
| 1242 | | - struct fuse_dirent *dirent = (struct fuse_dirent *) buf; |
|---|
| 1243 | | - size_t reclen = FUSE_DIRENT_SIZE(dirent); |
|---|
| 1244 | | - if (!dirent->namelen || dirent->namelen > FUSE_NAME_MAX) |
|---|
| 1245 | | - return -EIO; |
|---|
| 1246 | | - if (reclen > nbytes) |
|---|
| 1247 | | - break; |
|---|
| 1248 | | - if (memchr(dirent->name, '/', dirent->namelen) != NULL) |
|---|
| 1249 | | - return -EIO; |
|---|
| 1375 | + struct fuse_mount *fm = get_fuse_mount(inode); |
|---|
| 1376 | + struct fuse_page_desc desc = { .length = PAGE_SIZE - 1 }; |
|---|
| 1377 | + struct fuse_args_pages ap = { |
|---|
| 1378 | + .num_pages = 1, |
|---|
| 1379 | + .pages = &page, |
|---|
| 1380 | + .descs = &desc, |
|---|
| 1381 | + }; |
|---|
| 1382 | + char *link; |
|---|
| 1383 | + ssize_t res; |
|---|
| 1250 | 1384 | |
|---|
| 1251 | | - if (!dir_emit(ctx, dirent->name, dirent->namelen, |
|---|
| 1252 | | - dirent->ino, dirent->type)) |
|---|
| 1253 | | - break; |
|---|
| 1385 | + ap.args.opcode = FUSE_READLINK; |
|---|
| 1386 | + ap.args.nodeid = get_node_id(inode); |
|---|
| 1387 | + ap.args.out_pages = true; |
|---|
| 1388 | + ap.args.out_argvar = true; |
|---|
| 1389 | + ap.args.page_zeroing = true; |
|---|
| 1390 | + ap.args.out_numargs = 1; |
|---|
| 1391 | + ap.args.out_args[0].size = desc.length; |
|---|
| 1392 | + res = fuse_simple_request(fm, &ap.args); |
|---|
| 1254 | 1393 | |
|---|
| 1255 | | - buf += reclen; |
|---|
| 1256 | | - nbytes -= reclen; |
|---|
| 1257 | | - ctx->pos = dirent->off; |
|---|
| 1258 | | - } |
|---|
| 1394 | + fuse_invalidate_atime(inode); |
|---|
| 1259 | 1395 | |
|---|
| 1260 | | - return 0; |
|---|
| 1261 | | -} |
|---|
| 1396 | + if (res < 0) |
|---|
| 1397 | + return res; |
|---|
| 1262 | 1398 | |
|---|
| 1263 | | -static int fuse_direntplus_link(struct file *file, |
|---|
| 1264 | | - struct fuse_direntplus *direntplus, |
|---|
| 1265 | | - u64 attr_version) |
|---|
| 1266 | | -{ |
|---|
| 1267 | | - struct fuse_entry_out *o = &direntplus->entry_out; |
|---|
| 1268 | | - struct fuse_dirent *dirent = &direntplus->dirent; |
|---|
| 1269 | | - struct dentry *parent = file->f_path.dentry; |
|---|
| 1270 | | - struct qstr name = QSTR_INIT(dirent->name, dirent->namelen); |
|---|
| 1271 | | - struct dentry *dentry; |
|---|
| 1272 | | - struct dentry *alias; |
|---|
| 1273 | | - struct inode *dir = d_inode(parent); |
|---|
| 1274 | | - struct fuse_conn *fc; |
|---|
| 1275 | | - struct inode *inode; |
|---|
| 1276 | | - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); |
|---|
| 1277 | | - |
|---|
| 1278 | | - if (!o->nodeid) { |
|---|
| 1279 | | - /* |
|---|
| 1280 | | - * Unlike in the case of fuse_lookup, zero nodeid does not mean |
|---|
| 1281 | | - * ENOENT. Instead, it only means the userspace filesystem did |
|---|
| 1282 | | - * not want to return attributes/handle for this entry. |
|---|
| 1283 | | - * |
|---|
| 1284 | | - * So do nothing. |
|---|
| 1285 | | - */ |
|---|
| 1286 | | - return 0; |
|---|
| 1287 | | - } |
|---|
| 1288 | | - |
|---|
| 1289 | | - if (name.name[0] == '.') { |
|---|
| 1290 | | - /* |
|---|
| 1291 | | - * We could potentially refresh the attributes of the directory |
|---|
| 1292 | | - * and its parent? |
|---|
| 1293 | | - */ |
|---|
| 1294 | | - if (name.len == 1) |
|---|
| 1295 | | - return 0; |
|---|
| 1296 | | - if (name.name[1] == '.' && name.len == 2) |
|---|
| 1297 | | - return 0; |
|---|
| 1298 | | - } |
|---|
| 1299 | | - |
|---|
| 1300 | | - if (invalid_nodeid(o->nodeid)) |
|---|
| 1301 | | - return -EIO; |
|---|
| 1302 | | - if (fuse_invalid_attr(&o->attr)) |
|---|
| 1399 | + if (WARN_ON(res >= PAGE_SIZE)) |
|---|
| 1303 | 1400 | return -EIO; |
|---|
| 1304 | 1401 | |
|---|
| 1305 | | - fc = get_fuse_conn(dir); |
|---|
| 1306 | | - |
|---|
| 1307 | | - name.hash = full_name_hash(parent, name.name, name.len); |
|---|
| 1308 | | - dentry = d_lookup(parent, &name); |
|---|
| 1309 | | - if (!dentry) { |
|---|
| 1310 | | -retry: |
|---|
| 1311 | | - dentry = d_alloc_parallel(parent, &name, &wq); |
|---|
| 1312 | | - if (IS_ERR(dentry)) |
|---|
| 1313 | | - return PTR_ERR(dentry); |
|---|
| 1314 | | - } |
|---|
| 1315 | | - if (!d_in_lookup(dentry)) { |
|---|
| 1316 | | - struct fuse_inode *fi; |
|---|
| 1317 | | - inode = d_inode(dentry); |
|---|
| 1318 | | - if (!inode || |
|---|
| 1319 | | - get_node_id(inode) != o->nodeid || |
|---|
| 1320 | | - ((o->attr.mode ^ inode->i_mode) & S_IFMT)) { |
|---|
| 1321 | | - d_invalidate(dentry); |
|---|
| 1322 | | - dput(dentry); |
|---|
| 1323 | | - goto retry; |
|---|
| 1324 | | - } |
|---|
| 1325 | | - if (fuse_is_bad(inode)) { |
|---|
| 1326 | | - dput(dentry); |
|---|
| 1327 | | - return -EIO; |
|---|
| 1328 | | - } |
|---|
| 1329 | | - |
|---|
| 1330 | | - fi = get_fuse_inode(inode); |
|---|
| 1331 | | - spin_lock(&fc->lock); |
|---|
| 1332 | | - fi->nlookup++; |
|---|
| 1333 | | - spin_unlock(&fc->lock); |
|---|
| 1334 | | - |
|---|
| 1335 | | - forget_all_cached_acls(inode); |
|---|
| 1336 | | - fuse_change_attributes(inode, &o->attr, |
|---|
| 1337 | | - entry_attr_timeout(o), |
|---|
| 1338 | | - attr_version); |
|---|
| 1339 | | - /* |
|---|
| 1340 | | - * The other branch comes via fuse_iget() |
|---|
| 1341 | | - * which bumps nlookup inside |
|---|
| 1342 | | - */ |
|---|
| 1343 | | - } else { |
|---|
| 1344 | | - inode = fuse_iget(dir->i_sb, o->nodeid, o->generation, |
|---|
| 1345 | | - &o->attr, entry_attr_timeout(o), |
|---|
| 1346 | | - attr_version); |
|---|
| 1347 | | - if (!inode) |
|---|
| 1348 | | - inode = ERR_PTR(-ENOMEM); |
|---|
| 1349 | | - |
|---|
| 1350 | | - alias = d_splice_alias(inode, dentry); |
|---|
| 1351 | | - d_lookup_done(dentry); |
|---|
| 1352 | | - if (alias) { |
|---|
| 1353 | | - dput(dentry); |
|---|
| 1354 | | - dentry = alias; |
|---|
| 1355 | | - } |
|---|
| 1356 | | - if (IS_ERR(dentry)) |
|---|
| 1357 | | - return PTR_ERR(dentry); |
|---|
| 1358 | | - } |
|---|
| 1359 | | - if (fc->readdirplus_auto) |
|---|
| 1360 | | - set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state); |
|---|
| 1361 | | - fuse_change_entry_timeout(dentry, o); |
|---|
| 1362 | | - |
|---|
| 1363 | | - dput(dentry); |
|---|
| 1364 | | - return 0; |
|---|
| 1365 | | -} |
|---|
| 1366 | | - |
|---|
| 1367 | | -static int parse_dirplusfile(char *buf, size_t nbytes, struct file *file, |
|---|
| 1368 | | - struct dir_context *ctx, u64 attr_version) |
|---|
| 1369 | | -{ |
|---|
| 1370 | | - struct fuse_direntplus *direntplus; |
|---|
| 1371 | | - struct fuse_dirent *dirent; |
|---|
| 1372 | | - size_t reclen; |
|---|
| 1373 | | - int over = 0; |
|---|
| 1374 | | - int ret; |
|---|
| 1375 | | - |
|---|
| 1376 | | - while (nbytes >= FUSE_NAME_OFFSET_DIRENTPLUS) { |
|---|
| 1377 | | - direntplus = (struct fuse_direntplus *) buf; |
|---|
| 1378 | | - dirent = &direntplus->dirent; |
|---|
| 1379 | | - reclen = FUSE_DIRENTPLUS_SIZE(direntplus); |
|---|
| 1380 | | - |
|---|
| 1381 | | - if (!dirent->namelen || dirent->namelen > FUSE_NAME_MAX) |
|---|
| 1382 | | - return -EIO; |
|---|
| 1383 | | - if (reclen > nbytes) |
|---|
| 1384 | | - break; |
|---|
| 1385 | | - if (memchr(dirent->name, '/', dirent->namelen) != NULL) |
|---|
| 1386 | | - return -EIO; |
|---|
| 1387 | | - |
|---|
| 1388 | | - if (!over) { |
|---|
| 1389 | | - /* We fill entries into dstbuf only as much as |
|---|
| 1390 | | - it can hold. But we still continue iterating |
|---|
| 1391 | | - over remaining entries to link them. If not, |
|---|
| 1392 | | - we need to send a FORGET for each of those |
|---|
| 1393 | | - which we did not link. |
|---|
| 1394 | | - */ |
|---|
| 1395 | | - over = !dir_emit(ctx, dirent->name, dirent->namelen, |
|---|
| 1396 | | - dirent->ino, dirent->type); |
|---|
| 1397 | | - if (!over) |
|---|
| 1398 | | - ctx->pos = dirent->off; |
|---|
| 1399 | | - } |
|---|
| 1400 | | - |
|---|
| 1401 | | - buf += reclen; |
|---|
| 1402 | | - nbytes -= reclen; |
|---|
| 1403 | | - |
|---|
| 1404 | | - ret = fuse_direntplus_link(file, direntplus, attr_version); |
|---|
| 1405 | | - if (ret) |
|---|
| 1406 | | - fuse_force_forget(file, direntplus->entry_out.nodeid); |
|---|
| 1407 | | - } |
|---|
| 1402 | + link = page_address(page); |
|---|
| 1403 | + link[res] = '\0'; |
|---|
| 1408 | 1404 | |
|---|
| 1409 | 1405 | return 0; |
|---|
| 1410 | 1406 | } |
|---|
| 1411 | 1407 | |
|---|
| 1412 | | -static int fuse_readdir(struct file *file, struct dir_context *ctx) |
|---|
| 1408 | +static const char *fuse_get_link(struct dentry *dentry, struct inode *inode, |
|---|
| 1409 | + struct delayed_call *callback) |
|---|
| 1413 | 1410 | { |
|---|
| 1414 | | - int plus, err; |
|---|
| 1415 | | - size_t nbytes; |
|---|
| 1416 | | - struct page *page; |
|---|
| 1417 | | - struct inode *inode = file_inode(file); |
|---|
| 1418 | 1411 | struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 1419 | | - struct fuse_req *req; |
|---|
| 1420 | | - u64 attr_version = 0; |
|---|
| 1421 | | - bool locked; |
|---|
| 1412 | + struct page *page; |
|---|
| 1413 | + int err; |
|---|
| 1422 | 1414 | |
|---|
| 1415 | + err = -EIO; |
|---|
| 1423 | 1416 | if (fuse_is_bad(inode)) |
|---|
| 1424 | | - return -EIO; |
|---|
| 1417 | + goto out_err; |
|---|
| 1425 | 1418 | |
|---|
| 1426 | | - req = fuse_get_req(fc, 1); |
|---|
| 1427 | | - if (IS_ERR(req)) |
|---|
| 1428 | | - return PTR_ERR(req); |
|---|
| 1419 | + if (fc->cache_symlinks) |
|---|
| 1420 | + return page_get_link(dentry, inode, callback); |
|---|
| 1421 | + |
|---|
| 1422 | + err = -ECHILD; |
|---|
| 1423 | + if (!dentry) |
|---|
| 1424 | + goto out_err; |
|---|
| 1429 | 1425 | |
|---|
| 1430 | 1426 | page = alloc_page(GFP_KERNEL); |
|---|
| 1431 | | - if (!page) { |
|---|
| 1432 | | - fuse_put_request(fc, req); |
|---|
| 1433 | | - return -ENOMEM; |
|---|
| 1427 | + err = -ENOMEM; |
|---|
| 1428 | + if (!page) |
|---|
| 1429 | + goto out_err; |
|---|
| 1430 | + |
|---|
| 1431 | + err = fuse_readlink_page(inode, page); |
|---|
| 1432 | + if (err) { |
|---|
| 1433 | + __free_page(page); |
|---|
| 1434 | + goto out_err; |
|---|
| 1434 | 1435 | } |
|---|
| 1435 | 1436 | |
|---|
| 1436 | | - plus = fuse_use_readdirplus(inode, ctx); |
|---|
| 1437 | | - req->out.argpages = 1; |
|---|
| 1438 | | - req->num_pages = 1; |
|---|
| 1439 | | - req->pages[0] = page; |
|---|
| 1440 | | - req->page_descs[0].length = PAGE_SIZE; |
|---|
| 1441 | | - if (plus) { |
|---|
| 1442 | | - attr_version = fuse_get_attr_version(fc); |
|---|
| 1443 | | - fuse_read_fill(req, file, ctx->pos, PAGE_SIZE, |
|---|
| 1444 | | - FUSE_READDIRPLUS); |
|---|
| 1445 | | - } else { |
|---|
| 1446 | | - fuse_read_fill(req, file, ctx->pos, PAGE_SIZE, |
|---|
| 1447 | | - FUSE_READDIR); |
|---|
| 1448 | | - } |
|---|
| 1449 | | - locked = fuse_lock_inode(inode); |
|---|
| 1450 | | - fuse_request_send(fc, req); |
|---|
| 1451 | | - fuse_unlock_inode(inode, locked); |
|---|
| 1452 | | - nbytes = req->out.args[0].size; |
|---|
| 1453 | | - err = req->out.h.error; |
|---|
| 1454 | | - fuse_put_request(fc, req); |
|---|
| 1455 | | - if (!err) { |
|---|
| 1456 | | - if (plus) { |
|---|
| 1457 | | - err = parse_dirplusfile(page_address(page), nbytes, |
|---|
| 1458 | | - file, ctx, |
|---|
| 1459 | | - attr_version); |
|---|
| 1460 | | - } else { |
|---|
| 1461 | | - err = parse_dirfile(page_address(page), nbytes, file, |
|---|
| 1462 | | - ctx); |
|---|
| 1463 | | - } |
|---|
| 1464 | | - } |
|---|
| 1437 | + set_delayed_call(callback, page_put_link, page); |
|---|
| 1465 | 1438 | |
|---|
| 1466 | | - __free_page(page); |
|---|
| 1467 | | - fuse_invalidate_atime(inode); |
|---|
| 1468 | | - return err; |
|---|
| 1469 | | -} |
|---|
| 1439 | + return page_address(page); |
|---|
| 1470 | 1440 | |
|---|
| 1471 | | -static const char *fuse_get_link(struct dentry *dentry, |
|---|
| 1472 | | - struct inode *inode, |
|---|
| 1473 | | - struct delayed_call *done) |
|---|
| 1474 | | -{ |
|---|
| 1475 | | - struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 1476 | | - FUSE_ARGS(args); |
|---|
| 1477 | | - char *link; |
|---|
| 1478 | | - ssize_t ret; |
|---|
| 1479 | | - |
|---|
| 1480 | | - if (!dentry) |
|---|
| 1481 | | - return ERR_PTR(-ECHILD); |
|---|
| 1482 | | - |
|---|
| 1483 | | - if (fuse_is_bad(inode)) |
|---|
| 1484 | | - return ERR_PTR(-EIO); |
|---|
| 1485 | | - |
|---|
| 1486 | | - link = kmalloc(PAGE_SIZE, GFP_KERNEL); |
|---|
| 1487 | | - if (!link) |
|---|
| 1488 | | - return ERR_PTR(-ENOMEM); |
|---|
| 1489 | | - |
|---|
| 1490 | | - args.in.h.opcode = FUSE_READLINK; |
|---|
| 1491 | | - args.in.h.nodeid = get_node_id(inode); |
|---|
| 1492 | | - args.out.argvar = 1; |
|---|
| 1493 | | - args.out.numargs = 1; |
|---|
| 1494 | | - args.out.args[0].size = PAGE_SIZE - 1; |
|---|
| 1495 | | - args.out.args[0].value = link; |
|---|
| 1496 | | - ret = fuse_simple_request(fc, &args); |
|---|
| 1497 | | - if (ret < 0) { |
|---|
| 1498 | | - kfree(link); |
|---|
| 1499 | | - link = ERR_PTR(ret); |
|---|
| 1500 | | - } else { |
|---|
| 1501 | | - link[ret] = '\0'; |
|---|
| 1502 | | - set_delayed_call(done, kfree_link, link); |
|---|
| 1503 | | - } |
|---|
| 1504 | | - fuse_invalidate_atime(inode); |
|---|
| 1505 | | - return link; |
|---|
| 1441 | +out_err: |
|---|
| 1442 | + return ERR_PTR(err); |
|---|
| 1506 | 1443 | } |
|---|
| 1507 | 1444 | |
|---|
| 1508 | 1445 | static int fuse_dir_open(struct inode *inode, struct file *file) |
|---|
| .. | .. |
|---|
| 1520 | 1457 | static int fuse_dir_fsync(struct file *file, loff_t start, loff_t end, |
|---|
| 1521 | 1458 | int datasync) |
|---|
| 1522 | 1459 | { |
|---|
| 1523 | | - return fuse_fsync_common(file, start, end, datasync, 1); |
|---|
| 1460 | + struct inode *inode = file->f_mapping->host; |
|---|
| 1461 | + struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 1462 | + int err; |
|---|
| 1463 | + |
|---|
| 1464 | + if (fuse_is_bad(inode)) |
|---|
| 1465 | + return -EIO; |
|---|
| 1466 | + |
|---|
| 1467 | + if (fc->no_fsyncdir) |
|---|
| 1468 | + return 0; |
|---|
| 1469 | + |
|---|
| 1470 | + inode_lock(inode); |
|---|
| 1471 | + err = fuse_fsync_common(file, start, end, datasync, FUSE_FSYNCDIR); |
|---|
| 1472 | + if (err == -ENOSYS) { |
|---|
| 1473 | + fc->no_fsyncdir = 1; |
|---|
| 1474 | + err = 0; |
|---|
| 1475 | + } |
|---|
| 1476 | + inode_unlock(inode); |
|---|
| 1477 | + |
|---|
| 1478 | + return err; |
|---|
| 1524 | 1479 | } |
|---|
| 1525 | 1480 | |
|---|
| 1526 | 1481 | static long fuse_dir_ioctl(struct file *file, unsigned int cmd, |
|---|
| .. | .. |
|---|
| 1607 | 1562 | */ |
|---|
| 1608 | 1563 | void fuse_set_nowrite(struct inode *inode) |
|---|
| 1609 | 1564 | { |
|---|
| 1610 | | - struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 1611 | 1565 | struct fuse_inode *fi = get_fuse_inode(inode); |
|---|
| 1612 | 1566 | |
|---|
| 1613 | 1567 | BUG_ON(!inode_is_locked(inode)); |
|---|
| 1614 | 1568 | |
|---|
| 1615 | | - spin_lock(&fc->lock); |
|---|
| 1569 | + spin_lock(&fi->lock); |
|---|
| 1616 | 1570 | BUG_ON(fi->writectr < 0); |
|---|
| 1617 | 1571 | fi->writectr += FUSE_NOWRITE; |
|---|
| 1618 | | - spin_unlock(&fc->lock); |
|---|
| 1572 | + spin_unlock(&fi->lock); |
|---|
| 1619 | 1573 | wait_event(fi->page_waitq, fi->writectr == FUSE_NOWRITE); |
|---|
| 1620 | 1574 | } |
|---|
| 1621 | 1575 | |
|---|
| .. | .. |
|---|
| 1636 | 1590 | |
|---|
| 1637 | 1591 | void fuse_release_nowrite(struct inode *inode) |
|---|
| 1638 | 1592 | { |
|---|
| 1639 | | - struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 1593 | + struct fuse_inode *fi = get_fuse_inode(inode); |
|---|
| 1640 | 1594 | |
|---|
| 1641 | | - spin_lock(&fc->lock); |
|---|
| 1595 | + spin_lock(&fi->lock); |
|---|
| 1642 | 1596 | __fuse_release_nowrite(inode); |
|---|
| 1643 | | - spin_unlock(&fc->lock); |
|---|
| 1597 | + spin_unlock(&fi->lock); |
|---|
| 1644 | 1598 | } |
|---|
| 1645 | 1599 | |
|---|
| 1646 | 1600 | static void fuse_setattr_fill(struct fuse_conn *fc, struct fuse_args *args, |
|---|
| .. | .. |
|---|
| 1648 | 1602 | struct fuse_setattr_in *inarg_p, |
|---|
| 1649 | 1603 | struct fuse_attr_out *outarg_p) |
|---|
| 1650 | 1604 | { |
|---|
| 1651 | | - args->in.h.opcode = FUSE_SETATTR; |
|---|
| 1652 | | - args->in.h.nodeid = get_node_id(inode); |
|---|
| 1653 | | - args->in.numargs = 1; |
|---|
| 1654 | | - args->in.args[0].size = sizeof(*inarg_p); |
|---|
| 1655 | | - args->in.args[0].value = inarg_p; |
|---|
| 1656 | | - args->out.numargs = 1; |
|---|
| 1657 | | - args->out.args[0].size = sizeof(*outarg_p); |
|---|
| 1658 | | - args->out.args[0].value = outarg_p; |
|---|
| 1605 | + args->opcode = FUSE_SETATTR; |
|---|
| 1606 | + args->nodeid = get_node_id(inode); |
|---|
| 1607 | + args->in_numargs = 1; |
|---|
| 1608 | + args->in_args[0].size = sizeof(*inarg_p); |
|---|
| 1609 | + args->in_args[0].value = inarg_p; |
|---|
| 1610 | + args->out_numargs = 1; |
|---|
| 1611 | + args->out_args[0].size = sizeof(*outarg_p); |
|---|
| 1612 | + args->out_args[0].value = outarg_p; |
|---|
| 1659 | 1613 | } |
|---|
| 1660 | 1614 | |
|---|
| 1661 | 1615 | /* |
|---|
| .. | .. |
|---|
| 1663 | 1617 | */ |
|---|
| 1664 | 1618 | int fuse_flush_times(struct inode *inode, struct fuse_file *ff) |
|---|
| 1665 | 1619 | { |
|---|
| 1666 | | - struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 1620 | + struct fuse_mount *fm = get_fuse_mount(inode); |
|---|
| 1667 | 1621 | FUSE_ARGS(args); |
|---|
| 1668 | 1622 | struct fuse_setattr_in inarg; |
|---|
| 1669 | 1623 | struct fuse_attr_out outarg; |
|---|
| .. | .. |
|---|
| 1674 | 1628 | inarg.valid = FATTR_MTIME; |
|---|
| 1675 | 1629 | inarg.mtime = inode->i_mtime.tv_sec; |
|---|
| 1676 | 1630 | inarg.mtimensec = inode->i_mtime.tv_nsec; |
|---|
| 1677 | | - if (fc->minor >= 23) { |
|---|
| 1631 | + if (fm->fc->minor >= 23) { |
|---|
| 1678 | 1632 | inarg.valid |= FATTR_CTIME; |
|---|
| 1679 | 1633 | inarg.ctime = inode->i_ctime.tv_sec; |
|---|
| 1680 | 1634 | inarg.ctimensec = inode->i_ctime.tv_nsec; |
|---|
| .. | .. |
|---|
| 1683 | 1637 | inarg.valid |= FATTR_FH; |
|---|
| 1684 | 1638 | inarg.fh = ff->fh; |
|---|
| 1685 | 1639 | } |
|---|
| 1686 | | - fuse_setattr_fill(fc, &args, inode, &inarg, &outarg); |
|---|
| 1640 | + fuse_setattr_fill(fm->fc, &args, inode, &inarg, &outarg); |
|---|
| 1687 | 1641 | |
|---|
| 1688 | | - return fuse_simple_request(fc, &args); |
|---|
| 1642 | + return fuse_simple_request(fm, &args); |
|---|
| 1689 | 1643 | } |
|---|
| 1690 | 1644 | |
|---|
| 1691 | 1645 | /* |
|---|
| .. | .. |
|---|
| 1700 | 1654 | struct file *file) |
|---|
| 1701 | 1655 | { |
|---|
| 1702 | 1656 | struct inode *inode = d_inode(dentry); |
|---|
| 1703 | | - struct fuse_conn *fc = get_fuse_conn(inode); |
|---|
| 1657 | + struct fuse_mount *fm = get_fuse_mount(inode); |
|---|
| 1658 | + struct fuse_conn *fc = fm->fc; |
|---|
| 1704 | 1659 | struct fuse_inode *fi = get_fuse_inode(inode); |
|---|
| 1705 | 1660 | FUSE_ARGS(args); |
|---|
| 1706 | 1661 | struct fuse_setattr_in inarg; |
|---|
| .. | .. |
|---|
| 1710 | 1665 | loff_t oldsize; |
|---|
| 1711 | 1666 | int err; |
|---|
| 1712 | 1667 | bool trust_local_cmtime = is_wb && S_ISREG(inode->i_mode); |
|---|
| 1668 | + bool fault_blocked = false; |
|---|
| 1713 | 1669 | |
|---|
| 1714 | 1670 | if (!fc->default_permissions) |
|---|
| 1715 | 1671 | attr->ia_valid |= ATTR_FORCE; |
|---|
| .. | .. |
|---|
| 1717 | 1673 | err = setattr_prepare(dentry, attr); |
|---|
| 1718 | 1674 | if (err) |
|---|
| 1719 | 1675 | return err; |
|---|
| 1676 | + |
|---|
| 1677 | + if (attr->ia_valid & ATTR_SIZE) { |
|---|
| 1678 | + if (WARN_ON(!S_ISREG(inode->i_mode))) |
|---|
| 1679 | + return -EIO; |
|---|
| 1680 | + is_truncate = true; |
|---|
| 1681 | + } |
|---|
| 1682 | + |
|---|
| 1683 | + if (FUSE_IS_DAX(inode) && is_truncate) { |
|---|
| 1684 | + down_write(&fi->i_mmap_sem); |
|---|
| 1685 | + fault_blocked = true; |
|---|
| 1686 | + err = fuse_dax_break_layouts(inode, 0, 0); |
|---|
| 1687 | + if (err) { |
|---|
| 1688 | + up_write(&fi->i_mmap_sem); |
|---|
| 1689 | + return err; |
|---|
| 1690 | + } |
|---|
| 1691 | + } |
|---|
| 1720 | 1692 | |
|---|
| 1721 | 1693 | if (attr->ia_valid & ATTR_OPEN) { |
|---|
| 1722 | 1694 | /* This is coming from open(..., ... | O_TRUNC); */ |
|---|
| .. | .. |
|---|
| 1730 | 1702 | */ |
|---|
| 1731 | 1703 | i_size_write(inode, 0); |
|---|
| 1732 | 1704 | truncate_pagecache(inode, 0); |
|---|
| 1733 | | - return 0; |
|---|
| 1705 | + goto out; |
|---|
| 1734 | 1706 | } |
|---|
| 1735 | 1707 | file = NULL; |
|---|
| 1736 | 1708 | } |
|---|
| 1737 | | - |
|---|
| 1738 | | - if (attr->ia_valid & ATTR_SIZE) |
|---|
| 1739 | | - is_truncate = true; |
|---|
| 1740 | 1709 | |
|---|
| 1741 | 1710 | /* Flush dirty data/metadata before non-truncate SETATTR */ |
|---|
| 1742 | 1711 | if (is_wb && S_ISREG(inode->i_mode) && |
|---|
| .. | .. |
|---|
| 1772 | 1741 | inarg.lock_owner = fuse_lock_owner_id(fc, current->files); |
|---|
| 1773 | 1742 | } |
|---|
| 1774 | 1743 | fuse_setattr_fill(fc, &args, inode, &inarg, &outarg); |
|---|
| 1775 | | - err = fuse_simple_request(fc, &args); |
|---|
| 1744 | + err = fuse_simple_request(fm, &args); |
|---|
| 1776 | 1745 | if (err) { |
|---|
| 1777 | 1746 | if (err == -EINTR) |
|---|
| 1778 | 1747 | fuse_invalidate_attr(inode); |
|---|
| .. | .. |
|---|
| 1780 | 1749 | } |
|---|
| 1781 | 1750 | |
|---|
| 1782 | 1751 | if (fuse_invalid_attr(&outarg.attr) || |
|---|
| 1783 | | - (inode->i_mode ^ outarg.attr.mode) & S_IFMT) { |
|---|
| 1752 | + inode_wrong_type(inode, outarg.attr.mode)) { |
|---|
| 1784 | 1753 | fuse_make_bad(inode); |
|---|
| 1785 | 1754 | err = -EIO; |
|---|
| 1786 | 1755 | goto error; |
|---|
| 1787 | 1756 | } |
|---|
| 1788 | 1757 | |
|---|
| 1789 | | - spin_lock(&fc->lock); |
|---|
| 1758 | + spin_lock(&fi->lock); |
|---|
| 1790 | 1759 | /* the kernel maintains i_mtime locally */ |
|---|
| 1791 | 1760 | if (trust_local_cmtime) { |
|---|
| 1792 | 1761 | if (attr->ia_valid & ATTR_MTIME) |
|---|
| .. | .. |
|---|
| 1804 | 1773 | i_size_write(inode, outarg.attr.size); |
|---|
| 1805 | 1774 | |
|---|
| 1806 | 1775 | if (is_truncate) { |
|---|
| 1807 | | - /* NOTE: this may release/reacquire fc->lock */ |
|---|
| 1776 | + /* NOTE: this may release/reacquire fi->lock */ |
|---|
| 1808 | 1777 | __fuse_release_nowrite(inode); |
|---|
| 1809 | 1778 | } |
|---|
| 1810 | | - spin_unlock(&fc->lock); |
|---|
| 1779 | + spin_unlock(&fi->lock); |
|---|
| 1811 | 1780 | |
|---|
| 1812 | 1781 | /* |
|---|
| 1813 | 1782 | * Only call invalidate_inode_pages2() after removing |
|---|
| .. | .. |
|---|
| 1820 | 1789 | } |
|---|
| 1821 | 1790 | |
|---|
| 1822 | 1791 | clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state); |
|---|
| 1792 | +out: |
|---|
| 1793 | + if (fault_blocked) |
|---|
| 1794 | + up_write(&fi->i_mmap_sem); |
|---|
| 1795 | + |
|---|
| 1823 | 1796 | return 0; |
|---|
| 1824 | 1797 | |
|---|
| 1825 | 1798 | error: |
|---|
| .. | .. |
|---|
| 1827 | 1800 | fuse_release_nowrite(inode); |
|---|
| 1828 | 1801 | |
|---|
| 1829 | 1802 | clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state); |
|---|
| 1803 | + |
|---|
| 1804 | + if (fault_blocked) |
|---|
| 1805 | + up_write(&fi->i_mmap_sem); |
|---|
| 1830 | 1806 | return err; |
|---|
| 1831 | 1807 | } |
|---|
| 1832 | 1808 | |
|---|
| .. | .. |
|---|
| 1901 | 1877 | if (fuse_is_bad(inode)) |
|---|
| 1902 | 1878 | return -EIO; |
|---|
| 1903 | 1879 | |
|---|
| 1904 | | - if (!fuse_allow_current_process(fc)) |
|---|
| 1880 | + if (!fuse_allow_current_process(fc)) { |
|---|
| 1881 | + if (!request_mask) { |
|---|
| 1882 | + /* |
|---|
| 1883 | + * If user explicitly requested *nothing* then don't |
|---|
| 1884 | + * error out, but return st_dev only. |
|---|
| 1885 | + */ |
|---|
| 1886 | + stat->result_mask = 0; |
|---|
| 1887 | + stat->dev = inode->i_sb->s_dev; |
|---|
| 1888 | + return 0; |
|---|
| 1889 | + } |
|---|
| 1905 | 1890 | return -EACCES; |
|---|
| 1891 | + } |
|---|
| 1906 | 1892 | |
|---|
| 1907 | | - return fuse_update_get_attr(inode, NULL, stat, flags); |
|---|
| 1893 | + return fuse_update_get_attr(inode, NULL, stat, request_mask, flags); |
|---|
| 1908 | 1894 | } |
|---|
| 1909 | 1895 | |
|---|
| 1910 | 1896 | static const struct inode_operations fuse_dir_inode_operations = { |
|---|
| .. | .. |
|---|
| 1960 | 1946 | |
|---|
| 1961 | 1947 | void fuse_init_dir(struct inode *inode) |
|---|
| 1962 | 1948 | { |
|---|
| 1949 | + struct fuse_inode *fi = get_fuse_inode(inode); |
|---|
| 1950 | + |
|---|
| 1963 | 1951 | inode->i_op = &fuse_dir_inode_operations; |
|---|
| 1964 | 1952 | inode->i_fop = &fuse_dir_operations; |
|---|
| 1953 | + |
|---|
| 1954 | + spin_lock_init(&fi->rdc.lock); |
|---|
| 1955 | + fi->rdc.cached = false; |
|---|
| 1956 | + fi->rdc.size = 0; |
|---|
| 1957 | + fi->rdc.pos = 0; |
|---|
| 1958 | + fi->rdc.version = 0; |
|---|
| 1965 | 1959 | } |
|---|
| 1960 | + |
|---|
| 1961 | +static int fuse_symlink_readpage(struct file *null, struct page *page) |
|---|
| 1962 | +{ |
|---|
| 1963 | + int err = fuse_readlink_page(page->mapping->host, page); |
|---|
| 1964 | + |
|---|
| 1965 | + if (!err) |
|---|
| 1966 | + SetPageUptodate(page); |
|---|
| 1967 | + |
|---|
| 1968 | + unlock_page(page); |
|---|
| 1969 | + |
|---|
| 1970 | + return err; |
|---|
| 1971 | +} |
|---|
| 1972 | + |
|---|
| 1973 | +static const struct address_space_operations fuse_symlink_aops = { |
|---|
| 1974 | + .readpage = fuse_symlink_readpage, |
|---|
| 1975 | +}; |
|---|
| 1966 | 1976 | |
|---|
| 1967 | 1977 | void fuse_init_symlink(struct inode *inode) |
|---|
| 1968 | 1978 | { |
|---|
| 1969 | 1979 | inode->i_op = &fuse_symlink_inode_operations; |
|---|
| 1980 | + inode->i_data.a_ops = &fuse_symlink_aops; |
|---|
| 1981 | + inode_nohighmem(inode); |
|---|
| 1970 | 1982 | } |
|---|