Lines Matching +full:slew +full:- +full:time +full:- +full:us
1 // SPDX-License-Identifier: GPL-2.0-or-later
113 struct address_space *mapping = req->vnode->netfs.inode.i_mapping; in afs_dir_read_cleanup()
115 pgoff_t last = req->nr_pages - 1; in afs_dir_read_cleanup()
117 XA_STATE(xas, &mapping->i_pages, 0); in afs_dir_read_cleanup()
119 if (unlikely(!req->nr_pages)) in afs_dir_read_cleanup()
146 * we must take care because the directory may change size under us. in afs_dir_check_folio()
152 size = min_t(loff_t, folio_size(folio), i_size - pos); in afs_dir_check_folio()
155 if (block->hdr.magic != AFS_DIR_MAGIC) { in afs_dir_check_folio()
157 __func__, dvnode->netfs.inode.i_ino, in afs_dir_check_folio()
158 pos, offset, size, ntohs(block->hdr.magic)); in afs_dir_check_folio()
161 trace_afs_file_error(dvnode, -EIO, afs_file_error_dir_bad_magic); in afs_dir_check_folio()
167 * *should* be NUL-terminated anyway. in afs_dir_check_folio()
169 ((u8 *)block)[AFS_DIR_BLOCK_SIZE - 1] = 0; in afs_dir_check_folio()
187 struct address_space *mapping = dvnode->netfs.inode.i_mapping; in afs_dir_dump()
189 pgoff_t last = req->nr_pages - 1; in afs_dir_dump()
192 XA_STATE(xas, &mapping->i_pages, 0); in afs_dir_dump()
195 dvnode->fid.vid, dvnode->fid.vnode, in afs_dir_dump()
196 req->file_size, req->len, req->actual_len); in afs_dir_dump()
198 req->pos, req->nr_pages, in afs_dir_dump()
199 req->iter->iov_offset, iov_iter_count(req->iter)); in afs_dir_dump()
207 size = min_t(loff_t, folio_size(folio), req->actual_len - folio_pos(folio)); in afs_dir_dump()
221 struct address_space *mapping = dvnode->netfs.inode.i_mapping; in afs_dir_check()
223 pgoff_t last = req->nr_pages - 1; in afs_dir_check()
226 XA_STATE(xas, &mapping->i_pages, 0); in afs_dir_check()
228 if (unlikely(!req->nr_pages)) in afs_dir_check()
238 if (!afs_dir_check_folio(dvnode, folio, req->actual_len)) { in afs_dir_check()
240 ret = -EIO; in afs_dir_check()
254 _enter("{%lu}", inode->i_ino); in afs_dir_open()
259 if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(inode)->flags)) in afs_dir_open()
260 return -ENOENT; in afs_dir_open()
271 __acquires(&dvnode->validate_lock) in afs_read_dir()
273 struct address_space *mapping = dvnode->netfs.inode.i_mapping; in afs_read_dir()
284 return ERR_PTR(-ENOMEM); in afs_read_dir()
286 refcount_set(&req->usage, 1); in afs_read_dir()
287 req->vnode = dvnode; in afs_read_dir()
288 req->key = key_get(key); in afs_read_dir()
289 req->cleanup = afs_dir_read_cleanup; in afs_read_dir()
292 i_size = i_size_read(&dvnode->netfs.inode); in afs_read_dir()
300 trace_afs_file_error(dvnode, -EFBIG, afs_file_error_dir_big); in afs_read_dir()
301 ret = -EFBIG; in afs_read_dir()
307 nr_pages = (i_size + PAGE_SIZE - 1) / PAGE_SIZE; in afs_read_dir()
309 req->actual_len = i_size; /* May change */ in afs_read_dir()
310 req->len = nr_pages * PAGE_SIZE; /* We can ask for more than there is */ in afs_read_dir()
311 req->data_version = dvnode->status.data_version; /* May change */ in afs_read_dir()
312 iov_iter_xarray(&req->def_iter, ITER_DEST, &dvnode->netfs.inode.i_mapping->i_pages, in afs_read_dir()
314 req->iter = &req->def_iter; in afs_read_dir()
320 i = req->nr_pages; in afs_read_dir()
326 if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) in afs_read_dir()
330 mapping->gfp_mask); in afs_read_dir()
339 req->nr_pages += folio_nr_pages(folio); in afs_read_dir()
346 ret = -ERESTARTSYS; in afs_read_dir()
347 if (down_read_killable(&dvnode->validate_lock) < 0) in afs_read_dir()
350 if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) in afs_read_dir()
353 up_read(&dvnode->validate_lock); in afs_read_dir()
354 if (down_write_killable(&dvnode->validate_lock) < 0) in afs_read_dir()
357 if (!test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) { in afs_read_dir()
363 task_io_account_read(PAGE_SIZE * req->nr_pages); in afs_read_dir()
365 if (req->len < req->file_size) { in afs_read_dir()
369 up_write(&dvnode->validate_lock); in afs_read_dir()
370 remote_size = req->file_size; in afs_read_dir()
381 set_bit(AFS_VNODE_DIR_VALID, &dvnode->flags); in afs_read_dir()
384 downgrade_write(&dvnode->validate_lock); in afs_read_dir()
389 up_write(&dvnode->validate_lock); in afs_read_dir()
409 _enter("%llx,%x", ctx->pos, blkoff); in afs_dir_iterate_block()
411 curr = (ctx->pos - blkoff) / sizeof(union afs_xdr_dirent); in afs_dir_iterate_block()
413 /* walk through the block, an entry at a time */ in afs_dir_iterate_block()
419 if (!(block->hdr.bitmap[offset / 8] & in afs_dir_iterate_block()
425 ctx->pos = blkoff + in afs_dir_iterate_block()
431 dire = &block->dirents[offset]; in afs_dir_iterate_block()
432 nlen = strnlen(dire->u.name, in afs_dir_iterate_block()
433 sizeof(*block) - in afs_dir_iterate_block()
435 if (nlen > AFSNAMEMAX - 1) { in afs_dir_iterate_block()
445 nlen, dire->u.name); in afs_dir_iterate_block()
458 /* Check that the name-extension dirents are all allocated */ in afs_dir_iterate_block()
461 if (!(block->hdr.bitmap[ix / 8] & (1 << (ix % 8)))) { in afs_dir_iterate_block()
473 ctx->pos = blkoff + next * sizeof(union afs_xdr_dirent); in afs_dir_iterate_block()
478 if (!dir_emit(ctx, dire->u.name, nlen, in afs_dir_iterate_block()
479 ntohl(dire->u.vnode), in afs_dir_iterate_block()
480 (ctx->actor == afs_lookup_filldir || in afs_dir_iterate_block()
481 ctx->actor == afs_lookup_one_filldir)? in afs_dir_iterate_block()
482 ntohl(dire->u.unique) : DT_UNKNOWN)) { in afs_dir_iterate_block()
487 ctx->pos = blkoff + next * sizeof(union afs_xdr_dirent); in afs_dir_iterate_block()
507 _enter("{%lu},%u,,", dir->i_ino, (unsigned)ctx->pos); in afs_dir_iterate()
509 if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(dir)->flags)) { in afs_dir_iterate()
510 _leave(" = -ESTALE"); in afs_dir_iterate()
511 return -ESTALE; in afs_dir_iterate()
517 *_dir_version = req->data_version; in afs_dir_iterate()
520 ctx->pos += sizeof(union afs_xdr_dirent) - 1; in afs_dir_iterate()
521 ctx->pos &= ~(sizeof(union afs_xdr_dirent) - 1); in afs_dir_iterate()
525 while (ctx->pos < req->actual_len) { in afs_dir_iterate()
526 /* Fetch the appropriate folio from the directory and re-add it in afs_dir_iterate()
529 folio = __filemap_get_folio(dir->i_mapping, ctx->pos / PAGE_SIZE, in afs_dir_iterate()
536 offset = round_down(ctx->pos, sizeof(*dblock)) - folio_file_pos(folio); in afs_dir_iterate()
538 req->actual_len - folio_file_pos(folio)); in afs_dir_iterate()
554 up_read(&dvnode->validate_lock); in afs_dir_iterate()
573 * - if afs_dir_iterate_block() spots this function, it'll pass the FID
583 cookie->name.name, cookie->name.len, name, nlen, in afs_lookup_one_filldir()
590 if (cookie->name.len != nlen || in afs_lookup_one_filldir()
591 memcmp(cookie->name.name, name, nlen) != 0) { in afs_lookup_one_filldir()
596 cookie->fid.vnode = ino; in afs_lookup_one_filldir()
597 cookie->fid.unique = dtype; in afs_lookup_one_filldir()
598 cookie->found = 1; in afs_lookup_one_filldir()
606 * - just returns the FID the dentry name maps to if found
612 struct afs_super_info *as = dir->i_sb->s_fs_info; in afs_do_lookup_one()
615 .name = dentry->d_name, in afs_do_lookup_one()
616 .fid.vid = as->volume->vid in afs_do_lookup_one()
620 _enter("{%lu},%p{%pd},", dir->i_ino, dentry, dentry); in afs_do_lookup_one()
630 _leave(" = -ENOENT [not found]"); in afs_do_lookup_one()
631 return -ENOENT; in afs_do_lookup_one()
635 _leave(" = 0 { vn=%llu u=%u }", fid->vnode, fid->unique); in afs_do_lookup_one()
641 * - if afs_dir_iterate_block() spots this function, it'll pass the FID
651 cookie->name.name, cookie->name.len, name, nlen, in afs_lookup_filldir()
658 if (cookie->found) { in afs_lookup_filldir()
659 if (cookie->nr_fids < 50) { in afs_lookup_filldir()
660 cookie->fids[cookie->nr_fids].vnode = ino; in afs_lookup_filldir()
661 cookie->fids[cookie->nr_fids].unique = dtype; in afs_lookup_filldir()
662 cookie->nr_fids++; in afs_lookup_filldir()
664 } else if (cookie->name.len == nlen && in afs_lookup_filldir()
665 memcmp(cookie->name.name, name, nlen) == 0) { in afs_lookup_filldir()
666 cookie->fids[1].vnode = ino; in afs_lookup_filldir()
667 cookie->fids[1].unique = dtype; in afs_lookup_filldir()
668 cookie->found = 1; in afs_lookup_filldir()
669 if (cookie->one_only) in afs_lookup_filldir()
673 return cookie->nr_fids < 50; in afs_lookup_filldir()
678 * into inodes and save the first one - which is the one we actually want.
690 for (i = 0; i < op->nr_files; i++) { in afs_do_lookup_success()
693 vp = &op->file[0]; in afs_do_lookup_success()
694 abort_code = vp->scb.status.abort_code; in afs_do_lookup_success()
696 op->ac.abort_code = abort_code; in afs_do_lookup_success()
697 op->error = afs_abort_to_error(abort_code); in afs_do_lookup_success()
702 vp = &op->file[1]; in afs_do_lookup_success()
706 vp = &op->more_files[i - 2]; in afs_do_lookup_success()
710 if (!vp->scb.have_status && !vp->scb.have_error) in afs_do_lookup_success()
714 if (vp->vnode) { in afs_do_lookup_success()
715 if (!test_bit(AFS_VNODE_UNSET, &vp->vnode->flags)) in afs_do_lookup_success()
717 } else if (vp->scb.status.abort_code == 0) { in afs_do_lookup_success()
721 afs_cache_permit(vnode, op->key, in afs_do_lookup_success()
722 0 /* Assume vnode->cb_break is 0 */ + in afs_do_lookup_success()
723 op->cb_v_break, in afs_do_lookup_success()
724 &vp->scb); in afs_do_lookup_success()
725 vp->vnode = vnode; in afs_do_lookup_success()
726 vp->put_vnode = true; in afs_do_lookup_success()
729 _debug("- abort %d %llx:%llx.%x", in afs_do_lookup_success()
730 vp->scb.status.abort_code, in afs_do_lookup_success()
731 vp->fid.vid, vp->fid.vnode, vp->fid.unique); in afs_do_lookup_success()
758 struct afs_volume *volume = dvnode->volume; in afs_server_supports_ibulk()
763 if (!test_bit(AFS_VOLUME_MAYBE_NO_IBULK, &volume->flags)) in afs_server_supports_ibulk()
767 slist = rcu_dereference(volume->servers); in afs_server_supports_ibulk()
769 for (i = 0; i < slist->nr_servers; i++) { in afs_server_supports_ibulk()
770 server = slist->servers[i].server; in afs_server_supports_ibulk()
771 if (server == dvnode->cb_server) { in afs_server_supports_ibulk()
772 if (test_bit(AFS_SERVER_FL_NO_IBULK, &server->flags)) in afs_server_supports_ibulk()
783 * Do a lookup in a directory. We make use of bulk lookup to query a slew of
795 afs_dataversion_t data_version = READ_ONCE(dvnode->status.data_version); in afs_do_lookup()
799 _enter("{%lu},%p{%pd},", dir->i_ino, dentry, dentry); in afs_do_lookup()
803 return ERR_PTR(-ENOMEM); in afs_do_lookup()
805 for (i = 0; i < ARRAY_SIZE(cookie->fids); i++) in afs_do_lookup()
806 cookie->fids[i].vid = dvnode->fid.vid; in afs_do_lookup()
807 cookie->ctx.actor = afs_lookup_filldir; in afs_do_lookup()
808 cookie->name = dentry->d_name; in afs_do_lookup()
809 cookie->nr_fids = 2; /* slot 0 is saved for the fid we actually want in afs_do_lookup()
813 cookie->one_only = true; in afs_do_lookup()
816 ret = afs_dir_iterate(dir, &cookie->ctx, key, &data_version); in afs_do_lookup()
820 dentry->d_fsdata = (void *)(unsigned long)data_version; in afs_do_lookup()
822 ret = -ENOENT; in afs_do_lookup()
823 if (!cookie->found) in afs_do_lookup()
827 inode = ilookup5(dir->i_sb, cookie->fids[1].vnode, in afs_do_lookup()
828 afs_ilookup5_test_by_fid, &cookie->fids[1]); in afs_do_lookup()
832 /* Okay, we didn't find it. We need to query the server - and whilst in afs_do_lookup()
836 op = afs_alloc_operation(NULL, dvnode->volume); in afs_do_lookup()
843 afs_op_set_fid(op, 1, &cookie->fids[1]); in afs_do_lookup()
845 op->nr_files = cookie->nr_fids; in afs_do_lookup()
846 _debug("nr_files %u", op->nr_files); in afs_do_lookup()
849 op->error = -ENOMEM; in afs_do_lookup()
850 if (op->nr_files > 2) { in afs_do_lookup()
851 op->more_files = kvcalloc(op->nr_files - 2, in afs_do_lookup()
854 if (!op->more_files) in afs_do_lookup()
857 for (i = 2; i < op->nr_files; i++) { in afs_do_lookup()
858 vp = &op->more_files[i - 2]; in afs_do_lookup()
859 vp->fid = cookie->fids[i]; in afs_do_lookup()
864 ti = ilookup5_nowait(dir->i_sb, vp->fid.vnode, in afs_do_lookup()
865 afs_ilookup5_test_by_fid, &vp->fid); in afs_do_lookup()
868 vp->dv_before = vnode->status.data_version; in afs_do_lookup()
869 vp->cb_break_before = afs_calc_vnode_cb_break(vnode); in afs_do_lookup()
870 vp->vnode = vnode; in afs_do_lookup()
871 vp->put_vnode = true; in afs_do_lookup()
872 vp->speculative = true; /* vnode not locked */ in afs_do_lookup()
881 op->error = -ENOTSUPP; in afs_do_lookup()
882 if (!cookie->one_only) { in afs_do_lookup()
883 op->ops = &afs_inline_bulk_status_operation; in afs_do_lookup()
888 if (op->error == -ENOTSUPP) { in afs_do_lookup()
890 * op if any of the lookups fails - so, for the moment, revert in afs_do_lookup()
891 * to FS.FetchStatus for op->file[1]. in afs_do_lookup()
893 op->fetch_status.which = 1; in afs_do_lookup()
894 op->ops = &afs_lookup_fetch_status_operation; in afs_do_lookup()
898 inode = ERR_PTR(op->error); in afs_do_lookup()
901 if (op->error == 0) { in afs_do_lookup()
902 inode = &op->file[1].vnode->netfs.inode; in afs_do_lookup()
903 op->file[1].vnode = NULL; in afs_do_lookup()
906 if (op->file[0].scb.have_status) in afs_do_lookup()
907 dentry->d_fsdata = (void *)(unsigned long)op->file[0].scb.status.data_version; in afs_do_lookup()
909 dentry->d_fsdata = (void *)(unsigned long)op->file[0].dv_before; in afs_do_lookup()
931 ret = ERR_PTR(-ENOMEM); in afs_lookup_atsys()
935 if (dentry->d_name.len > 4) { in afs_lookup_atsys()
936 memcpy(p, dentry->d_name.name, dentry->d_name.len - 4); in afs_lookup_atsys()
937 p += dentry->d_name.len - 4; in afs_lookup_atsys()
941 read_lock(&net->sysnames_lock); in afs_lookup_atsys()
942 subs = net->sysnames; in afs_lookup_atsys()
943 refcount_inc(&subs->usage); in afs_lookup_atsys()
944 read_unlock(&net->sysnames_lock); in afs_lookup_atsys()
946 for (i = 0; i < subs->nr; i++) { in afs_lookup_atsys()
947 name = subs->subs[i]; in afs_lookup_atsys()
948 len = dentry->d_name.len - 4 + strlen(name); in afs_lookup_atsys()
950 ret = ERR_PTR(-ENAMETOOLONG); in afs_lookup_atsys()
955 ret = lookup_one_len(buf, dentry->d_parent, len); in afs_lookup_atsys()
987 dvnode->fid.vid, dvnode->fid.vnode, dentry, dentry); in afs_lookup()
991 if (dentry->d_name.len >= AFSNAMEMAX) { in afs_lookup()
992 _leave(" = -ENAMETOOLONG"); in afs_lookup()
993 return ERR_PTR(-ENAMETOOLONG); in afs_lookup()
996 if (test_bit(AFS_VNODE_DELETED, &dvnode->flags)) { in afs_lookup()
997 _leave(" = -ESTALE"); in afs_lookup()
998 return ERR_PTR(-ESTALE); in afs_lookup()
1001 key = afs_request_key(dvnode->volume->cell); in afs_lookup()
1014 if (dentry->d_name.len >= 4 && in afs_lookup()
1015 dentry->d_name.name[dentry->d_name.len - 4] == '@' && in afs_lookup()
1016 dentry->d_name.name[dentry->d_name.len - 3] == 's' && in afs_lookup()
1017 dentry->d_name.name[dentry->d_name.len - 2] == 'y' && in afs_lookup()
1018 dentry->d_name.name[dentry->d_name.len - 1] == 's') in afs_lookup()
1024 if (inode == ERR_PTR(-ENOENT)) in afs_lookup()
1028 fid = AFS_FS_I(inode)->fid; in afs_lookup()
1030 _debug("splice %p", dentry->d_inode); in afs_lookup()
1033 d->d_fsdata = dentry->d_fsdata; in afs_lookup()
1034 trace_afs_lookup(dvnode, &d->d_name, &fid); in afs_lookup()
1036 trace_afs_lookup(dvnode, &dentry->d_name, &fid); in afs_lookup()
1055 parent = READ_ONCE(dentry->d_parent); in afs_d_revalidate_rcu()
1058 return -ECHILD; in afs_d_revalidate_rcu()
1060 if (test_bit(AFS_VNODE_DELETED, &dvnode->flags)) in afs_d_revalidate_rcu()
1061 return -ECHILD; in afs_d_revalidate_rcu()
1064 return -ECHILD; in afs_d_revalidate_rcu()
1068 * on a 32-bit system, we only have 32 bits in the dentry to store the in afs_d_revalidate_rcu()
1071 dir_version = (long)READ_ONCE(dvnode->status.data_version); in afs_d_revalidate_rcu()
1072 de_version = (long)READ_ONCE(dentry->d_fsdata); in afs_d_revalidate_rcu()
1074 dir_version = (long)READ_ONCE(dvnode->invalid_before); in afs_d_revalidate_rcu()
1075 if (de_version - dir_version < 0) in afs_d_revalidate_rcu()
1076 return -ECHILD; in afs_d_revalidate_rcu()
1084 * - NOTE! the hit can be a negative hit too, so we can't assume we have an
1104 vnode->fid.vid, vnode->fid.vnode, dentry, in afs_d_revalidate()
1105 vnode->flags); in afs_d_revalidate()
1110 key = afs_request_key(AFS_FS_S(dentry->d_sb)->volume->cell); in afs_d_revalidate()
1121 if (test_bit(AFS_VNODE_DELETED, &dir->flags)) { in afs_d_revalidate()
1128 * on a 32-bit system, we only have 32 bits in the dentry to store the in afs_d_revalidate()
1131 dir_version = dir->status.data_version; in afs_d_revalidate()
1132 de_version = (long)dentry->d_fsdata; in afs_d_revalidate()
1136 invalid_before = dir->invalid_before; in afs_d_revalidate()
1137 if (de_version - (long)invalid_before >= 0) in afs_d_revalidate()
1144 ret = afs_do_lookup_one(&dir->netfs.inode, dentry, &fid, key, &dir_version); in afs_d_revalidate()
1161 if (fid.vnode != vnode->fid.vnode) { in afs_d_revalidate()
1164 vnode->fid.vnode); in afs_d_revalidate()
1171 if (fid.unique != vnode->fid.unique) { in afs_d_revalidate()
1172 _debug("%pd: file deleted (uq %u -> %u I:%u)", in afs_d_revalidate()
1174 vnode->fid.unique, in afs_d_revalidate()
1175 vnode->netfs.inode.i_generation); in afs_d_revalidate()
1180 case -ENOENT: in afs_d_revalidate()
1194 dentry->d_fsdata = (void *)(unsigned long)dir_version; in afs_d_revalidate()
1213 * - called from dput() when d_count is going to 0.
1214 * - return 1 to request dentry be unhashed, 0 otherwise
1220 if (dentry->d_flags & DCACHE_NFSFS_RENAMED) in afs_d_delete()
1224 (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(d_inode(dentry))->flags) || in afs_d_delete()
1225 test_bit(AFS_VNODE_PSEUDODIR, &AFS_FS_I(d_inode(dentry))->flags))) in afs_d_delete()
1241 if (dentry->d_flags & DCACHE_NFSFS_RENAMED) in afs_d_iput()
1256 struct afs_vnode *vnode = op->file[0].vnode; in afs_check_for_remote_deletion()
1258 switch (op->ac.abort_code) { in afs_check_for_remote_deletion()
1260 set_bit(AFS_VNODE_DELETED, &vnode->flags); in afs_check_for_remote_deletion()
1270 struct afs_vnode_param *vp = &op->file[1]; in afs_vnode_new_inode()
1276 ASSERTCMP(op->error, ==, 0); in afs_vnode_new_inode()
1280 /* ENOMEM or EINTR at a really inconvenient time - just abandon in afs_vnode_new_inode()
1283 op->error = PTR_ERR(inode); in afs_vnode_new_inode()
1288 set_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags); in afs_vnode_new_inode()
1289 if (!op->error) in afs_vnode_new_inode()
1290 afs_cache_permit(vnode, op->key, vnode->cb_break, &vp->scb); in afs_vnode_new_inode()
1291 d_instantiate(op->dentry, inode); in afs_vnode_new_inode()
1296 _enter("op=%08x", op->debug_id); in afs_create_success()
1297 op->ctime = op->file[0].scb.status.mtime_client; in afs_create_success()
1298 afs_vnode_commit_status(op, &op->file[0]); in afs_create_success()
1299 afs_update_dentry_version(op, &op->file[0], op->dentry); in afs_create_success()
1305 struct afs_vnode_param *dvp = &op->file[0]; in afs_create_edit_dir()
1306 struct afs_vnode_param *vp = &op->file[1]; in afs_create_edit_dir()
1307 struct afs_vnode *dvnode = dvp->vnode; in afs_create_edit_dir()
1309 _enter("op=%08x", op->debug_id); in afs_create_edit_dir()
1311 down_write(&dvnode->validate_lock); in afs_create_edit_dir()
1312 if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && in afs_create_edit_dir()
1313 dvnode->status.data_version == dvp->dv_before + dvp->dv_delta) in afs_create_edit_dir()
1314 afs_edit_dir_add(dvnode, &op->dentry->d_name, &vp->fid, in afs_create_edit_dir()
1315 op->create.reason); in afs_create_edit_dir()
1316 up_write(&dvnode->validate_lock); in afs_create_edit_dir()
1321 _enter("op=%08x", op->debug_id); in afs_create_put()
1323 if (op->error) in afs_create_put()
1324 d_drop(op->dentry); in afs_create_put()
1346 dvnode->fid.vid, dvnode->fid.vnode, dentry, mode); in afs_mkdir()
1348 op = afs_alloc_operation(NULL, dvnode->volume); in afs_mkdir()
1355 op->file[0].dv_delta = 1; in afs_mkdir()
1356 op->file[0].modification = true; in afs_mkdir()
1357 op->file[0].update_ctime = true; in afs_mkdir()
1358 op->dentry = dentry; in afs_mkdir()
1359 op->create.mode = S_IFDIR | mode; in afs_mkdir()
1360 op->create.reason = afs_edit_dir_for_mkdir; in afs_mkdir()
1361 op->mtime = current_time(dir); in afs_mkdir()
1362 op->ops = &afs_mkdir_operation; in afs_mkdir()
1374 clear_nlink(&vnode->netfs.inode); in afs_dir_remove_subdir()
1375 set_bit(AFS_VNODE_DELETED, &vnode->flags); in afs_dir_remove_subdir()
1376 clear_bit(AFS_VNODE_CB_PROMISED, &vnode->flags); in afs_dir_remove_subdir()
1377 clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); in afs_dir_remove_subdir()
1383 _enter("op=%08x", op->debug_id); in afs_rmdir_success()
1384 op->ctime = op->file[0].scb.status.mtime_client; in afs_rmdir_success()
1385 afs_vnode_commit_status(op, &op->file[0]); in afs_rmdir_success()
1386 afs_update_dentry_version(op, &op->file[0], op->dentry); in afs_rmdir_success()
1391 struct afs_vnode_param *dvp = &op->file[0]; in afs_rmdir_edit_dir()
1392 struct afs_vnode *dvnode = dvp->vnode; in afs_rmdir_edit_dir()
1394 _enter("op=%08x", op->debug_id); in afs_rmdir_edit_dir()
1395 afs_dir_remove_subdir(op->dentry); in afs_rmdir_edit_dir()
1397 down_write(&dvnode->validate_lock); in afs_rmdir_edit_dir()
1398 if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && in afs_rmdir_edit_dir()
1399 dvnode->status.data_version == dvp->dv_before + dvp->dv_delta) in afs_rmdir_edit_dir()
1400 afs_edit_dir_remove(dvnode, &op->dentry->d_name, in afs_rmdir_edit_dir()
1402 up_write(&dvnode->validate_lock); in afs_rmdir_edit_dir()
1407 _enter("op=%08x", op->debug_id); in afs_rmdir_put()
1408 if (op->file[1].vnode) in afs_rmdir_put()
1409 up_write(&op->file[1].vnode->rmdir_lock); in afs_rmdir_put()
1431 dvnode->fid.vid, dvnode->fid.vnode, dentry); in afs_rmdir()
1433 op = afs_alloc_operation(NULL, dvnode->volume); in afs_rmdir()
1438 op->file[0].dv_delta = 1; in afs_rmdir()
1439 op->file[0].modification = true; in afs_rmdir()
1440 op->file[0].update_ctime = true; in afs_rmdir()
1442 op->dentry = dentry; in afs_rmdir()
1443 op->ops = &afs_rmdir_operation; in afs_rmdir()
1448 ret = afs_validate(vnode, op->key); in afs_rmdir()
1454 ret = down_write_killable(&vnode->rmdir_lock); in afs_rmdir()
1457 op->file[1].vnode = vnode; in afs_rmdir()
1470 * break the callback promise on the file - if it had one - before it returns
1471 * to us, and if it was deleted, it won't
1478 struct afs_vnode *dvnode = op->file[0].vnode; in afs_dir_remove_link()
1479 struct afs_vnode *vnode = op->file[1].vnode; in afs_dir_remove_link()
1480 struct dentry *dentry = op->dentry; in afs_dir_remove_link()
1483 if (op->error != 0 || in afs_dir_remove_link()
1484 (op->file[1].scb.have_status && op->file[1].scb.have_error)) in afs_dir_remove_link()
1489 if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) { in afs_dir_remove_link()
1491 } else if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) { in afs_dir_remove_link()
1492 write_seqlock(&vnode->cb_lock); in afs_dir_remove_link()
1493 drop_nlink(&vnode->netfs.inode); in afs_dir_remove_link()
1494 if (vnode->netfs.inode.i_nlink == 0) { in afs_dir_remove_link()
1495 set_bit(AFS_VNODE_DELETED, &vnode->flags); in afs_dir_remove_link()
1498 write_sequnlock(&vnode->cb_lock); in afs_dir_remove_link()
1502 if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) in afs_dir_remove_link()
1505 ret = afs_validate(vnode, op->key); in afs_dir_remove_link()
1506 if (ret != -ESTALE) in afs_dir_remove_link()
1507 op->error = ret; in afs_dir_remove_link()
1510 _debug("nlink %d [val %d]", vnode->netfs.inode.i_nlink, op->error); in afs_dir_remove_link()
1515 _enter("op=%08x", op->debug_id); in afs_unlink_success()
1516 op->ctime = op->file[0].scb.status.mtime_client; in afs_unlink_success()
1517 afs_check_dir_conflict(op, &op->file[0]); in afs_unlink_success()
1518 afs_vnode_commit_status(op, &op->file[0]); in afs_unlink_success()
1519 afs_vnode_commit_status(op, &op->file[1]); in afs_unlink_success()
1520 afs_update_dentry_version(op, &op->file[0], op->dentry); in afs_unlink_success()
1526 struct afs_vnode_param *dvp = &op->file[0]; in afs_unlink_edit_dir()
1527 struct afs_vnode *dvnode = dvp->vnode; in afs_unlink_edit_dir()
1529 _enter("op=%08x", op->debug_id); in afs_unlink_edit_dir()
1530 down_write(&dvnode->validate_lock); in afs_unlink_edit_dir()
1531 if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && in afs_unlink_edit_dir()
1532 dvnode->status.data_version == dvp->dv_before + dvp->dv_delta) in afs_unlink_edit_dir()
1533 afs_edit_dir_remove(dvnode, &op->dentry->d_name, in afs_unlink_edit_dir()
1535 up_write(&dvnode->validate_lock); in afs_unlink_edit_dir()
1540 _enter("op=%08x", op->debug_id); in afs_unlink_put()
1541 if (op->unlink.need_rehash && op->error < 0 && op->error != -ENOENT) in afs_unlink_put()
1542 d_rehash(op->dentry); in afs_unlink_put()
1565 dvnode->fid.vid, dvnode->fid.vnode, dentry); in afs_unlink()
1567 if (dentry->d_name.len >= AFSNAMEMAX) in afs_unlink()
1568 return -ENAMETOOLONG; in afs_unlink()
1570 op = afs_alloc_operation(NULL, dvnode->volume); in afs_unlink()
1575 op->file[0].dv_delta = 1; in afs_unlink()
1576 op->file[0].modification = true; in afs_unlink()
1577 op->file[0].update_ctime = true; in afs_unlink()
1580 ret = afs_validate(vnode, op->key); in afs_unlink()
1582 op->error = ret; in afs_unlink()
1586 spin_lock(&dentry->d_lock); in afs_unlink()
1588 spin_unlock(&dentry->d_lock); in afs_unlink()
1591 op->error = afs_sillyrename(dvnode, vnode, dentry, op->key); in afs_unlink()
1597 op->unlink.need_rehash = true; in afs_unlink()
1599 spin_unlock(&dentry->d_lock); in afs_unlink()
1601 op->file[1].vnode = vnode; in afs_unlink()
1602 op->file[1].update_ctime = true; in afs_unlink()
1603 op->file[1].op_unlinked = true; in afs_unlink()
1604 op->dentry = dentry; in afs_unlink()
1605 op->ops = &afs_unlink_operation; in afs_unlink()
1612 if (op->error == 0 && (op->flags & AFS_OPERATION_DIR_CONFLICT)) { in afs_unlink()
1613 op->file[1].update_ctime = false; in afs_unlink()
1614 op->fetch_status.which = 1; in afs_unlink()
1615 op->ops = &afs_fetch_status_operation; in afs_unlink()
1643 int ret = -ENAMETOOLONG; in afs_create()
1646 dvnode->fid.vid, dvnode->fid.vnode, dentry, mode); in afs_create()
1648 if (dentry->d_name.len >= AFSNAMEMAX) in afs_create()
1651 op = afs_alloc_operation(NULL, dvnode->volume); in afs_create()
1658 op->file[0].dv_delta = 1; in afs_create()
1659 op->file[0].modification = true; in afs_create()
1660 op->file[0].update_ctime = true; in afs_create()
1662 op->dentry = dentry; in afs_create()
1663 op->create.mode = S_IFREG | mode; in afs_create()
1664 op->create.reason = afs_edit_dir_for_create; in afs_create()
1665 op->mtime = current_time(dir); in afs_create()
1666 op->ops = &afs_create_operation; in afs_create()
1677 struct afs_vnode_param *dvp = &op->file[0]; in afs_link_success()
1678 struct afs_vnode_param *vp = &op->file[1]; in afs_link_success()
1680 _enter("op=%08x", op->debug_id); in afs_link_success()
1681 op->ctime = dvp->scb.status.mtime_client; in afs_link_success()
1684 afs_update_dentry_version(op, dvp, op->dentry); in afs_link_success()
1685 if (op->dentry_2->d_parent == op->dentry->d_parent) in afs_link_success()
1686 afs_update_dentry_version(op, dvp, op->dentry_2); in afs_link_success()
1687 ihold(&vp->vnode->netfs.inode); in afs_link_success()
1688 d_instantiate(op->dentry, &vp->vnode->netfs.inode); in afs_link_success()
1693 _enter("op=%08x", op->debug_id); in afs_link_put()
1694 if (op->error) in afs_link_put()
1695 d_drop(op->dentry); in afs_link_put()
1716 int ret = -ENAMETOOLONG; in afs_link()
1719 vnode->fid.vid, vnode->fid.vnode, in afs_link()
1720 dvnode->fid.vid, dvnode->fid.vnode, in afs_link()
1723 if (dentry->d_name.len >= AFSNAMEMAX) in afs_link()
1726 op = afs_alloc_operation(NULL, dvnode->volume); in afs_link()
1732 ret = afs_validate(vnode, op->key); in afs_link()
1738 op->file[0].dv_delta = 1; in afs_link()
1739 op->file[0].modification = true; in afs_link()
1740 op->file[0].update_ctime = true; in afs_link()
1741 op->file[1].update_ctime = true; in afs_link()
1743 op->dentry = dentry; in afs_link()
1744 op->dentry_2 = from; in afs_link()
1745 op->ops = &afs_link_operation; in afs_link()
1746 op->create.reason = afs_edit_dir_for_link; in afs_link()
1777 dvnode->fid.vid, dvnode->fid.vnode, dentry, in afs_symlink()
1780 ret = -ENAMETOOLONG; in afs_symlink()
1781 if (dentry->d_name.len >= AFSNAMEMAX) in afs_symlink()
1784 ret = -EINVAL; in afs_symlink()
1788 op = afs_alloc_operation(NULL, dvnode->volume); in afs_symlink()
1795 op->file[0].dv_delta = 1; in afs_symlink()
1797 op->dentry = dentry; in afs_symlink()
1798 op->ops = &afs_symlink_operation; in afs_symlink()
1799 op->create.reason = afs_edit_dir_for_symlink; in afs_symlink()
1800 op->create.symlink = content; in afs_symlink()
1801 op->mtime = current_time(dir); in afs_symlink()
1812 _enter("op=%08x", op->debug_id); in afs_rename_success()
1814 op->ctime = op->file[0].scb.status.mtime_client; in afs_rename_success()
1815 afs_check_dir_conflict(op, &op->file[1]); in afs_rename_success()
1816 afs_vnode_commit_status(op, &op->file[0]); in afs_rename_success()
1817 if (op->file[1].vnode != op->file[0].vnode) { in afs_rename_success()
1818 op->ctime = op->file[1].scb.status.mtime_client; in afs_rename_success()
1819 afs_vnode_commit_status(op, &op->file[1]); in afs_rename_success()
1825 struct afs_vnode_param *orig_dvp = &op->file[0]; in afs_rename_edit_dir()
1826 struct afs_vnode_param *new_dvp = &op->file[1]; in afs_rename_edit_dir()
1827 struct afs_vnode *orig_dvnode = orig_dvp->vnode; in afs_rename_edit_dir()
1828 struct afs_vnode *new_dvnode = new_dvp->vnode; in afs_rename_edit_dir()
1829 struct afs_vnode *vnode = AFS_FS_I(d_inode(op->dentry)); in afs_rename_edit_dir()
1830 struct dentry *old_dentry = op->dentry; in afs_rename_edit_dir()
1831 struct dentry *new_dentry = op->dentry_2; in afs_rename_edit_dir()
1834 _enter("op=%08x", op->debug_id); in afs_rename_edit_dir()
1836 if (op->rename.rehash) { in afs_rename_edit_dir()
1837 d_rehash(op->rename.rehash); in afs_rename_edit_dir()
1838 op->rename.rehash = NULL; in afs_rename_edit_dir()
1841 down_write(&orig_dvnode->validate_lock); in afs_rename_edit_dir()
1842 if (test_bit(AFS_VNODE_DIR_VALID, &orig_dvnode->flags) && in afs_rename_edit_dir()
1843 orig_dvnode->status.data_version == orig_dvp->dv_before + orig_dvp->dv_delta) in afs_rename_edit_dir()
1844 afs_edit_dir_remove(orig_dvnode, &old_dentry->d_name, in afs_rename_edit_dir()
1848 up_write(&orig_dvnode->validate_lock); in afs_rename_edit_dir()
1849 down_write(&new_dvnode->validate_lock); in afs_rename_edit_dir()
1852 if (test_bit(AFS_VNODE_DIR_VALID, &new_dvnode->flags) && in afs_rename_edit_dir()
1853 new_dvnode->status.data_version == new_dvp->dv_before + new_dvp->dv_delta) { in afs_rename_edit_dir()
1854 if (!op->rename.new_negative) in afs_rename_edit_dir()
1855 afs_edit_dir_remove(new_dvnode, &new_dentry->d_name, in afs_rename_edit_dir()
1858 afs_edit_dir_add(new_dvnode, &new_dentry->d_name, in afs_rename_edit_dir()
1859 &vnode->fid, afs_edit_dir_for_rename_2); in afs_rename_edit_dir()
1864 spin_lock(&new_inode->i_lock); in afs_rename_edit_dir()
1865 if (S_ISDIR(new_inode->i_mode)) in afs_rename_edit_dir()
1867 else if (new_inode->i_nlink > 0) in afs_rename_edit_dir()
1869 spin_unlock(&new_inode->i_lock); in afs_rename_edit_dir()
1878 afs_update_dentry_version(op, new_dvp, op->dentry); in afs_rename_edit_dir()
1879 afs_update_dentry_version(op, new_dvp, op->dentry_2); in afs_rename_edit_dir()
1883 up_write(&new_dvnode->validate_lock); in afs_rename_edit_dir()
1888 _enter("op=%08x", op->debug_id); in afs_rename_put()
1889 if (op->rename.rehash) in afs_rename_put()
1890 d_rehash(op->rename.rehash); in afs_rename_put()
1891 dput(op->rename.tmp); in afs_rename_put()
1892 if (op->error) in afs_rename_put()
1893 d_rehash(op->dentry); in afs_rename_put()
1916 return -EINVAL; in afs_rename()
1918 /* Don't allow silly-rename files be moved around. */ in afs_rename()
1919 if (old_dentry->d_flags & DCACHE_NFSFS_RENAMED) in afs_rename()
1920 return -EINVAL; in afs_rename()
1927 orig_dvnode->fid.vid, orig_dvnode->fid.vnode, in afs_rename()
1928 vnode->fid.vid, vnode->fid.vnode, in afs_rename()
1929 new_dvnode->fid.vid, new_dvnode->fid.vnode, in afs_rename()
1932 op = afs_alloc_operation(NULL, orig_dvnode->volume); in afs_rename()
1936 ret = afs_validate(vnode, op->key); in afs_rename()
1937 op->error = ret; in afs_rename()
1943 op->file[0].dv_delta = 1; in afs_rename()
1944 op->file[1].dv_delta = 1; in afs_rename()
1945 op->file[0].modification = true; in afs_rename()
1946 op->file[1].modification = true; in afs_rename()
1947 op->file[0].update_ctime = true; in afs_rename()
1948 op->file[1].update_ctime = true; in afs_rename()
1950 op->dentry = old_dentry; in afs_rename()
1951 op->dentry_2 = new_dentry; in afs_rename()
1952 op->rename.new_negative = d_is_negative(new_dentry); in afs_rename()
1953 op->ops = &afs_rename_operation; in afs_rename()
1955 /* For non-directories, check whether the target is busy and if so, in afs_rename()
1956 * make a copy of the dentry and then do a silly-rename. If the in afs_rename()
1957 * silly-rename succeeds, the copied dentry is hashed and becomes the in afs_rename()
1966 op->rename.rehash = new_dentry; in afs_rename()
1971 op->rename.tmp = d_alloc(new_dentry->d_parent, in afs_rename()
1972 &new_dentry->d_name); in afs_rename()
1973 if (!op->rename.tmp) { in afs_rename()
1974 op->error = -ENOMEM; in afs_rename()
1980 new_dentry, op->key); in afs_rename()
1982 op->error = ret; in afs_rename()
1986 op->dentry_2 = op->rename.tmp; in afs_rename()
1987 op->rename.rehash = NULL; in afs_rename()
1988 op->rename.new_negative = true; in afs_rename()
1999 * lookup instead - which we hold a lock against. in afs_rename()
2011 * - return true if the folio can now be released, false if not
2017 _enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, folio_index(folio)); in afs_dir_release_folio()
2022 if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) in afs_dir_release_folio()
2035 _enter("{%lu},%zu,%zu", folio->index, offset, length); in afs_dir_invalidate_folio()
2040 if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) in afs_dir_invalidate_folio()