Whamcloud - gitweb
LU-3308 mdc: allow setting readdir RPC size parameter 88/26088/10
authorAndreas Dilger <andreas.dilger@intel.com>
Sun, 19 Mar 2017 06:45:55 +0000 (00:45 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 2 May 2017 01:57:46 +0000 (01:57 +0000)
Allow the mdc.*.max_pages_per_rpc tunable to set the MDS bulk
readdir RPC size, rather than always using the default 1MB RPC
size.  The tunable is set in the MDC, as it should be, rather
than in the llite superblock, which requires extra code just to
get it up from the MDC's connect_data only to send it back down.
The RPC size could be tuned independently if different types of
MDSes are used (e.g. local vs. remote).

Remove the md_op_data.op_max_pages and ll_sb_info.ll_md_brw_pages
fields that previously were used to pass the readdir size from
llite to mdc_read_page().  Reorder some 32-bit fields in md_op_data
to avoid struct holes.

Remove lprocfs_obd_rd_max_pages_per_rpc() as it is no longer used.
Move osc_obd_max_pages_per_rpc_seq_write() to obdclass along with
lprocfs_obd_max_pages_per_rpc_seq_show().

Remove debug messages from fid_flatten*() since this clutters up
the debug logs, and is redundant with other debug messages.

Fix test_24v's calculation for the number of RPCs being sent, so
that it will be correct even if the readdir RPC size is modified.
Register cleanup trap to avoid leaving lots of files behind.

Merge "slow" sanity test_24D into test_24v since they both need to
have many files in a single directory, which avoids duplication.

Change calc_osc_stats() and calc_llite_stats() into calc_stats()
to be used in test_24v and other tests.  Similarly, clear_osc_stats()
and clear_llite_stats() are consolidated into clear_stats().

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Ibd814cea3b788129be8aca2866d1bb139b3ebbe5
Reviewed-on: https://review.whamcloud.com/26088
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
20 files changed:
lustre/include/lprocfs_status.h
lustre/include/lustre_fid.h
lustre/include/lustre_net.h
lustre/include/obd.h
lustre/llite/dir.c
lustre/llite/lcommon_cl.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/llite_nfs.c
lustre/llite/statahead.c
lustre/mdc/lproc_mdc.c
lustre/mdc/mdc_request.c
lustre/mdt/mdt_handler.c
lustre/obdclass/lprocfs_status.c
lustre/osc/lproc_osc.c
lustre/ptlrpc/import.c
lustre/ptlrpc/sec_bulk.c
lustre/tests/sanity.sh
lustre/tests/sanityn.sh
lustre/tests/test-framework.sh

index 4f78d6f..b68a3f5 100644 (file)
@@ -770,10 +770,9 @@ lprocfs_recovery_time_hard_seq_write(struct file *file,
 int lprocfs_target_instance_seq_show(struct seq_file *m, void *data);
 #endif
 int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data);
-ssize_t
-lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
-                                       const char __user *buffer,
-                                       size_t count, loff_t *off);
+ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
+                                               const char __user *buffer,
+                                               size_t count, loff_t *off);
 
 struct root_squash_info;
 int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
