Lines Matching +full:1 +full:- +full:cell
1 // SPDX-License-Identifier: GPL-2.0-or-later
30 struct afs_super_info *as = AFS_FS_S(inode->i_sb); in afs_iget5_pseudo_set()
34 vnode->volume = as->volume; in afs_iget5_pseudo_set()
35 vnode->fid = *fid; in afs_iget5_pseudo_set()
36 inode->i_ino = fid->vnode; in afs_iget5_pseudo_set()
37 inode->i_generation = fid->unique; in afs_iget5_pseudo_set()
54 if (as->volume) in afs_iget_pseudo_dir()
55 fid.vid = as->volume->vid; in afs_iget_pseudo_dir()
57 fid.vnode = 1; in afs_iget_pseudo_dir()
58 fid.unique = 1; in afs_iget_pseudo_dir()
67 _leave(" = -ENOMEM"); in afs_iget_pseudo_dir()
68 return ERR_PTR(-ENOMEM); in afs_iget_pseudo_dir()
72 inode, inode->i_ino, fid.vid, fid.vnode, fid.unique); in afs_iget_pseudo_dir()
77 BUG_ON(!(inode->i_state & I_NEW)); in afs_iget_pseudo_dir()
79 netfs_inode_init(&vnode->netfs, NULL, false); in afs_iget_pseudo_dir()
80 inode->i_size = 0; in afs_iget_pseudo_dir()
81 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; in afs_iget_pseudo_dir()
83 inode->i_op = &afs_dynroot_inode_operations; in afs_iget_pseudo_dir()
84 inode->i_fop = &simple_dir_operations; in afs_iget_pseudo_dir()
86 inode->i_op = &afs_autocell_inode_operations; in afs_iget_pseudo_dir()
89 inode->i_uid = GLOBAL_ROOT_UID; in afs_iget_pseudo_dir()
90 inode->i_gid = GLOBAL_ROOT_GID; in afs_iget_pseudo_dir()
92 inode->i_blocks = 0; in afs_iget_pseudo_dir()
93 inode->i_generation = 0; in afs_iget_pseudo_dir()
95 set_bit(AFS_VNODE_PSEUDODIR, &vnode->flags); in afs_iget_pseudo_dir()
97 set_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags); in afs_iget_pseudo_dir()
98 inode->i_flags |= S_AUTOMOUNT; in afs_iget_pseudo_dir()
101 inode->i_flags |= S_NOATIME; in afs_iget_pseudo_dir()
108 * Probe to see if a cell may exist. This prevents positive dentries from
113 struct afs_cell *cell; in afs_probe_cell_name() local
115 const char *name = dentry->d_name.name; in afs_probe_cell_name()
116 size_t len = dentry->d_name.len; in afs_probe_cell_name()
122 if (len == 1) in afs_probe_cell_name()
123 return -EINVAL; in afs_probe_cell_name()
125 len--; in afs_probe_cell_name()
128 cell = afs_find_cell(net, name, len, afs_cell_trace_use_probe); in afs_probe_cell_name()
129 if (!IS_ERR(cell)) { in afs_probe_cell_name()
130 afs_unuse_cell(net, cell, afs_cell_trace_unuse_probe); in afs_probe_cell_name()
134 ret = dns_query(net->net, "afsdb", name, len, "srv=1", in afs_probe_cell_name()
136 if (ret == -ENODATA || ret == -ENOKEY || ret == 0) in afs_probe_cell_name()
137 ret = -ENOENT; in afs_probe_cell_name()
141 if (v1->hdr.zero == 0 && in afs_probe_cell_name()
142 v1->hdr.content == DNS_PAYLOAD_IS_SERVER_LIST && in afs_probe_cell_name()
143 v1->hdr.version == 1 && in afs_probe_cell_name()
144 (v1->status != DNS_LOOKUP_GOOD && in afs_probe_cell_name()
145 v1->status != DNS_LOOKUP_GOOD_WITH_BAD)) in afs_probe_cell_name()
146 return -ENOENT; in afs_probe_cell_name()
162 int ret = -ENOENT; in afs_try_auto_mntpt()
165 dentry, dentry, vnode->fid.vid, vnode->fid.vnode); in afs_try_auto_mntpt()
167 if (!test_bit(AFS_VNODE_AUTOCELL, &vnode->flags)) in afs_try_auto_mntpt()
174 inode = afs_iget_pseudo_dir(dir->i_sb, false); in afs_try_auto_mntpt()
185 return ret == -ENOENT ? NULL : ERR_PTR(ret); in afs_try_auto_mntpt()
189 * Look up @cell in a dynroot directory. This is a substitution for the
190 * local cell name for the net namespace.
194 struct afs_cell *cell; in afs_lookup_atcell() local
200 if (!net->ws_cell) in afs_lookup_atcell()
201 return ERR_PTR(-ENOENT); in afs_lookup_atcell()
203 ret = ERR_PTR(-ENOMEM); in afs_lookup_atcell()
204 name = kmalloc(AFS_MAXCELLNAME + 1, GFP_KERNEL); in afs_lookup_atcell()
208 down_read(&net->cells_lock); in afs_lookup_atcell()
209 cell = net->ws_cell; in afs_lookup_atcell()
210 if (cell) { in afs_lookup_atcell()
211 len = cell->name_len; in afs_lookup_atcell()
212 memcpy(name, cell->name, len + 1); in afs_lookup_atcell()
214 up_read(&net->cells_lock); in afs_lookup_atcell()
216 ret = ERR_PTR(-ENOENT); in afs_lookup_atcell()
217 if (!cell) in afs_lookup_atcell()
220 ret = lookup_one_len(name, dentry->d_parent, len); in afs_lookup_atcell()
222 /* We don't want to d_add() the @cell dentry here as we don't want to in afs_lookup_atcell()
223 * the cached dentry to hide changes to the local cell name. in afs_lookup_atcell()
243 return ERR_PTR(-EOPNOTSUPP); in afs_dynroot_lookup()
245 if (dentry->d_name.len >= AFSNAMEMAX) { in afs_dynroot_lookup()
246 _leave(" = -ENAMETOOLONG"); in afs_dynroot_lookup()
247 return ERR_PTR(-ENAMETOOLONG); in afs_dynroot_lookup()
250 if (dentry->d_name.len == 5 && in afs_dynroot_lookup()
251 memcmp(dentry->d_name.name, "@cell", 5) == 0) in afs_dynroot_lookup()
268 * Create a manually added cell mount directory.
269 * - The caller must hold net->proc_cells_lock
271 int afs_dynroot_mkdir(struct afs_net *net, struct afs_cell *cell) in afs_dynroot_mkdir() argument
273 struct super_block *sb = net->dynroot_sb; in afs_dynroot_mkdir()
277 if (!sb || atomic_read(&sb->s_active) == 0) in afs_dynroot_mkdir()
280 /* Let the ->lookup op do the creation */ in afs_dynroot_mkdir()
281 root = sb->s_root; in afs_dynroot_mkdir()
282 inode_lock(root->d_inode); in afs_dynroot_mkdir()
283 subdir = lookup_one_len(cell->name, root, cell->name_len); in afs_dynroot_mkdir()
290 subdir->d_fsdata = (void *)1UL; in afs_dynroot_mkdir()
293 inode_unlock(root->d_inode); in afs_dynroot_mkdir()
298 * Remove a manually added cell mount directory.
299 * - The caller must hold net->proc_cells_lock
301 void afs_dynroot_rmdir(struct afs_net *net, struct afs_cell *cell) in afs_dynroot_rmdir() argument
303 struct super_block *sb = net->dynroot_sb; in afs_dynroot_rmdir()
306 if (!sb || atomic_read(&sb->s_active) == 0) in afs_dynroot_rmdir()
309 root = sb->s_root; in afs_dynroot_rmdir()
310 inode_lock(root->d_inode); in afs_dynroot_rmdir()
312 /* Don't want to trigger a lookup call, which will re-add the cell */ in afs_dynroot_rmdir()
313 subdir = try_lookup_one_len(cell->name, root, cell->name_len); in afs_dynroot_rmdir()
321 if (subdir->d_fsdata) { in afs_dynroot_rmdir()
323 subdir->d_fsdata = NULL; in afs_dynroot_rmdir()
328 inode_unlock(root->d_inode); in afs_dynroot_rmdir()
333 * Populate a newly created dynamic root with cell names.
337 struct afs_cell *cell; in afs_dynroot_populate() local
341 mutex_lock(&net->proc_cells_lock); in afs_dynroot_populate()
343 net->dynroot_sb = sb; in afs_dynroot_populate()
344 hlist_for_each_entry(cell, &net->proc_cells, proc_link) { in afs_dynroot_populate()
345 ret = afs_dynroot_mkdir(net, cell); in afs_dynroot_populate()
352 mutex_unlock(&net->proc_cells_lock); in afs_dynroot_populate()
356 net->dynroot_sb = NULL; in afs_dynroot_populate()
367 struct dentry *root = sb->s_root, *subdir; in afs_dynroot_depopulate()
370 mutex_lock(&net->proc_cells_lock); in afs_dynroot_depopulate()
371 if (net->dynroot_sb == sb) in afs_dynroot_depopulate()
372 net->dynroot_sb = NULL; in afs_dynroot_depopulate()
373 mutex_unlock(&net->proc_cells_lock); in afs_dynroot_depopulate()
377 inode_lock(root->d_inode); in afs_dynroot_depopulate()
380 hlist_for_each_entry_safe(subdir, n, &root->d_children, d_sib) { in afs_dynroot_depopulate()
381 if (subdir->d_fsdata) { in afs_dynroot_depopulate()
382 subdir->d_fsdata = NULL; in afs_dynroot_depopulate()
387 inode_unlock(root->d_inode); in afs_dynroot_depopulate()