summaryrefslogtreecommitdiff
path: root/drivers/staging/lustre
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2018-02-20 13:23:38 +1100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-22 15:06:36 +0100
commit8689a5027c7cfb8ee25318127262fbc974662d26 (patch)
tree0c9c8b1418444b9e28ce83d8940ba0cd1d284d50 /drivers/staging/lustre
parent8ede253133d45d510dacfde86ba836fd301e8c06 (diff)
staging: lustre: fid: fix up debugfs access to ->lcs_space
lcs_space can change while the lock is not held if an RPC in underway. This can be detected by seq->ls_update being set. In this case, reading or writing the value should return -EBUSY. Also, the D_INFO CDEBUG() which reports the lcs_space being updated never fires, as it tests the wrong value - ldebugfs_fid_write_common() returns 'count' on success. Finally, this return value should be returned from ldebugfs_fid_space_seq_write(), rather than always returning 'count', so that errors can be detected. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre')
-rw-r--r--drivers/staging/lustre/lustre/fid/lproc_fid.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c
index e05487662afd..a1e5bf9f36ec 100644
--- a/drivers/staging/lustre/lustre/fid/lproc_fid.c
+++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c
@@ -106,28 +106,35 @@ ldebugfs_fid_space_seq_write(struct file *file,
rc = ldebugfs_fid_write_common(buffer, count, &range);
spin_lock(&seq->lcs_lock);
+ if (seq->lcs_update)
+ /* An RPC call is active to update lcs_space */
+ rc = -EBUSY;
if (rc > 0)
seq->lcs_space = range;
spin_unlock(&seq->lcs_lock);
- if (rc == 0) {
+ if (rc > 0) {
CDEBUG(D_INFO, "%s: Space: " DRANGE "\n",
seq->lcs_name, PRANGE(&range));
}
- return count;
+ return rc;
}
static int
ldebugfs_fid_space_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
+ int rc = 0;
spin_lock(&seq->lcs_lock);
- seq_printf(m, "[%#llx - %#llx]:%x:%s\n", PRANGE(&seq->lcs_space));
+ if (seq->lcs_update)
+ rc = -EBUSY;
+ else
+ seq_printf(m, "[%#llx - %#llx]:%x:%s\n", PRANGE(&seq->lcs_space));
spin_unlock(&seq->lcs_lock);
- return 0;
+ return rc;
}
static ssize_t