index 26acbde..dc996a5 100644 (file)
@@ -797,19 +797,19 @@ static inline void ost_fid_from_resid(struct lu_fid *fid,
  */
 static inline __u64 fid_flatten(const struct lu_fid *fid)
 {
-        __u64 ino;
-        __u64 seq;
+       __u64 ino;
+       __u64 seq;
 
-        if (fid_is_igif(fid)) {
-                ino = lu_igif_ino(fid);
-                RETURN(ino);
-        }
+       if (fid_is_igif(fid)) {
+               ino = lu_igif_ino(fid);
+               return ino;
+       }
 
-        seq = fid_seq(fid);
+       seq = fid_seq(fid);
 
-        ino = (seq << 24) + ((seq >> 24) & 0xffffff0000ULL) + fid_oid(fid);
+       ino = (seq << 24) + ((seq >> 24) & 0xffffff0000ULL) + fid_oid(fid);
 
-        RETURN(ino ? ino : fid_oid(fid));
+       return ino ?: fid_oid(fid);
 }
 
 static inline __u32 fid_hash(const struct lu_fid *f, int bits)
@@ -823,26 +823,26 @@ static inline __u32 fid_hash(const struct lu_fid *f, int bits)
  * map fid to 32 bit value for ino on 32bit systems. */
 static inline __u32 fid_flatten32(const struct lu_fid *fid)
 {
-        __u32 ino;
-        __u64 seq;
+       __u32 ino;
+       __u64 seq;
 
-        if (fid_is_igif(fid)) {
-                ino = lu_igif_ino(fid);
-                RETURN(ino);
-        }
+       if (fid_is_igif(fid)) {
+               ino = lu_igif_ino(fid);
+               return ino;
+       }
 
-        seq = fid_seq(fid) - FID_SEQ_START;
+       seq = fid_seq(fid) - FID_SEQ_START;
 
-        /* Map the high bits of the OID into higher bits of the inode number so
-         * that inodes generated at about the same time have a reduced chance
-         * of collisions. This will give a period of 2^12 = 1024 unique clients
-         * (from SEQ) and up to min(LUSTRE_SEQ_MAX_WIDTH, 2^20) = 128k objects
-         * (from OID), or up to 128M inodes without collisions for new files. */
-        ino = ((seq & 0x000fffffULL) << 12) + ((seq >> 8) & 0xfffff000) +
-               (seq >> (64 - (40-8)) & 0xffffff00) +
-               (fid_oid(fid) & 0xff000fff) + ((fid_oid(fid) & 0x00fff000) << 8);
+       /* Map the high bits of the OID into higher bits of the inode number so
+        * that inodes generated at about the same time have a reduced chance
+        * of collisions. This will give a period of 2^12 = 1024 unique clients
+        * (from SEQ) and up to min(LUSTRE_SEQ_MAX_WIDTH, 2^20) = 128k objects
+        * (from OID), or up to 128M inodes without collisions for new files. */
+       ino = ((seq & 0x000fffffULL) << 12) + ((seq >> 8) & 0xfffff000) +
+             (seq >> (64 - (40-8)) & 0xffffff00) +
+             (fid_oid(fid) & 0xff000fff) + ((fid_oid(fid) & 0x00fff000) << 8);
 
-        RETURN(ino ? ino : fid_oid(fid));
+       return ino ?: fid_oid(fid);
 }
 
 static inline int
index eee74a6..1619459 100644 (file)
  * currently supported maximum between peers at connect via ocd_brw_size.
  */
 #define PTLRPC_MAX_BRW_BITS    (LNET_MTU_BITS + PTLRPC_BULK_OPS_BITS)
-#define PTLRPC_MAX_BRW_SIZE    (1 << PTLRPC_MAX_BRW_BITS)
+#define PTLRPC_MAX_BRW_SIZE    (1U << PTLRPC_MAX_BRW_BITS)
 #define PTLRPC_MAX_BRW_PAGES   (PTLRPC_MAX_BRW_SIZE >> PAGE_SHIFT)
 
-#define ONE_MB_BRW_SIZE                (1 << LNET_MTU_BITS)
-#define MD_MAX_BRW_SIZE                (1 << LNET_MTU_BITS)
+#define ONE_MB_BRW_SIZE                (1U << LNET_MTU_BITS)
+#define MD_MAX_BRW_SIZE                (1U << LNET_MTU_BITS)
 #define MD_MAX_BRW_PAGES       (MD_MAX_BRW_SIZE >> PAGE_SHIFT)
 #define DT_MAX_BRW_SIZE                PTLRPC_MAX_BRW_SIZE
 #define DT_MAX_BRW_PAGES       (DT_MAX_BRW_SIZE >> PAGE_SHIFT)
-#define OFD_MAX_BRW_SIZE       (1 << LNET_MTU_BITS)
+#define OFD_MAX_BRW_SIZE       (1U << LNET_MTU_BITS)
 
 /* When PAGE_SIZE is a constant, we can check our arithmetic here with cpp! */
 #if ((PTLRPC_MAX_BRW_PAGES & (PTLRPC_MAX_BRW_PAGES - 1)) != 0)
index afeaed8..596ce8d 100644 (file)
@@ -788,39 +788,36 @@ static inline bool it_has_reply_body(const struct lookup_intent *it)
 }
 
 struct md_op_data {
-        struct lu_fid           op_fid1; /* operation fid1 (usualy parent) */
-        struct lu_fid           op_fid2; /* operation fid2 (usualy child) */
-        struct lu_fid           op_fid3; /* 2 extra fids to find conflicting */
-        struct lu_fid           op_fid4; /* to the operation locks. */
+       struct lu_fid           op_fid1; /* operation fid1 (usualy parent) */
+       struct lu_fid           op_fid2; /* operation fid2 (usualy child) */
+       struct lu_fid           op_fid3; /* 2 extra fids to find conflicting */
+       struct lu_fid           op_fid4; /* to the operation locks. */
        u32                     op_mds;  /* what mds server open will go to */
-       struct lustre_handle    op_handle;
+       __u32                   op_mode;
+       struct lustre_handle    op_handle;
        s64                     op_mod_time;
-        const char             *op_name;
+       const char              *op_name;
        size_t                  op_namelen;
-        __u32                   op_mode;
-        struct lmv_stripe_md   *op_mea1;
-        struct lmv_stripe_md   *op_mea2;
-        __u32                   op_suppgids[2];
-        __u32                   op_fsuid;
-        __u32                   op_fsgid;
-        cfs_cap_t               op_cap;
-        void                   *op_data;
+       struct lmv_stripe_md    *op_mea1;
+       struct lmv_stripe_md    *op_mea2;
+       __u32                   op_suppgids[2];
+       __u32                   op_fsuid;
+       __u32                   op_fsgid;
+       cfs_cap_t               op_cap;
+       void                    *op_data;
        size_t                  op_data_size;
 
-        /* iattr fields and blocks. */
+       /* iattr fields and blocks. */
        struct iattr            op_attr;
        loff_t                  op_attr_blocks;
-       unsigned int            op_attr_flags; /* LUSTRE_{SYNC,..}_FL */
        __u64                   op_valid; /* OBD_MD_* */
+       unsigned int            op_attr_flags; /* LUSTRE_{SYNC,..}_FL */
 
        enum md_op_flags        op_flags;
 
        /* Various operation flags. */
        enum mds_op_bias        op_bias;
 
-       /* Used by readdir */
-       unsigned int            op_max_pages;
-
        /* used to transfer info between the stacks of MD client
         * see enum op_cli_flags */
        enum md_cli_flags       op_cli_flags;
index 67c52fe..c217a31 100644 (file)
@@ -247,18 +247,11 @@ int ll_dir_read(struct inode *inode, __u64 *ppos, struct md_op_data *op_data,
                        __u64          ino;
 
                        hash = le64_to_cpu(ent->lde_hash);
-                       if (hash < pos)
-                               /*
-                                * Skip until we find target hash
-                                * value.
-                                */
+                       if (hash < pos) /* Skip until we find target hash */
                                continue;
 
                        namelen = le16_to_cpu(ent->lde_namelen);
-                       if (namelen == 0)
-                               /*
-                                * Skip dummy record.
-                                */
+                       if (namelen == 0) /* Skip dummy record */
                                continue;
 
                        if (is_api32 && is_hash64)
@@ -268,10 +261,9 @@ int ll_dir_read(struct inode *inode, __u64 *ppos, struct md_op_data *op_data,
                        fid_le_to_cpu(&fid, &ent->lde_fid);
                        ino = cl_fid_build_ino(&fid, is_api32);
                        type = ll_dirent_type_get(ent);
-                       /* For 'll_nfs_get_name_filldir()', it will try
-                        * to access the 'ent' through its 'lde_name',
-                        * so the parameter 'name' for 'filldir()' must
-                        * be part of the 'ent'. */
+                       /* For ll_nfs_get_name_filldir(), it will try to access
+                        * 'ent' through 'lde_name', so the parameter 'name'
+                        * for 'filldir()' must be part of the 'ent'. */
 #ifdef HAVE_DIR_CONTEXT
                        ctx->pos = lhash;
                        done = !dir_emit(ctx, ent->lde_name, namelen, ino,
@@ -377,7 +369,6 @@ static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
                        }
                }
        }
-       op_data->op_max_pages = sbi->ll_md_brw_pages;
 #ifdef HAVE_DIR_CONTEXT
        ctx->pos = pos;
        rc = ll_dir_read(inode, &pos, op_data, ctx);
index 7bdb9ea..9ea2bd7 100644 (file)
@@ -253,28 +253,28 @@ void cl_inode_fini(struct inode *inode)
 }
 
 /**
- * build inode number from passed @fid */
+ * build inode number from passed @fid.
+ *
+ * For 32-bit systems or syscalls limit the inode number to a 32-bit value
+ * to avoid EOVERFLOW errors.  This will inevitably result in inode number
+ * collisions, but fid_flatten32() tries hard to avoid this if possible.
+ */
 __u64 cl_fid_build_ino(const struct lu_fid *fid, int api32)
 {
-        if (BITS_PER_LONG == 32 || api32)
-                RETURN(fid_flatten32(fid));
-        else
-                RETURN(fid_flatten(fid));
+       if (BITS_PER_LONG == 32 || api32)
+               RETURN(fid_flatten32(fid));
+
+       RETURN(fid_flatten(fid));
 }
 
 /**
  * build inode generation from passed @fid.  If our FID overflows the 32-bit
- * inode number then return a non-zero generation to distinguish them. */
+ * inode number then return a non-zero generation to distinguish them.
+ */
 __u32 cl_fid_build_gen(const struct lu_fid *fid)
 {
-        __u32 gen;
-        ENTRY;
-
-        if (fid_is_igif(fid)) {
-                gen = lu_igif_gen(fid);
-                RETURN(gen);
-        }
+       if (fid_is_igif(fid))
+               RETURN(lu_igif_gen(fid));
 
-        gen = (fid_flatten(fid) >> 32);
-        RETURN(gen);
+       RETURN(fid_flatten(fid) >> 32);
 }
