Skip to content

Commit 39e1be6

Browse files
neilbrownchucklever
authored andcommitted
nfsd: allow state with no file to appear in /proc/fs/nfsd/clients/*/states
Change the "show" functions to show some content even if a file cannot be found. This is the case for admin-revoked state. This is primarily useful for debugging - to ensure states are being removed eventually. So change several seq_printf() to seq_puts(). Some of these are needed to keep checkpatch happy. Others were done for consistency. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 1ac3629 commit 39e1be6

1 file changed

Lines changed: 58 additions & 60 deletions

File tree

fs/nfsd/nfs4state.c

Lines changed: 58 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,9 +2554,9 @@ static struct nfs4_client *get_nfsdfs_clp(struct inode *inode)
25542554

25552555
static void seq_quote_mem(struct seq_file *m, char *data, int len)
25562556
{
2557-
seq_printf(m, "\"");
2557+
seq_puts(m, "\"");
25582558
seq_escape_mem(m, data, len, ESCAPE_HEX | ESCAPE_NAP | ESCAPE_APPEND, "\"\\");
2559-
seq_printf(m, "\"");
2559+
seq_puts(m, "\"");
25602560
}
25612561

25622562
static const char *cb_state2str(int state)
@@ -2597,14 +2597,14 @@ static int client_info_show(struct seq_file *m, void *v)
25972597
seq_puts(m, "status: unconfirmed\n");
25982598
seq_printf(m, "seconds from last renew: %lld\n",
25992599
ktime_get_boottime_seconds() - clp->cl_time);
2600-
seq_printf(m, "name: ");
2600+
seq_puts(m, "name: ");
26012601
seq_quote_mem(m, clp->cl_name.data, clp->cl_name.len);
26022602
seq_printf(m, "\nminor version: %d\n", clp->cl_minorversion);
26032603
if (clp->cl_nii_domain.data) {
2604-
seq_printf(m, "Implementation domain: ");
2604+
seq_puts(m, "Implementation domain: ");
26052605
seq_quote_mem(m, clp->cl_nii_domain.data,
26062606
clp->cl_nii_domain.len);
2607-
seq_printf(m, "\nImplementation name: ");
2607+
seq_puts(m, "\nImplementation name: ");
26082608
seq_quote_mem(m, clp->cl_nii_name.data, clp->cl_nii_name.len);
26092609
seq_printf(m, "\nImplementation time: [%lld, %ld]\n",
26102610
clp->cl_nii_time.tv_sec, clp->cl_nii_time.tv_nsec);
@@ -2671,7 +2671,7 @@ static void nfs4_show_superblock(struct seq_file *s, struct nfsd_file *f)
26712671

26722672
static void nfs4_show_owner(struct seq_file *s, struct nfs4_stateowner *oo)
26732673
{
2674-
seq_printf(s, "owner: ");
2674+
seq_puts(s, "owner: ");
26752675
seq_quote_mem(s, oo->so_owner.data, oo->so_owner.len);
26762676
}
26772677

@@ -2689,20 +2689,13 @@ static int nfs4_show_open(struct seq_file *s, struct nfs4_stid *st)
26892689
struct nfs4_stateowner *oo;
26902690
unsigned int access, deny;
26912691

2692-
if (st->sc_type != SC_TYPE_OPEN && st->sc_type != SC_TYPE_LOCK)
2693-
return 0; /* XXX: or SEQ_SKIP? */
26942692
ols = openlockstateid(st);
26952693
oo = ols->st_stateowner;
26962694
nf = st->sc_file;
26972695

2698-
spin_lock(&nf->fi_lock);
2699-
file = find_any_file_locked(nf);
2700-
if (!file)
2701-
goto out;
2702-
2703-
seq_printf(s, "- ");
2696+
seq_puts(s, "- ");
27042697
nfs4_show_stateid(s, &st->sc_stateid);
2705-
seq_printf(s, ": { type: open, ");
2698+
seq_puts(s, ": { type: open, ");
27062699

27072700
access = bmap_to_share_mode(ols->st_access_bmap);
27082701
deny = bmap_to_share_mode(ols->st_deny_bmap);
@@ -2714,14 +2707,17 @@ static int nfs4_show_open(struct seq_file *s, struct nfs4_stid *st)
27142707
deny & NFS4_SHARE_ACCESS_READ ? "r" : "-",
27152708
deny & NFS4_SHARE_ACCESS_WRITE ? "w" : "-");
27162709

2717-
nfs4_show_superblock(s, file);
2718-
seq_printf(s, ", ");
2719-
nfs4_show_fname(s, file);
2720-
seq_printf(s, ", ");
2721-
nfs4_show_owner(s, oo);
2722-
seq_printf(s, " }\n");
2723-
out:
2710+
spin_lock(&nf->fi_lock);
2711+
file = find_any_file_locked(nf);
2712+
if (file) {
2713+
nfs4_show_superblock(s, file);
2714+
seq_puts(s, ", ");
2715+
nfs4_show_fname(s, file);
2716+
seq_puts(s, ", ");
2717+
}
27242718
spin_unlock(&nf->fi_lock);
2719+
nfs4_show_owner(s, oo);
2720+
seq_puts(s, " }\n");
27252721
return 0;
27262722
}
27272723

