Whamcloud - gitweb
LU-9679 lustre: avoid cast of file->private_data 51/36651/4
authorMr NeilBrown <neilb@suse.de>
Sun, 3 Nov 2019 23:02:58 +0000 (10:02 +1100)
committerOleg Drokin <green@whamcloud.com>
Fri, 14 Feb 2020 05:49:28 +0000 (05:49 +0000)
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 <neilb@suse.de>
Change-Id: I9a7adb102687496f43bab099b1ca584955f040c9
Reviewed-on: https://review.whamcloud.com/36651
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.super@gmail.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
12 files changed:
lustre/fid/lproc_fid.c
lustre/fld/lproc_fld.c
lustre/ldlm/ldlm_resource.c
lustre/lov/lproc_lov.c
lustre/mdc/lproc_mdc.c
lustre/obdclass/lprocfs_status.c
lustre/obdclass/lu_ref.c
lustre/osc/lproc_osc.c
lustre/ptlrpc/nrs_crr.c
lustre/ptlrpc/nrs_tbf.c
lustre/quota/qmt_pool.c
lustre/quota/qsd_lib.c

index 0f460f9..688082e 100644 (file)
@@ -105,11 +105,11 @@ ldebugfs_server_fid_space_seq_write(struct file *file,
                                    const char __user *buffer,
                                    size_t count, loff_t *off)
 {
                                    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;
        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);
 
        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)
 {
                                    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;
        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);
 
        mutex_lock(&seq->lcs_mutex);
        rc = ldebugfs_fid_write_common(buffer, count, &seq->lcs_space);
index 1bcecdf..5edc90d 100644 (file)
@@ -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)
 {
 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;
        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;
 
        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;
        for (i = 0; fld_hash[i].fh_name; i++) {
                if (count != strlen(fld_hash[i].fh_name))
                        continue;
index d1ace7a..5b2ce0c 100644 (file)
@@ -111,9 +111,10 @@ static ssize_t seq_watermark_write(struct file *file,
                                   const char __user *buffer, size_t count,
                                   loff_t *off)
 {
                                   const char __user *buffer, size_t count,
                                   loff_t *off)
 {
+       struct seq_file *m = file->private_data;
        u64 value;
        __u64 watermark;
        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;
        bool wm_low = (data == &ldlm_reclaim_threshold_mb) ? true : false;
        char kernbuf[22] = "";
        int rc;
index a65b250..234eeb3 100644 (file)
@@ -54,7 +54,8 @@ static ssize_t lov_stripesize_seq_write(struct file *file,
                                        const char __user *buffer,
                                        size_t count, loff_t *off)
 {
                                        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;
        struct lov_desc *desc;
        char kernbuf[22] = "";
        u64 val;
index c6a7e99..cf21905 100644 (file)
@@ -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)
 {
                                             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;
 
        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;
        rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
index ebace78..7b8aff9 100644 (file)
@@ -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)
 {
                                                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;
        struct client_obd *cli = &dev->u.cli;
        struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data;
        int chunk_mask, rc;
index e0a7579..cf674a9 100644 (file)
@@ -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)
 {
 
 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);
 
        spin_lock(&lu_ref_refs_guard);
        list_del_init(&ref->lf_linkage);
index 5f7638f..387ec7d 100644 (file)
@@ -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)
 {
                                       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;
        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)
 {
                                             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;
        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)
 {
                                           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];
        int i;
        DECLARE_CKSUM_NAME;
        char kernbuf[10];
index 6d0a0be..680cefb 100644 (file)
@@ -665,7 +665,8 @@ ptlrpc_lprocfs_nrs_crrn_quantum_seq_write(struct file *file,
                                          size_t count,
                                          loff_t *off)
 {
                                          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;
        enum ptlrpc_nrs_queue_type   queue = 0;
        char                         kernbuf[LPROCFS_NRS_WR_QUANTUM_MAX_CMD];
        char                        *val;
index 15874da..a8f3b79 100644 (file)
@@ -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;
         */
        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;
                struct ptlrpc_service_part *svcpt;
 
                svcpt = policy->pol_nrs->nrs_svcpt;
index c6ef6fc..71e5a52 100644 (file)
@@ -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)
 {
 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;
 
        long long least_qunit;
        int qunit, rc;
 
-       pool = ((struct seq_file *)file->private_data)->private;
        LASSERT(pool != NULL);
 
        /* Not tuneable for inode limit */
        LASSERT(pool != NULL);
 
        /* Not tuneable for inode limit */
index c535f90..cbdd74e 100644 (file)
@@ -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)
 {
 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);
        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)
 {
 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;
 
        time64_t timeout;
        int rc;