index c8432b1..07bd134 100644 (file)
@@ -503,8 +503,6 @@ struct ll_sb_info {
         unsigned int              ll_namelen;
         struct file_operations   *ll_fop;
 
-       unsigned int              ll_md_brw_pages; /* readdir pages per RPC */
-
         struct lu_site           *ll_site;
         struct cl_device         *ll_cl;
         /* Statistics */
index 3307d2c..d75f94c 100644 (file)
@@ -352,11 +352,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
         if (data->ocd_connect_flags & OBD_CONNECT_64BITHASH)
                 sbi->ll_flags |= LL_SBI_64BIT_HASH;
 
-       if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE)
-               sbi->ll_md_brw_pages = data->ocd_brw_size >> PAGE_SHIFT;
-       else
-               sbi->ll_md_brw_pages = 1;
-
        if (data->ocd_connect_flags & OBD_CONNECT_LAYOUTLOCK)
                sbi->ll_flags |= LL_SBI_LAYOUT_LOCK;
 
index 4dcc13d..9b15396 100644 (file)
@@ -260,7 +260,6 @@ static int ll_get_name(struct dentry *dentry, char *name,
        if (IS_ERR(op_data))
                GOTO(out, rc = PTR_ERR(op_data));
 
-       op_data->op_max_pages = ll_i2sbi(dir)->ll_md_brw_pages;
        inode_lock(dir);
 #ifdef HAVE_DIR_CONTEXT
        rc = ll_dir_read(dir, &pos, op_data, &lgd.ctx);
index 5a38893..a2002d3 100644 (file)
@@ -1002,8 +1002,6 @@ static int ll_statahead_thread(void *arg)
        if (IS_ERR(op_data))
                GOTO(out, rc = PTR_ERR(op_data));
 
-       op_data->op_max_pages = ll_i2sbi(dir)->ll_md_brw_pages;
-
        if (sbi->ll_flags & LL_SBI_AGL_ENABLED)
                ll_start_agl(parent, sai);
 
@@ -1290,7 +1288,6 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry)
        /**
         *FIXME choose the start offset of the readdir
         */
-       op_data->op_max_pages = ll_i2sbi(dir)->ll_md_brw_pages;
 
        ll_dir_chain_init(&chain);
        page = ll_get_dir_page(dir, op_data, 0, &chain);
index 3bdfb4a..2ede98f 100644 (file)
@@ -88,13 +88,13 @@ static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
 
 static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
                                                const char __user *buffer,
