Whamcloud - gitweb
LU-3336 lfsck: orphan OST-objects iteration
[fs/lustre-release.git] / lustre / ptlrpc / nrs_crr.c
index 27959cf..7d4158c 100644 (file)
@@ -181,7 +181,7 @@ static cfs_hash_ops_t nrs_crrn_hash_ops = {
  * \retval -ENOMEM OOM error
  * \retval 0      success
  */
-static int nrs_crrn_start(struct ptlrpc_nrs_policy *policy)
+static int nrs_crrn_start(struct ptlrpc_nrs_policy *policy, char *arg)
 {
        struct nrs_crrn_net    *net;
        int                     rc = 0;
@@ -352,8 +352,7 @@ int nrs_crrn_res_get(struct ptlrpc_nrs_policy *policy,
                goto out;
 
        OBD_CPT_ALLOC_GFP(cli, nrs_pol2cptab(policy), nrs_pol2cptid(policy),
-                         sizeof(*cli), moving_req ? GFP_ATOMIC :
-                         __GFP_IO);
+                         sizeof(*cli), moving_req ? GFP_ATOMIC : GFP_NOFS);
        if (cli == NULL)
                return -ENOMEM;
 
@@ -633,14 +632,12 @@ static void nrs_crrn_req_stop(struct ptlrpc_nrs_policy *policy,
  *     reg_quantum:8
  *     hp_quantum:4
  */
-static int ptlrpc_lprocfs_rd_nrs_crrn_quantum(char *page, char **start,
-                                             off_t off, int count, int *eof,
-                                             void *data)
+static int
+ptlrpc_lprocfs_nrs_crrn_quantum_seq_show(struct seq_file *m, void *data)
 {
-       struct ptlrpc_service       *svc = data;
-       __u16                        quantum;
-       int                          rc;
-       int                          rc2 = 0;
+       struct ptlrpc_service   *svc = m->private;
+       __u16                   quantum;
+       int                     rc;
 
        /**
         * Perform two separate calls to this as only one of the NRS heads'
@@ -652,9 +649,8 @@ static int ptlrpc_lprocfs_rd_nrs_crrn_quantum(char *page, char **start,
                                       NRS_CTL_CRRN_RD_QUANTUM,
                                       true, &quantum);
        if (rc == 0) {
-               *eof = 1;
-               rc2 = snprintf(page, count, NRS_LPROCFS_QUANTUM_NAME_REG
-                              "%-5d\n", quantum);
+               seq_printf(m, NRS_LPROCFS_QUANTUM_NAME_REG
+                          "%-5d\n", quantum);
                /**
                 * Ignore -ENODEV as the regular NRS head's policy may be in the
                 * ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
@@ -671,9 +667,7 @@ static int ptlrpc_lprocfs_rd_nrs_crrn_quantum(char *page, char **start,
                                       NRS_CTL_CRRN_RD_QUANTUM,
                                       true, &quantum);
        if (rc == 0) {
-               *eof = 1;
-               rc2 += snprintf(page + rc2, count - rc2,
-                               NRS_LPROCFS_QUANTUM_NAME_HP"%-5d\n", quantum);
+               seq_printf(m, NRS_LPROCFS_QUANTUM_NAME_HP"%-5d\n", quantum);
                /**
                 * Ignore -ENODEV as the high priority NRS head's policy may be
                 * in the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
@@ -683,8 +677,7 @@ static int ptlrpc_lprocfs_rd_nrs_crrn_quantum(char *page, char **start,
        }
 
 no_hp:
-
-       return rc2 ? : rc;
+       return rc;
 }
 
 /**
@@ -707,18 +700,19 @@ no_hp:
  * policy instances in the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state
  * are skipped later by nrs_crrn_ctl().
  */
-static int ptlrpc_lprocfs_wr_nrs_crrn_quantum(struct file *file,
-                                             const char *buffer,
-                                             unsigned long count, void *data)
+static ssize_t
+ptlrpc_lprocfs_nrs_crrn_quantum_seq_write(struct file *file,
+                                         const char *buffer, size_t count,
+                                         loff_t *off)
 {
-       struct ptlrpc_service       *svc = data;
+       struct ptlrpc_service       *svc = ((struct seq_file *)file->private_data)->private;
        enum ptlrpc_nrs_queue_type   queue = 0;
        char                         kernbuf[LPROCFS_NRS_WR_QUANTUM_MAX_CMD];
        char                        *val;
        long                         quantum_reg;
        long                         quantum_hp;
        /** lprocfs_find_named_value() modifies its argument, so keep a copy */
-       unsigned long                count_copy;
+       size_t                       count_copy;
        int                          rc = 0;
        int                          rc2 = 0;
 
@@ -815,6 +809,7 @@ static int ptlrpc_lprocfs_wr_nrs_crrn_quantum(struct file *file,
 
        return rc == -ENODEV && rc2 == -ENODEV ? -ENODEV : count;
 }
+LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs_crrn_quantum);
 
 /**
  * Initializes a CRR-N policy's lprocfs interface for service \a svc
@@ -826,12 +821,9 @@ static int ptlrpc_lprocfs_wr_nrs_crrn_quantum(struct file *file,
  */
 int nrs_crrn_lprocfs_init(struct ptlrpc_service *svc)
 {
-       int     rc;
-
-       struct lprocfs_vars nrs_crrn_lprocfs_vars[] = {
+       struct lprocfs_seq_vars nrs_crrn_lprocfs_vars[] = {
                { .name         = "nrs_crrn_quantum",
-                 .read_fptr    = ptlrpc_lprocfs_rd_nrs_crrn_quantum,
-                 .write_fptr   = ptlrpc_lprocfs_wr_nrs_crrn_quantum,
+                 .fops         = &ptlrpc_lprocfs_nrs_crrn_quantum_fops,
                  .data = svc },
                { NULL }
        };
@@ -839,9 +831,8 @@ int nrs_crrn_lprocfs_init(struct ptlrpc_service *svc)
        if (svc->srv_procroot == NULL)
                return 0;
 
-       rc = lprocfs_add_vars(svc->srv_procroot, nrs_crrn_lprocfs_vars, NULL);
-
-       return rc;
+       return lprocfs_seq_add_vars(svc->srv_procroot, nrs_crrn_lprocfs_vars,
+                                   NULL);
 }
 
 /**