From f07508d17b49574c7ea47a855c6e8af2b23c3add Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Mon, 4 Nov 2019 10:02:58 +1100 Subject: [PATCH] LU-9679 lustre: avoid cast of file->private_data Instead of foo = ((struct seq_file*)file->private_data)->private; use struct seq_file *m = file->private_data; foo = m->private; Many places is lustre use this second style already. It is much less noisy and prefered for upstream Linux. Signed-off-by: Mr NeilBrown Change-Id: I9a7adb102687496f43bab099b1ca584955f040c9 Reviewed-on: https://review.whamcloud.com/36651 Tested-by: jenkins Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: Shaun Tancheff --- lustre/fid/lproc_fid.c | 8 ++++---- lustre/fld/lproc_fld.c | 5 ++--- lustre/ldlm/ldlm_resource.c | 3 ++- lustre/lov/lproc_lov.c | 3 ++- lustre/mdc/lproc_mdc.c | 4 ++-- lustre/obdclass/lprocfs_status.c | 4 ++-- lustre/obdclass/lu_ref.c | 3 ++- lustre/osc/lproc_osc.c | 9 ++++++--- lustre/ptlrpc/nrs_crr.c | 3 ++- lustre/ptlrpc/nrs_tbf.c | 2 +- lustre/quota/qmt_pool.c | 4 ++-- lustre/quota/qsd_lib.c | 6 ++++-- 12 files changed, 31 insertions(+), 23 deletions(-) diff --git a/lustre/fid/lproc_fid.c b/lustre/fid/lproc_fid.c index 0f460f9..688082e 100644 --- a/lustre/fid/lproc_fid.c +++ b/lustre/fid/lproc_fid.c @@ -105,11 +105,11 @@ ldebugfs_server_fid_space_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct lu_server_seq *seq; + struct seq_file *m = file->private_data; + struct lu_server_seq *seq = m->private; int rc; ENTRY; - seq = ((struct seq_file *)file->private_data)->private; mutex_lock(&seq->lss_mutex); rc = ldebugfs_fid_write_common(buffer, count, &seq->lss_space); @@ -494,11 +494,11 @@ ldebugfs_client_fid_space_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct lu_client_seq *seq; + struct seq_file *m = file->private_data; + struct lu_client_seq *seq = m->private; int rc; ENTRY; - seq = ((struct seq_file *)file->private_data)->private; mutex_lock(&seq->lcs_mutex); rc = ldebugfs_fid_write_common(buffer, count, &seq->lcs_space); diff --git a/lustre/fld/lproc_fld.c b/lustre/fld/lproc_fld.c index 1bcecdf..5edc90d 100644 --- a/lustre/fld/lproc_fld.c +++ b/lustre/fld/lproc_fld.c @@ -82,7 +82,8 @@ static ssize_t fld_debugfs_hash_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct lu_client_fld *fld; + struct seq_file *m = file->private_data; + struct lu_client_fld *fld = m->private; struct lu_fld_hash *hash = NULL; char fh_name[8]; int i; @@ -93,8 +94,6 @@ fld_debugfs_hash_seq_write(struct file *file, const char __user *buffer, if (copy_from_user(fh_name, buffer, count) != 0) return -EFAULT; - fld = ((struct seq_file *)file->private_data)->private; - for (i = 0; fld_hash[i].fh_name; i++) { if (count != strlen(fld_hash[i].fh_name)) continue; diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index d1ace7a..5b2ce0c 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -111,9 +111,10 @@ static ssize_t seq_watermark_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { + struct seq_file *m = file->private_data; u64 value; __u64 watermark; - __u64 *data = ((struct seq_file *)file->private_data)->private; + __u64 *data = m->private; bool wm_low = (data == &ldlm_reclaim_threshold_mb) ? true : false; char kernbuf[22] = ""; int rc; diff --git a/lustre/lov/lproc_lov.c b/lustre/lov/lproc_lov.c index a65b250..234eeb3 100644 --- a/lustre/lov/lproc_lov.c +++ b/lustre/lov/lproc_lov.c @@ -54,7 +54,8 @@ static ssize_t lov_stripesize_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct seq_file *m = file->private_data; + struct obd_device *dev = m->private; struct lov_desc *desc; char kernbuf[22] = ""; u64 val; diff --git a/lustre/mdc/lproc_mdc.c b/lustre/mdc/lproc_mdc.c index c6a7e99..cf21905 100644 --- a/lustre/mdc/lproc_mdc.c +++ b/lustre/mdc/lproc_mdc.c @@ -469,11 +469,11 @@ static ssize_t mdc_dom_min_repsize_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct obd_device *dev; + struct seq_file *m = file->private_data; + struct obd_device *dev = m->private; unsigned int val; int rc; - dev = ((struct seq_file *)file->private_data)->private; rc = kstrtouint_from_user(buffer, count, 0, &val); if (rc) return rc; diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index ebace78..7b8aff9 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -2442,8 +2442,8 @@ ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct obd_device *dev = - ((struct seq_file *)file->private_data)->private; + struct seq_file *m = file->private_data; + struct obd_device *dev = m->private; struct client_obd *cli = &dev->u.cli; struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data; int chunk_mask, rc; diff --git a/lustre/obdclass/lu_ref.c b/lustre/obdclass/lu_ref.c index e0a7579..cf674a9 100644 --- a/lustre/obdclass/lu_ref.c +++ b/lustre/obdclass/lu_ref.c @@ -395,7 +395,8 @@ static int lu_ref_seq_open(struct inode *inode, struct file *file) static int lu_ref_seq_release(struct inode *inode, struct file *file) { - struct lu_ref *ref = ((struct seq_file *)file->private_data)->private; + struct seq_file *m = file->private_data; + struct lu_ref *ref = m->private; spin_lock(&lu_ref_refs_guard); list_del_init(&ref->lf_linkage); diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index 5f7638f..387ec7d 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -210,7 +210,8 @@ static ssize_t osc_cached_mb_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct seq_file *m = file->private_data; + struct obd_device *dev = m->private; struct client_obd *cli = &dev->u.cli; u64 pages_number; const char *tmp; @@ -280,7 +281,8 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct seq_file *m = file->private_data; + struct obd_device *obd = m->private; struct client_obd *cli = &obd->u.cli; char kernbuf[22] = ""; u64 val; @@ -424,7 +426,8 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct seq_file *m = file->private_data; + struct obd_device *obd = m->private; int i; DECLARE_CKSUM_NAME; char kernbuf[10]; diff --git a/lustre/ptlrpc/nrs_crr.c b/lustre/ptlrpc/nrs_crr.c index 6d0a0be..680cefb 100644 --- a/lustre/ptlrpc/nrs_crr.c +++ b/lustre/ptlrpc/nrs_crr.c @@ -665,7 +665,8 @@ ptlrpc_lprocfs_nrs_crrn_quantum_seq_write(struct file *file, size_t count, loff_t *off) { - struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; + struct seq_file *m = file->private_data; + struct ptlrpc_service *svc = m->private; enum ptlrpc_nrs_queue_type queue = 0; char kernbuf[LPROCFS_NRS_WR_QUANTUM_MAX_CMD]; char *val; diff --git a/lustre/ptlrpc/nrs_tbf.c b/lustre/ptlrpc/nrs_tbf.c index 15874da..a8f3b79 100644 --- a/lustre/ptlrpc/nrs_tbf.c +++ b/lustre/ptlrpc/nrs_tbf.c @@ -2883,7 +2883,7 @@ static int nrs_tbf_ctl(struct ptlrpc_nrs_policy *policy, */ case NRS_CTL_TBF_RD_RULE: { struct nrs_tbf_head *head = policy->pol_private; - struct seq_file *m = (struct seq_file *) arg; + struct seq_file *m = arg; struct ptlrpc_service_part *svcpt; svcpt = policy->pol_nrs->nrs_svcpt; diff --git a/lustre/quota/qmt_pool.c b/lustre/quota/qmt_pool.c index c6ef6fc..71e5a52 100644 --- a/lustre/quota/qmt_pool.c +++ b/lustre/quota/qmt_pool.c @@ -125,11 +125,11 @@ static ssize_t qpi_soft_least_qunit_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct qmt_pool_info *pool; + struct seq_file *m = file->private_data; + struct qmt_pool_info *pool = m->private; long long least_qunit; int qunit, rc; - pool = ((struct seq_file *)file->private_data)->private; LASSERT(pool != NULL); /* Not tuneable for inode limit */ diff --git a/lustre/quota/qsd_lib.c b/lustre/quota/qsd_lib.c index c535f90..cbdd74e 100644 --- a/lustre/quota/qsd_lib.c +++ b/lustre/quota/qsd_lib.c @@ -201,7 +201,8 @@ static ssize_t lprocfs_force_reint_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct qsd_instance *qsd = ((struct seq_file *)file->private_data)->private; + struct seq_file *m = file->private_data; + struct qsd_instance *qsd = m->private; int rc = 0, qtype; LASSERT(qsd != NULL); @@ -248,7 +249,8 @@ static ssize_t qsd_timeout_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct qsd_instance *qsd = ((struct seq_file *)file->private_data)->private; + struct seq_file *m = file->private_data; + struct qsd_instance *qsd = m->private; time64_t timeout; int rc; -- 1.8.3.1