-                                               size_t count,
-                                               loff_t *off)
+                                               size_t count, loff_t *off)
 {
-       struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
+       struct obd_device *dev;
        __s64 val;
        int rc;
 
+       dev = ((struct seq_file *)file->private_data)->private;
        rc = lprocfs_str_to_s64(buffer, count, &val);
        if (rc)
                return rc;
@@ -110,7 +110,6 @@ static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
 }
 LPROC_SEQ_FOPS(mdc_max_rpcs_in_flight);
 
-
 static int mdc_max_mod_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
 {
        struct obd_device *dev = m->private;
@@ -124,8 +123,7 @@ static int mdc_max_mod_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
 
 static ssize_t mdc_max_mod_rpcs_in_flight_seq_write(struct file *file,
                                                    const char __user *buffer,
-                                                   size_t count,
-                                                   loff_t *off)
+                                                   size_t count, loff_t *off)
 {
        struct obd_device *dev =
                        ((struct seq_file *)file->private_data)->private;
@@ -147,7 +145,6 @@ static ssize_t mdc_max_mod_rpcs_in_flight_seq_write(struct file *file,
 }
 LPROC_SEQ_FOPS(mdc_max_mod_rpcs_in_flight);
 
-
 static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v)
 {
        struct obd_device *dev = seq->private;
@@ -155,7 +152,6 @@ static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v)
        return obd_mod_rpc_stats_seq_show(&dev->u.cli, seq);
 }
 
-
 static ssize_t mdc_rpc_stats_seq_write(struct file *file,
                                       const char __user *buf,
                                       size_t len, loff_t *off)
@@ -170,7 +166,6 @@ static ssize_t mdc_rpc_stats_seq_write(struct file *file,
 }
 LPROC_SEQ_FOPS(mdc_rpc_stats);
 
-
 LPROC_SEQ_FOPS_WO_TYPE(mdc, ping);
 
 LPROC_SEQ_FOPS_RO_TYPE(mdc, uuid);
@@ -185,13 +180,7 @@ LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
 LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
 LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
 LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
-
-static int mdc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
-{
-       return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
-}
-LPROC_SEQ_FOPS_RO(mdc_obd_max_pages_per_rpc);
-
+LPROC_SEQ_FOPS_RW_TYPE(mdc, obd_max_pages_per_rpc);
 LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
 LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
 
@@ -219,12 +208,6 @@ struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
          .fops =       &mdc_server_uuid_fops   },
        { .name =       "mds_conn_uuid",
          .fops =       &mdc_conn_uuid_fops     },