@@ -2735,30 +2731,29 @@ static int nfs4_show_lock(struct seq_file *s, struct nfs4_stid *st)
27352731
ols = openlockstateid(st);
27362732
oo = ols->st_stateowner;
27372733
nf = st->sc_file;
2738-
spin_lock(&nf->fi_lock);
2739-
file = find_any_file_locked(nf);
2740-
if (!file)
2741-
goto out;
27422734

2743-
seq_printf(s, "- ");
2735+
seq_puts(s, "- ");
27442736
nfs4_show_stateid(s, &st->sc_stateid);
2745-
seq_printf(s, ": { type: lock, ");
2737+
seq_puts(s, ": { type: lock, ");
27462738

2747-
/*
2748-
* Note: a lock stateid isn't really the same thing as a lock,
2749-
* it's the locking state held by one owner on a file, and there
2750-
* may be multiple (or no) lock ranges associated with it.
2751-
* (Same for the matter is true of open stateids.)
2752-
*/
2739+
spin_lock(&nf->fi_lock);
2740+
file = find_any_file_locked(nf);
2741+
if (file) {
2742+
/*
2743+
* Note: a lock stateid isn't really the same thing as a lock,
2744+
* it's the locking state held by one owner on a file, and there
2745+
* may be multiple (or no) lock ranges associated with it.
2746+
* (Same for the matter is true of open stateids.)
2747+
*/
27532748

2754-
nfs4_show_superblock(s, file);
2755-
/* XXX: open stateid? */
2756-
seq_printf(s, ", ");
2757-
nfs4_show_fname(s, file);
2758-
seq_printf(s, ", ");
2749+
nfs4_show_superblock(s, file);
2750+
/* XXX: open stateid? */
2751+
seq_puts(s, ", ");
2752+
nfs4_show_fname(s, file);
2753+
seq_puts(s, ", ");
2754+
}
27592755
nfs4_show_owner(s, oo);
2760-
seq_printf(s, " }\n");
2761-
out:
2756+
seq_puts(s, " }\n");
27622757
spin_unlock(&nf->fi_lock);
27632758
return 0;
27642759
}
@@ -2771,25 +2766,25 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st)
27712766

27722767
ds = delegstateid(st);
27732768
nf = st->sc_file;
2774-
spin_lock(&nf->fi_lock);
2775-
file = nf->fi_deleg_file;
2776-
if (!file)
2777-
goto out;
27782769

2779-
seq_printf(s, "- ");
2770+
seq_puts(s, "- ");
27802771
nfs4_show_stateid(s, &st->sc_stateid);
2781-
seq_printf(s, ": { type: deleg, ");
2772+
seq_puts(s, ": { type: deleg, ");
27822773

2783-
seq_printf(s, "access: %s, ",
2784-
ds->dl_type == NFS4_OPEN_DELEGATE_READ ? "r" : "w");
2774+
seq_printf(s, "access: %s",
2775+
ds->dl_type == NFS4_OPEN_DELEGATE_READ ? "r" : "w");
27852776

27862777
/* XXX: lease time, whether it's being recalled. */
27872778

2788-
nfs4_show_superblock(s, file);
2789-
seq_printf(s, ", ");
2790-
nfs4_show_fname(s, file);
2791-
seq_printf(s, " }\n");
2792-
out:
2779+
spin_lock(&nf->fi_lock);
2780+
file = nf->fi_deleg_file;
2781+
if (file) {
2782+
seq_puts(s, ", ");
2783+
nfs4_show_superblock(s, file);
2784+
seq_puts(s, ", ");
2785+
nfs4_show_fname(s, file);
2786+
}
2787+
seq_puts(s, " }\n");
27932788
spin_unlock(&nf->fi_lock);
27942789
return 0;
27952790
}
@@ -2802,16 +2797,19 @@ static int nfs4_show_layout(struct seq_file *s, struct nfs4_stid *st)
28022797
ls = container_of(st, struct nfs4_layout_stateid, ls_stid);
28032798
file = ls->ls_file;
28042799

2805-
seq_printf(s, "- ");
2800+
seq_puts(s, "- ");
28062801
nfs4_show_stateid(s, &st->sc_stateid);
2807-
seq_printf(s, ": { type: layout, ");
2802+
seq_puts(s, ": { type: layout");
28082803

28092804
/* XXX: What else would be useful? */
28102805

2811-
nfs4_show_superblock(s, file);
2812-
seq_printf(s, ", ");
2813-
nfs4_show_fname(s, file);
2814-
seq_printf(s, " }\n");
2806+
if (file) {
2807+
seq_puts(s, ", ");
2808+
nfs4_show_superblock(s, file);
2809+
seq_puts(s, ", ");
2810+
nfs4_show_fname(s, file);
2811+
}
2812+
seq_puts(s, " }\n");
28152813

28162814
return 0;
28172815
}

0 commit comments

Comments
 (0)