Skip to content

Commit 92c4815

Browse files
committed
afs: Make afs_lookup_cell() take a trace note
Pass a note to be added to the afs_cell tracepoint to afs_lookup_cell() so that different callers can be distinguished. Signed-off-by: David Howells <dhowells@redhat.com> cc: Marc Dionne <marc.dionne@auristor.com> cc: linux-afs@lists.infradead.org cc: linux-fsdevel@vger.kernel.org Link: https://lore.kernel.org/r/20250224234154.2014840-11-dhowells@redhat.com/ # v1 Link: https://lore.kernel.org/r/20250310094206.801057-7-dhowells@redhat.com/ # v4
1 parent 76daa30 commit 92c4815

8 files changed

Lines changed: 28 additions & 13 deletions

File tree

fs/afs/cell.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net,
233233
* @namesz: The strlen of the cell name.
234234
* @vllist: A colon/comma separated list of numeric IP addresses or NULL.
235235
* @excl: T if an error should be given if the cell name already exists.
236+
* @trace: The reason to be logged if the lookup is successful.
236237
*
237238
* Look up a cell record by name and query the DNS for VL server addresses if
238239
* needed. Note that that actual DNS query is punted off to the manager thread
@@ -241,7 +242,8 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net,
241242
*/
242243
struct afs_cell *afs_lookup_cell(struct afs_net *net,
243244
const char *name, unsigned int namesz,
244-
const char *vllist, bool excl)
245+
const char *vllist, bool excl,
246+
enum afs_cell_trace trace)
245247
{
246248
struct afs_cell *cell, *candidate, *cursor;
247249
struct rb_node *parent, **pp;
@@ -251,7 +253,7 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,
251253
_enter("%s,%s", name, vllist);
252254

253255
if (!excl) {
254-
cell = afs_find_cell(net, name, namesz, afs_cell_trace_use_lookup);
256+
cell = afs_find_cell(net, name, namesz, trace);
255257
if (!IS_ERR(cell))
256258
goto wait_for_cell;
257259
}
@@ -327,7 +329,7 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,
327329
if (excl) {
328330
ret = -EEXIST;
329331
} else {
330-
afs_use_cell(cursor, afs_cell_trace_use_lookup);
332+
afs_use_cell(cursor, trace);
331333
ret = 0;
332334
}
333335
up_write(&net->cells_lock);
@@ -382,8 +384,9 @@ int afs_cell_init(struct afs_net *net, const char *rootcell)
382384
if (cp && cp < rootcell + len)
383385
return -EINVAL;
384386

385-
/* allocate a cell record for the root cell */
386-
new_root = afs_lookup_cell(net, rootcell, len, vllist, false);
387+
/* allocate a cell record for the root/workstation cell */
388+
new_root = afs_lookup_cell(net, rootcell, len, vllist, false,
389+
afs_cell_trace_use_lookup_ws);
387390
if (IS_ERR(new_root)) {
388391
_leave(" = %ld", PTR_ERR(new_root));
389392
return PTR_ERR(new_root);

fs/afs/dynroot.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ static struct dentry *afs_dynroot_lookup_cell(struct inode *dir, struct dentry *
108108
dotted = true;
109109
}
110110

111-
cell = afs_lookup_cell(net, name, len, NULL, false);
111+
cell = afs_lookup_cell(net, name, len, NULL, false,
112+
afs_cell_trace_use_lookup_dynroot);
112113
if (IS_ERR(cell)) {
113114
ret = PTR_ERR(cell);
114115
goto out_no_cell;

fs/afs/internal.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,8 +1046,10 @@ static inline bool afs_cb_is_broken(unsigned int cb_break,
10461046
extern int afs_cell_init(struct afs_net *, const char *);
10471047
extern struct afs_cell *afs_find_cell(struct afs_net *, const char *, unsigned,
10481048
enum afs_cell_trace);
1049-
extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned,
1050-
const char *, bool);
1049+
struct afs_cell *afs_lookup_cell(struct afs_net *net,
1050+
const char *name, unsigned int namesz,
1051+
const char *vllist, bool excl,
1052+
enum afs_cell_trace trace);
10511053
extern struct afs_cell *afs_use_cell(struct afs_cell *, enum afs_cell_trace);
10521054
extern void afs_unuse_cell(struct afs_net *, struct afs_cell *, enum afs_cell_trace);
10531055
extern struct afs_cell *afs_get_cell(struct afs_cell *, enum afs_cell_trace);

fs/afs/mntpt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt)
107107
if (size > AFS_MAXCELLNAME)
108108
return -ENAMETOOLONG;
109109

110-
cell = afs_lookup_cell(ctx->net, p, size, NULL, false);
110+
cell = afs_lookup_cell(ctx->net, p, size, NULL, false,
111+
afs_cell_trace_use_lookup_mntpt);
111112
if (IS_ERR(cell)) {
112113
pr_err("kAFS: unable to lookup cell '%pd'\n", mntpt);
113114
return PTR_ERR(cell);

fs/afs/proc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ static int afs_proc_cells_write(struct file *file, char *buf, size_t size)
122122
if (strcmp(buf, "add") == 0) {
123123
struct afs_cell *cell;
124124

125-
cell = afs_lookup_cell(net, name, strlen(name), args, true);
125+
cell = afs_lookup_cell(net, name, strlen(name), args, true,
126+
afs_cell_trace_use_lookup_add);
126127
if (IS_ERR(cell)) {
127128
ret = PTR_ERR(cell);
128129
goto done;

fs/afs/super.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ static int afs_parse_source(struct fs_context *fc, struct fs_parameter *param)
290290
/* lookup the cell record */
291291
if (cellname) {
292292
cell = afs_lookup_cell(ctx->net, cellname, cellnamesz,
293-
NULL, false);
293+
NULL, false,
294+
afs_cell_trace_use_lookup_mount);
294295
if (IS_ERR(cell)) {
295296
pr_err("kAFS: unable to lookup cell '%*.*s'\n",
296297
cellnamesz, cellnamesz, cellname ?: "");

fs/afs/vl_alias.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ static int yfs_check_canonical_cell_name(struct afs_cell *cell, struct key *key)
269269
if (!name_len || name_len > AFS_MAXCELLNAME)
270270
master = ERR_PTR(-EOPNOTSUPP);
271271
else
272-
master = afs_lookup_cell(cell->net, cell_name, name_len, NULL, false);
272+
master = afs_lookup_cell(cell->net, cell_name, name_len, NULL, false,
273+
afs_cell_trace_use_lookup_canonical);
273274
kfree(cell_name);
274275
if (IS_ERR(master))
275276
return PTR_ERR(master);

include/trace/events/afs.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,12 @@ enum yfs_cm_operation {
208208
EM(afs_cell_trace_use_check_alias, "USE chk-al") \
209209
EM(afs_cell_trace_use_fc, "USE fc ") \
210210
EM(afs_cell_trace_use_fc_alias, "USE fc-al ") \
211-
EM(afs_cell_trace_use_lookup, "USE lookup") \
211+
EM(afs_cell_trace_use_lookup_add, "USE lu-add") \
212+
EM(afs_cell_trace_use_lookup_canonical, "USE lu-can") \
213+
EM(afs_cell_trace_use_lookup_dynroot, "USE lu-dyn") \
214+
EM(afs_cell_trace_use_lookup_mntpt, "USE lu-mpt") \
215+
EM(afs_cell_trace_use_lookup_mount, "USE lu-mnt") \
216+
EM(afs_cell_trace_use_lookup_ws, "USE lu-ws ") \
212217
EM(afs_cell_trace_use_mntpt, "USE mntpt ") \
213218
EM(afs_cell_trace_use_pin, "USE pin ") \
214219
EM(afs_cell_trace_use_probe, "USE probe ") \

0 commit comments

Comments
 (0)