Whamcloud - gitweb
LU-6158 mdt: always shrink_capsule in getxattr_all
[fs/lustre-release.git] / lustre / fld / lproc_fld.c
index ccfb258..b231c16 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 
 #define DEBUG_SUBSYSTEM S_FLD
 
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-# include <linux/module.h>
-#else /* __KERNEL__ */
-# include <liblustre.h>
-#endif
-
+#include <libcfs/libcfs.h>
+#include <linux/module.h>
 #include <dt_object.h>
 #include <obd_support.h>
 #include <lustre_fld.h>
 #include <lustre_fid.h>
 #include "fld_internal.h"
-#include <md_object.h>
 
-#ifdef LPROCFS
+#ifdef CONFIG_PROC_FS
 static int
 fld_proc_targets_seq_show(struct seq_file *m, void *unused)
 {
@@ -68,9 +62,8 @@ fld_proc_targets_seq_show(struct seq_file *m, void *unused)
        LASSERT(fld != NULL);
 
        spin_lock(&fld->lcf_lock);
-        cfs_list_for_each_entry(target,
-                                &fld->lcf_targets, ft_chain)
-               seq_printf(m, "%s\n", fld_target_name(target));
+       list_for_each_entry(target, &fld->lcf_targets, ft_chain)
+       seq_printf(m, "%s\n", fld_target_name(target));
        spin_unlock(&fld->lcf_lock);
        RETURN(0);
 }
@@ -91,7 +84,7 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused)
 }
 
 static ssize_t
-fld_proc_hash_seq_write(struct file *file, const char *buffer,
+fld_proc_hash_seq_write(struct file *file, const char __user *buffer,
                        size_t count, loff_t *off)
 {
        struct lu_client_fld *fld = ((struct seq_file *)file->private_data)->private;
@@ -124,7 +117,7 @@ fld_proc_hash_seq_write(struct file *file, const char *buffer,
 }
 
 static ssize_t
-lprocfs_cache_flush_seq_write(struct file *file, const char *buffer,
+lprocfs_cache_flush_seq_write(struct file *file, const char __user *buffer,
                               size_t count, loff_t *pos)
 {
        struct lu_client_fld *fld = ((struct seq_file *)file->private_data)->private;
@@ -143,7 +136,7 @@ LPROC_SEQ_FOPS_RO(fld_proc_targets);
 LPROC_SEQ_FOPS(fld_proc_hash);
 LPROC_SEQ_FOPS_WO_TYPE(fld, cache_flush);
 
-struct lprocfs_seq_vars fld_client_proc_list[] = {
+struct lprocfs_vars fld_client_proc_list[] = {
        { .name =       "targets",
          .fops =       &fld_proc_targets_fops  },
        { .name =       "hash",
@@ -167,6 +160,8 @@ static void *fldb_seq_start(struct seq_file *p, loff_t *pos)
        struct lu_server_fld    *fld;
        struct dt_object        *obj;
        const struct dt_it_ops  *iops;
+       struct dt_key           *key;
+       int                     rc;
 
        if (param == NULL || param->fsp_stop)
                return NULL;
@@ -176,9 +171,16 @@ static void *fldb_seq_start(struct seq_file *p, loff_t *pos)
        LASSERT(obj != NULL);
        iops = &obj->do_index_ops->dio_it;
 
-       iops->load(&param->fsp_env, param->fsp_it, *pos);
+       rc = iops->load(&param->fsp_env, param->fsp_it, *pos);
+       if (rc <= 0)
+               return NULL;
+
+       key = iops->key(&param->fsp_env, param->fsp_it);
+       if (IS_ERR(key))
+               return NULL;
+
+       *pos = be64_to_cpu(*(__u64 *)key);
 
-       *pos = be64_to_cpu(*(__u64 *)iops->key(&param->fsp_env, param->fsp_it));
        return param;
 }
 
@@ -277,7 +279,10 @@ static int fldb_seq_open(struct inode *inode, struct file *file)
        int                     env_init = 0;
        int                     rc;
 
-       LPROCFS_ENTRY_CHECK(PDE(inode));
+       rc = LPROCFS_ENTRY_CHECK(inode);
+       if (rc < 0)
+               return rc;
+
        rc = seq_open(file, &fldb_sops);
        if (rc)
                GOTO(out, rc);
@@ -299,7 +304,7 @@ static int fldb_seq_open(struct inode *inode, struct file *file)
 
        env_init = 1;
        iops = &obj->do_index_ops->dio_it;
-       param->fsp_it = iops->init(&param->fsp_env, obj, 0, NULL);
+       param->fsp_it = iops->init(&param->fsp_env, obj, 0);
        if (IS_ERR(param->fsp_it))
                GOTO(out, rc = PTR_ERR(param->fsp_it));
 
@@ -354,10 +359,10 @@ const struct file_operations fld_proc_seq_fops = {
        .release = fldb_seq_release,
 };
 
-struct lprocfs_seq_vars fld_server_proc_list[] = {
+struct lprocfs_vars fld_server_proc_list[] = {
        { NULL }
 };
 
 # endif /* HAVE_SERVER_SUPPORT */
 
-#endif /* LPROCFS */
+#endif /* CONFIG_PROC_FS */