-       /*
-        * FIXME: below proc entry is provided, but not in used, instead
-        * sbi->sb_md_brw_size is used, the per obd variable should be used
-        * when CMD is enabled, and dir pages are managed in MDC layer.
-        * Remember to enable proc write function.
-        */
        { .name =       "max_pages_per_rpc",
          .fops =       &mdc_obd_max_pages_per_rpc_fops },
        { .name =       "max_rpcs_in_flight",
index 95add74..390068d 100644 (file)
@@ -1167,22 +1167,22 @@ static inline void delete_from_page_cache(struct page *page)
  **/
 static int mdc_read_page_remote(void *data, struct page *page0)
 {
-       struct readpage_param   *rp = data;
-       struct page             **page_pool;
-       struct page             *page;
-       struct lu_dirpage       *dp;
-       int                     rd_pgs = 0; /* number of pages read actually */
-       int                     npages;
-       struct md_op_data       *op_data = rp->rp_mod;
-       struct ptlrpc_request   *req;
-       int                     max_pages = op_data->op_max_pages;
-       struct inode            *inode;
-       struct lu_fid           *fid;
-       int                     i;
-       int                     rc;
+       struct readpage_param *rp = data;
+       struct page **page_pool;
+       struct page *page;
+       struct lu_dirpage *dp;
+       struct md_op_data *op_data = rp->rp_mod;
+       struct ptlrpc_request *req;
+       int max_pages;
+       struct inode *inode;
+       struct lu_fid *fid;
+       int rd_pgs = 0; /* number of pages actually read */
+       int npages;
+       int i;
+       int rc;
        ENTRY;
 
-       LASSERT(max_pages > 0 && max_pages <= PTLRPC_MAX_BRW_PAGES);
+       max_pages = rp->rp_exp->exp_obd->u.cli.cl_max_pages_per_rpc;
        inode = op_data->op_data;
        fid = &op_data->op_fid1;
        LASSERT(inode != NULL);
@@ -1209,10 +1209,9 @@ static int mdc_read_page_remote(void *data, struct page *page0)
        } else {
                int lu_pgs;
 
-               rd_pgs = (req->rq_bulk->bd_nob_transferred +
-                           PAGE_SIZE - 1) >> PAGE_SHIFT;
-               lu_pgs = req->rq_bulk->bd_nob_transferred >>
-                                                       LU_PAGE_SHIFT;
+               rd_pgs = (req->rq_bulk->bd_nob_transferred + PAGE_SIZE - 1) >>
+                       PAGE_SHIFT;
+               lu_pgs = req->rq_bulk->bd_nob_transferred >> LU_PAGE_SHIFT;
                LASSERT(!(req->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK));
 
                CDEBUG(D_INODE, "read %d(%d) pages\n", rd_pgs, lu_pgs);
index c0d1b72..aa586ec 100644 (file)
@@ -5277,16 +5277,13 @@ static int mdt_connect_internal(struct obd_export *exp,
        if (!mdt->mdt_opts.mo_user_xattr)
                data->ocd_connect_flags &= ~OBD_CONNECT_XATTR;
 
-       if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) {
-               data->ocd_brw_size = min(data->ocd_brw_size,
-                                        (__u32)MD_MAX_BRW_SIZE);
+       if (OCD_HAS_FLAG(data, BRW_SIZE)) {
+               data->ocd_brw_size = min(data->ocd_brw_size, MD_MAX_BRW_SIZE);
                if (data->ocd_brw_size == 0) {
-                       CERROR("%s: cli %s/%p ocd_connect_flags: %#llx"
-                              " ocd_version: %x ocd_grant: %d "
-                              "ocd_index: %u ocd_brw_size is "
-                              "unexpectedly zero, network data "
-                              "corruption? Refusing connection of this"
-                              " client\n",
+                       CERROR("%s: cli %s/%p ocd_connect_flags: %#llx "
+                              "ocd_version: %x ocd_grant: %d ocd_index: %u "
+                              "ocd_brw_size unexpectedly zero, network data "
+                              "corruption? Refusing to connect this client\n",
                               mdt_obd_name(mdt),
                               exp->exp_client_uuid.uuid,
                               exp, data->ocd_connect_flags, data->ocd_version,
index 7896dc5..eb46f76 100644 (file)
@@ -2288,31 +2288,58 @@ const struct sysfs_ops lustre_sysfs_ops = {
 };
 EXPORT_SYMBOL_GPL(lustre_sysfs_ops);
 
-int lprocfs_obd_rd_max_pages_per_rpc(char *page, char **start, off_t off,
-                                    int count, int *eof, void *data)
+int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *dev = data;
        struct client_obd *cli = &dev->u.cli;
-       int rc;
 
        spin_lock(&cli->cl_loi_list_lock);
-       rc = snprintf(page, count, "%d\n", cli->cl_max_pages_per_rpc);
+       seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
        spin_unlock(&cli->cl_loi_list_lock);
-
-       return rc;
+       return 0;
 }
+EXPORT_SYMBOL(lprocfs_obd_max_pages_per_rpc_seq_show);
 
-int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data)
+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 = data;
+       struct obd_device *dev =
+               ((struct seq_file *)file->private_data)->private;
        struct client_obd *cli = &dev->u.cli;
+       struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data;
+       int chunk_mask, rc;
+       __s64 val;
+
+       rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
+       if (rc)
+               return rc;
+       if (val < 0)
+               return -ERANGE;
+
+       /* if the max_pages is specified in bytes, convert to pages */
+       if (val >= ONE_MB_BRW_SIZE)
+               val >>= PAGE_SHIFT;
 
+       LPROCFS_CLIMP_CHECK(dev);
+
+       chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_SHIFT)) - 1);
+       /* max_pages_per_rpc must be chunk aligned */
+       val = (val + ~chunk_mask) & chunk_mask;
+       if (val == 0 || (ocd->ocd_brw_size != 0 &&
+                        val > ocd->ocd_brw_size >> PAGE_SHIFT)) {
+               LPROCFS_CLIMP_EXIT(dev);
+               return -ERANGE;
+       }
        spin_lock(&cli->cl_loi_list_lock);
-       seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
+       cli->cl_max_pages_per_rpc = val;
+       client_adjust_max_dirty(cli);
        spin_unlock(&cli->cl_loi_list_lock);
-       return 0;
+
+       LPROCFS_CLIMP_EXIT(dev);
+       return count;
 }
-EXPORT_SYMBOL(lprocfs_obd_max_pages_per_rpc_seq_show);
+EXPORT_SYMBOL(lprocfs_obd_max_pages_per_rpc_seq_write);
 
 int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
                           struct root_squash_info *squash, char *name)
index a71fb0f..deb1760 100644 (file)
@@ -537,50 +537,7 @@ static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v)
 }
 LPROC_SEQ_FOPS_RO(osc_destroys_in_flight);
 
-static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
-{
-       return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
-}
-
-static ssize_t osc_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 client_obd *cli = &dev->u.cli;
-       struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data;
-       int chunk_mask, rc;
-       __s64 val;
-
-       rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
-       if (rc)
-               return rc;
-       if (val < 0)
-               return -ERANGE;
-
-       /* if the max_pages is specified in bytes, convert to pages */
-       if (val >= ONE_MB_BRW_SIZE)
-               val >>= PAGE_SHIFT;
-
-       LPROCFS_CLIMP_CHECK(dev);
-
-       chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_SHIFT)) - 1);
-       /* max_pages_per_rpc must be chunk aligned */
-       val = (val + ~chunk_mask) & chunk_mask;
-       if (val == 0 || (ocd->ocd_brw_size != 0 &&
-                        val > ocd->ocd_brw_size >> PAGE_SHIFT)) {
-               LPROCFS_CLIMP_EXIT(dev);
-               return -ERANGE;
-       }
-       spin_lock(&cli->cl_loi_list_lock);
-       cli->cl_max_pages_per_rpc = val;
-       client_adjust_max_dirty(cli);
-       spin_unlock(&cli->cl_loi_list_lock);
-
-       LPROCFS_CLIMP_EXIT(dev);
-       return count;
-}
-LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc);
+LPROC_SEQ_FOPS_RW_TYPE(osc, obd_max_pages_per_rpc);
 
 static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
 {
index 1a4bf69..e559c6c 100644 (file)
@@ -1108,7 +1108,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
 
        /* Import flags should be updated before waking import at FULL state */
        rc = ptlrpc_connect_set_flags(imp, ocd, old_connect_flags, exp,
-                                aa->pcaa_initial_connect);
+                                     aa->pcaa_initial_connect);
        class_export_put(exp);
        if (rc != 0)
                GOTO(out, rc);
index 15c4f9b..22868c4 100644 (file)
@@ -242,7 +242,7 @@ static unsigned long enc_pools_shrink_count(struct shrinker *s,
        }
 
        LASSERT(page_pools.epp_idle_idx <= IDLE_IDX_MAX);
-       return max((int)page_pools.epp_free_pages - PTLRPC_MAX_BRW_PAGES, 0) *
+       return max(page_pools.epp_free_pages - PTLRPC_MAX_BRW_PAGES, 0UL) *
                (IDLE_IDX_MAX - page_pools.epp_idle_idx) / IDLE_IDX_MAX;
 }
 
index 37cd0ba..67fd9c1 100755 (executable)
@@ -75,8 +75,8 @@ init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
 init_logging
 
-#                                  5              12          (min)"
-[ "$SLOW" = "no" ] && EXCEPT_SLOW="24D 27m 64b 68 71 115 300o"
+#                                  5          12          (min)"
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
 
 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
        # bug number for skipped test: LU-4536 LU-1957
@@ -1038,53 +1038,73 @@ page_size() {
 }
 
 simple_cleanup_common() {
+       local rc=0
        trap 0
+       [ -z "$DIR" -o -z "$tdir" ] && return 0
+
+       local start=$SECONDS
        rm -rf $DIR/$tdir
+       rc=$?
        wait_delete_completed
+       echo "cleanup time $((SECONDS - start))"
+       return $rc
 }
 
 max_pages_per_rpc() {
-       $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
+       local mdtname="$(printf "MDT%04x" ${1:-0})"
+       $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
 }
 
 test_24v() {
-       local NRFILES=100000
-       local FREE_INODES=$(mdt_free_inodes 0)
-       [[ $FREE_INODES -lt $NRFILES ]] &&
-               skip "not enough free inodes $FREE_INODES required $NRFILES" &&
-               return
-
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       trap simple_cleanup_common EXIT
-
+       local nrfiles=${COUNT:-100000}
        # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
-       [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
+       [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
 
-       test_mkdir -p $DIR/$tdir
-       createmany -m $DIR/$tdir/$tfile $NRFILES
+       local fname="$DIR/$tdir/$tfile"
+       test_mkdir "$(dirname $fname)"
+       # assume MDT0000 has the fewest inodes
+       local stripes=$($LFS getdirstripe -c $(dirname $fname))
+       local free_inodes=$(($(mdt_free_inodes 0) * stripes))
+       [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
+
+       trap simple_cleanup_common EXIT
+
+       createmany -m "$fname" $nrfiles
 
        cancel_lru_locks mdc
        lctl set_param mdc.*.stats clear
 
-       ls $DIR/$tdir >/dev/null || error "error in listing large dir"
-
+       # was previously test_24D: LU-6101
+       # readdir() returns correct number of entries after cursor reload
+       local num_ls=$(ls $DIR/$tdir | wc -l)
+       local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
+       local num_all=$(ls -a $DIR/$tdir | wc -l)
+       if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
+            $num_all -ne $((nrfiles + 2)) ]; then
+               error "Expected $nrfiles files, got $num_ls " \
+                       "($num_uniq unique $num_all .&..)"
+       fi
        # LU-5 large readdir
-       # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
-       #               8 bytes for name(filename is mostly 5 in this test) +
-       #               8 bytes for luda_type
+       # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
+       #               N bytes for name (len($nrfiles) rounded to 8 bytes) +
+       #               8 bytes for luda_type (4 bytes rounded to 8 bytes)
        # take into account of overhead in lu_dirpage header and end mark in
-       # each page, plus one in RPC_NUM calculation.
-       DIRENT_SIZE=48
-       RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
-       RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
-       mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
-                               awk '/^mds_readpage/ {print $2}')
-       [[ $mds_readpage -gt $RPC_NUM ]] &&
-               error "large readdir doesn't take effect"
+       # each page, plus one in rpc_num calculation.
+       local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
+       local page_entries=$((($(page_size) - 24) / dirent_size))
+       local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
+       local rpc_pages=$(max_pages_per_rpc $mdt_idx)
+       local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
+       local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
+       echo "readpages: $mds_readpage rpc_max: $rpc_max"
+       (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
+               error "large readdir doesn't take effect: " \
+                     "$mds_readpage should be about $rpc_max"
 
        simple_cleanup_common
 }
-run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
+run_test 24v "list large directory (test hash collision, b=17560)"
 
 test_24w() { # bug21506
         SZ1=234852
@@ -1163,6 +1183,7 @@ test_24A() { # LU-3182
 
        rm -rf $DIR/$tdir
        test_mkdir -p $DIR/$tdir
+       trap simple_cleanup_common EXIT
        createmany -m $DIR/$tdir/$tfile $NFILES
        local t=$(ls $DIR/$tdir | wc -l)
        local u=$(ls $DIR/$tdir | sort -u | wc -l)
@@ -1171,7 +1192,7 @@ test_24A() { # LU-3182
                error "Expected $NFILES files, got $t ($u unique $v .&..)"
        fi
 
-       rm -rf $DIR/$tdir || error "Can not delete directories"
+       simple_cleanup_common || error "Can not delete directories"
 }
 run_test 24A "readdir() returns correct number of entries."
 
@@ -1229,23 +1250,6 @@ test_24C() {
 }
 run_test 24C "check .. in striped dir"
 
-test_24D() { # LU-6101
-       local NFILES=50000
-
-       rm -rf $DIR/$tdir
-       mkdir -p $DIR/$tdir
-       createmany -m $DIR/$tdir/$tfile $NFILES
-       local t=$(ls $DIR/$tdir | wc -l)
-       local u=$(ls $DIR/$tdir | sort -u | wc -l)
-       local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
-       if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
-               error "Expected $NFILES files, got $t ($u unique $v .&..)"
-       fi
-
-       rm -rf $DIR/$tdir || error "Can not delete directories"
-}
-run_test 24D "readdir() returns correct number of entries after cursor reload"
-
 test_24E() {
        [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
@@ -1661,7 +1665,7 @@ test_27u() { # bug 4900
 #define OBD_FAIL_MDS_OSC_PRECREATE      0x139
        do_nodes $list $LCTL set_param fail_loc=0x139
        test_mkdir -p $DIR/$tdir
-       rm -rf $DIR/$tdir/*
+       trap simple_cleanup_common EXIT
        createmany -o $DIR/$tdir/t- 1000
        do_nodes $list $LCTL set_param fail_loc=0
 
@@ -1669,6 +1673,7 @@ test_27u() { # bug 4900
        $GETSTRIPE $DIR/$tdir > $TLOG
        OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
        unlinkmany $DIR/$tdir/t- 1000
+       trap 0
        [[ $OBJS -gt 0 ]] &&
                error "$OBJS objects created on OST-0. See $TLOG" || pass
 }
@@ -12641,32 +12646,34 @@ test_216() { # bug 20317
                "ldlm.namespaces.filter-*.contended_locks" >> $p
        save_lustre_params $facets \
                "ldlm.namespaces.filter-*.contention_seconds" >> $p
-       clear_osc_stats
+       clear_stats osc.*.osc_stats
 
-        # agressive lockless i/o settings
-        for node in $(osts_nodes); do
-                do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
-        done
-        lctl set_param -n osc.*.contention_seconds 60
+       # agressive lockless i/o settings
+       do_nodes $(comma_list $(osts_nodes)) \
+               "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
+                       ldlm.namespaces.filter-*.contended_locks=0 \
+                       ldlm.namespaces.filter-*.contention_seconds=60"
+       lctl set_param -n osc.*.contention_seconds=60
 
-        $DIRECTIO write $DIR/$tfile 0 10 4096
-        $CHECKSTAT -s 40960 $DIR/$tfile
+       $DIRECTIO write $DIR/$tfile 0 10 4096
+       $CHECKSTAT -s 40960 $DIR/$tfile
 
-        # disable lockless i/o
-        for node in $(osts_nodes); do
-                do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
-        done
-        lctl set_param -n osc.*.contention_seconds 0
-        clear_osc_stats
+       # disable lockless i/o
+       do_nodes $(comma_list $(osts_nodes)) \
+               "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
+                       ldlm.namespaces.filter-*.contended_locks=32 \
+                       ldlm.namespaces.filter-*.contention_seconds=0"
+       lctl set_param -n osc.*.contention_seconds=0
+       clear_stats osc.*.osc_stats
 
-        dd if=/dev/zero of=$DIR/$tfile count=0
-        $CHECKSTAT -s 0 $DIR/$tfile
+       dd if=/dev/zero of=$DIR/$tfile count=0
+       $CHECKSTAT -s 0 $DIR/$tfile
 
-        restore_lustre_params <$p
-        rm -f $p
-        rm $DIR/$tfile
+       restore_lustre_params <$p
+       rm -f $p
+       rm $DIR/$tfile
 }
-run_test 216 "check lockless direct write works and updates file size and kms correctly"
+run_test 216 "check lockless direct write updates file size and kms correctly"
 
 test_217() { # bug 22430
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
index 21caf70..417037c 100755 (executable)
@@ -745,42 +745,42 @@ enable_lockless_truncate() {
 test_32a() { # bug 11270
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
        save_lustre_params client "osc.*.lockless_truncate" > $p
-        cancel_lru_locks osc
-        enable_lockless_truncate 1
-        rm -f $DIR1/$tfile
-        lfs setstripe -c -1 $DIR1/$tfile
-        dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
-                /dev/null 2>&1
-        clear_osc_stats
-
-        log "checking cached lockless truncate"
-        $TRUNCATE $DIR1/$tfile 8000000
-        $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
-       [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
+       cancel_lru_locks osc
+       enable_lockless_truncate 1
+       rm -f $DIR1/$tfile
+       lfs setstripe -c -1 $DIR1/$tfile
+       dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
+               /dev/null 2>&1
+       clear_stats osc.*.osc_stats
+
+       log "checking cached lockless truncate"
+       $TRUNCATE $DIR1/$tfile 8000000
+       $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
+       [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
                error "cached truncate isn't lockless"
 
-        log "checking not cached lockless truncate"
-        $TRUNCATE $DIR2/$tfile 5000000
-        $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
-       [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
+       log "checking not cached lockless truncate"
+       $TRUNCATE $DIR2/$tfile 5000000
+       $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
+       [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
                error "not cached truncate isn't lockless"
 
-        log "disabled lockless truncate"
-        enable_lockless_truncate 0
-        clear_osc_stats
-        $TRUNCATE $DIR2/$tfile 3000000
-        $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
-        [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
-                error "lockless truncate disabling failed"
-        rm $DIR1/$tfile
-        # restore lockless_truncate default values
-        restore_lustre_params < $p
-        rm -f $p
+       log "disabled lockless truncate"
+       enable_lockless_truncate 0
+       clear_stats osc.*.osc_stats
+       $TRUNCATE $DIR2/$tfile 3000000
+       $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
+       [ $(calc_stats osc.*.osc_stats lockless_truncate) -eq 0 ] ||
+               error "lockless truncate disabling failed"
+       rm $DIR1/$tfile
+       # restore lockless_truncate default values
+       restore_lustre_params < $p
+       rm -f $p
 }
 run_test 32a "lockless truncate"
 
 test_32b() { # bug 11270
-        remote_ost_nodsh && skip "remote OST with nodsh" && return
+       remote_ost_nodsh && skip "remote OST with nodsh" && return
 
        local node
        local facets=$(get_facets OST)
@@ -793,35 +793,42 @@ test_32b() { # bug 11270
                "ldlm.namespaces.filter-*.contended_locks" >> $p
        save_lustre_params $facets \
                "ldlm.namespaces.filter-*.contention_seconds" >> $p
-       clear_osc_stats
+       clear_stats osc.*.osc_stats
 
-        # agressive lockless i/o settings
-        for node in $(osts_nodes); do
-                do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
-        done
-        lctl set_param -n osc.*.contention_seconds 60
-        for i in $(seq 5); do
-                dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
-                dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
-        done
-        [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
-        # disable lockless i/o (it is disabled by default)
-        for node in $(osts_nodes); do
-                do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
-        done
-        # set contention_seconds to 0 at client too, otherwise Lustre still
-        # remembers lock contention
-        lctl set_param -n osc.*.contention_seconds 0
-        clear_osc_stats
-        for i in $(seq 1); do
-                dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
-                dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
-        done
-        [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
-                error "lockless i/o works when disabled"
-        rm -f $DIR1/$tfile
-        restore_lustre_params <$p
-        rm -f $p
+       # agressive lockless i/o settings
+       do_nodes $(comma_list $(osts_nodes)) \
+               "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
+                       ldlm.namespaces.filter-*.contended_locks=0 \
+                       ldlm.namespaces.filter-*.contention_seconds=60"
+       lctl set_param -n osc.*.contention_seconds=60
+       for i in {1..5}; do
+               dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
+                       /dev/null 2>&1
+               dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
+                       /dev/null 2>&1
+       done
+       [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -ne 0 ] ||
+               error "lockless i/o was not triggered"
+       # disable lockless i/o (it is disabled by default)
+       do_nodes $(comma_list $(osts_nodes)) \
+               "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
+                       ldlm.namespaces.filter-*.contended_locks=32 \
+                       ldlm.namespaces.filter-*.contention_seconds=0"
+       # set contention_seconds to 0 at client too, otherwise Lustre still
+       # remembers lock contention
+       lctl set_param -n osc.*.contention_seconds=0
+       clear_stats osc.*.osc_stats
+       for i in {1..1}; do
+               dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
+                       /dev/null 2>&1
+               dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
+                       /dev/null 2>&1
+       done
+       [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -eq 0 ] ||
+               error "lockless i/o works when disabled"
+       rm -f $DIR1/$tfile
+       restore_lustre_params <$p
+       rm -f $p
 }
 run_test 32b "lockless i/o"
 
@@ -2877,14 +2884,16 @@ test_73() {
                error "setfattr1 failed"
        getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
        getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
-       clear_llite_stats
+       clear_stats llite.*.stats
        # PR lock should be cached by now on both clients
        getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
        # 2 hits for getfattr(0)+getfattr(size)
-       [ $(calc_llite_stats getxattr_hits) -eq 2 ] || error "not cached in $DIR1"
+       [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
+               error "not cached in $DIR1"
        getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
        # 4 hits for more getfattr(0)+getfattr(size)
-       [ $(calc_llite_stats getxattr_hits) -eq 4 ] || error "not cached in $DIR2"
+       [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
+               error "not cached in $DIR2"
        rm -f $DIR2/$tfile
 
        restore_lustre_params < $p
index 24fc8cc..c565f08 100755 (executable)
@@ -5846,32 +5846,22 @@ inodes_available () {
 }
 
 mdsrate_inodes_available () {
-    local min_inodes=$(inodes_available)
-    echo $((min_inodes * 99 / 100))
+       local min_inodes=$(inodes_available)
+       echo $((min_inodes * 99 / 100))
 }
 
-# reset llite stat counters
-clear_llite_stats(){
-        lctl set_param -n llite.*.stats 0
+# reset stat counters
+clear_stats() {
+       local paramfile="$1"
+       lctl set_param -n $paramfile=0
 }
 
-# sum llite stat items
-calc_llite_stats() {
-       local res=$(lctl get_param -n llite.*.stats |
-               awk '/^'"$1"'/ {sum += $2} END { printf("%0.0f", sum) }')
-       echo $((res))
-}
-
-# reset osc stat counters
-clear_osc_stats(){
-       lctl set_param -n osc.*.osc_stats 0
-}
-
-# sum osc stat items
-calc_osc_stats() {
-       local res=$(lctl get_param -n osc.*.osc_stats |
-               awk '/^'"$1"'/ {sum += $2} END { printf("%0.0f", sum) }')
-       echo $((res))
+# sum stat items
+calc_stats() {
+       local paramfile="$1"
+       local stat="$2"
+       lctl get_param -n $paramfile |
+               awk '/^'$stat'/ { sum += $2 } END { printf("%0.0f", sum) }'
 }
 
 calc_sum () {
@@ -5879,8 +5869,8 @@ calc_sum () {
 }
 
 calc_osc_kbytes () {
-        df $MOUNT > /dev/null
-        $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
+       df $MOUNT > /dev/null
+       $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
 }
 
 # save_lustre_params(comma separated facet list, parameter_mask)