2013-07-24 08:35:49

by mail-agent-noreply

[permalink] [raw]
Subject: [PATCH 0/8] staging/lustre: Intel tree sync and two fixups

From: Peng Tao <[email protected]>

Hi Greg,

I've fixed up the rest of Intel tree ported patches and rebased them on top
of your staging-next. Also I found that the Lustre errno translate code breaks
build on non-x86 systems. I've added one patch to fix it. Please queue them if
they are OK to you.

Thanks,
Tao

Cc: Andreas Dilger <[email protected]>

John L. Hammond (2):
staging/lustre/llite: handle io init failure in ll_fault_io_init()
staging/lustre/obdclass: use a dummy structure for lu_ref_link

Liu Xuezhao (1):
staging/lustre/obdclass: add obd_target.h

Peng Tao (2):
staging/lustre: fix Kconfig bool defaults
staging/lustre: fix build on non-x86

Sebastien Buisson (2):
staging/lustre: fix 'data race condition' issues in at_reset()
staging/lustre/llite: fix 'data race condition' issues of lli_flags

Thomas Leibovici (1):
staging/lustre/lmv: support DNE with HSM.

drivers/staging/lustre/lustre/Kconfig | 2 +-
drivers/staging/lustre/lustre/include/cl_object.h | 10 +-
.../lustre/lustre/include/linux/lustre_fsfilt.h | 10 -
.../staging/lustre/lustre/include/lprocfs_status.h | 36 --
drivers/staging/lustre/lustre/include/lu_object.h | 18 +-
drivers/staging/lustre/lustre/include/lu_ref.h | 14 +-
.../staging/lustre/lustre/include/lustre_import.h | 2 +
drivers/staging/lustre/lustre/include/obd.h | 140 +-----
drivers/staging/lustre/lustre/llite/llite_lib.c | 4 +
drivers/staging/lustre/lustre/llite/llite_mmap.c | 36 +-
drivers/staging/lustre/lustre/llite/namei.c | 5 +-
drivers/staging/lustre/lustre/lmv/lmv_obd.c | 200 +++++++-
drivers/staging/lustre/lustre/lvfs/lvfs_linux.c | 1 -
drivers/staging/lustre/lustre/mdc/mdc_request.c | 18 +-
drivers/staging/lustre/lustre/obdclass/Makefile | 2 +-
drivers/staging/lustre/lustre/obdclass/cl_io.c | 17 +-
drivers/staging/lustre/lustre/obdclass/cl_lock.c | 6 +-
drivers/staging/lustre/lustre/obdclass/cl_page.c | 5 +-
.../lustre/lustre/obdclass/lprocfs_jobstats.c | 560 --------------------
drivers/staging/lustre/lustre/obdclass/lu_object.c | 15 +-
drivers/staging/lustre/lustre/obdclass/obd_mount.c | 1 -
drivers/staging/lustre/lustre/osc/osc_cache.c | 8 +-
drivers/staging/lustre/lustre/ptlrpc/Makefile | 2 +-
drivers/staging/lustre/lustre/ptlrpc/errno.c | 4 +-
24 files changed, 301 insertions(+), 815 deletions(-)
delete mode 100644 drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c


2013-07-24 08:35:54

by mail-agent-noreply

[permalink] [raw]
Subject: [PATCH 1/8] staging/lustre/lmv: support DNE with HSM.

From: Thomas Leibovici <[email protected]>

Send HSM requests to the appropriate MDT. Split lists of fids of HSM
actions into one list per MDT.
Move kuc registration/unregistration from MDC to LMV as this is not
MDT related.

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3365
Lustre-change: http://review.whamcloud.com/6714
Signed-off-by: Thomas Leibovici <[email protected]>
Reviewed-by: John L. Hammond <[email protected]>
Reviewed-by: jacques-Charles Lafoucriere <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: Peng Tao <[email protected]>
Signed-off-by: Andreas Dilger <[email protected]>
---
drivers/staging/lustre/lustre/lmv/lmv_obd.c | 200 ++++++++++++++++++++++-
drivers/staging/lustre/lustre/mdc/mdc_request.c | 18 +--
2 files changed, 205 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index 5bd952a..11c8d64 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -44,6 +44,7 @@
#include <asm/div64.h>
#include <linux/seq_file.h>
#include <linux/namei.h>
+#include <asm/uaccess.h>

#include <lustre/lustre_idl.h>
#include <obd_support.h>
@@ -783,6 +784,125 @@ out_fid2path:
RETURN(rc);
}

+static int lmv_hsm_req_count(struct lmv_obd *lmv,
+ const struct hsm_user_request *hur,
+ const struct lmv_tgt_desc *tgt_mds)
+{
+ int i, nr = 0;
+ struct lmv_tgt_desc *curr_tgt;
+
+ /* count how many requests must be sent to the given target */
+ for (i = 0; i < hur->hur_request.hr_itemcount; i++) {
+ curr_tgt = lmv_find_target(lmv, &hur->hur_user_item[i].hui_fid);
+ if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid))
+ nr++;
+ }
+ return nr;
+}
+
+static void lmv_hsm_req_build(struct lmv_obd *lmv,
+ struct hsm_user_request *hur_in,
+ const struct lmv_tgt_desc *tgt_mds,
+ struct hsm_user_request *hur_out)
+{
+ int i, nr_out;
+ struct lmv_tgt_desc *curr_tgt;
+
+ /* build the hsm_user_request for the given target */
+ hur_out->hur_request = hur_in->hur_request;
+ nr_out = 0;
+ for (i = 0; i < hur_in->hur_request.hr_itemcount; i++) {
+ curr_tgt = lmv_find_target(lmv,
+ &hur_in->hur_user_item[i].hui_fid);
+ if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) {
+ hur_out->hur_user_item[nr_out] =
+ hur_in->hur_user_item[i];
+ nr_out++;
+ }
+ }
+ hur_out->hur_request.hr_itemcount = nr_out;
+ memcpy(hur_data(hur_out), hur_data(hur_in),
+ hur_in->hur_request.hr_data_len);
+}
+
+static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len,
+ struct lustre_kernelcomm *lk, void *uarg)
+{
+ int i, rc = 0;
+ ENTRY;
+
+ /* unregister request (call from llapi_hsm_copytool_fini) */
+ for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
+ /* best effort: try to clean as much as possible
+ * (continue on error) */
+ obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, len, lk, uarg);
+ }
+
+ /* Whatever the result, remove copytool from kuc groups.
+ * Unreached coordinators will get EPIPE on next requests
+ * and will unregister automatically.
+ */
+ rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group);
+ RETURN(rc);
+}
+
+static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len,
+ struct lustre_kernelcomm *lk, void *uarg)
+{
+ struct file *filp;
+ int i, j, err;
+ int rc = 0;
+ bool any_set = false;
+ ENTRY;
+
+ /* All or nothing: try to register to all MDS.
+ * In case of failure, unregister from previous MDS,
+ * except if it because of inactive target. */
+ for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
+ err = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp,
+ len, lk, uarg);
+ if (err) {
+ if (lmv->tgts[i]->ltd_active) {
+ /* permanent error */
+ CERROR("error: iocontrol MDC %s on MDT"
+ "idx %d cmd %x: err = %d\n",
+ lmv->tgts[i]->ltd_uuid.uuid,
+ i, cmd, err);
+ rc = err;
+ lk->lk_flags |= LK_FLG_STOP;
+ /* unregister from previous MDS */
+ for (j = 0; j < i; j++)
+ obd_iocontrol(cmd,
+ lmv->tgts[j]->ltd_exp,
+ len, lk, uarg);
+ RETURN(rc);
+ }
+ /* else: transient error.
+ * kuc will register to the missing MDT
+ * when it is back */
+ } else {
+ any_set = true;
+ }
+ }
+
+ if (!any_set)
+ /* no registration done: return error */
+ RETURN(-ENOTCONN);
+
+ /* at least one registration done, with no failure */
+ filp = fget(lk->lk_wfd);
+ if (filp == NULL) {
+ RETURN(-EBADF);
+ }
+ rc = libcfs_kkuc_group_add(filp, lk->lk_uid, lk->lk_group, lk->lk_data);
+ if (rc != 0 && filp != NULL)
+ fput(filp);
+ RETURN(rc);
+}
+
+
+
+
static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
int len, void *karg, void *uarg)
{
@@ -908,7 +1028,77 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
}
case LL_IOC_HSM_STATE_GET:
case LL_IOC_HSM_STATE_SET:
- case LL_IOC_HSM_ACTION:
+ case LL_IOC_HSM_ACTION: {
+ struct md_op_data *op_data = karg;
+ struct lmv_tgt_desc *tgt;
+
+ tgt = lmv_find_target(lmv, &op_data->op_fid1);
+ if (IS_ERR(tgt))
+ RETURN(PTR_ERR(tgt));
+
+ if (tgt->ltd_exp == NULL)
+ RETURN(-EINVAL);
+
+ rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg);
+ break;
+ }
+ case LL_IOC_HSM_PROGRESS: {
+ const struct hsm_progress_kernel *hpk = karg;
+ struct lmv_tgt_desc *tgt;
+
+ tgt = lmv_find_target(lmv, &hpk->hpk_fid);
+ if (IS_ERR(tgt))
+ RETURN(PTR_ERR(tgt));
+ rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg);
+ break;
+ }
+ case LL_IOC_HSM_REQUEST: {
+ struct hsm_user_request *hur = karg;
+ struct lmv_tgt_desc *tgt;
+ unsigned int reqcount = hur->hur_request.hr_itemcount;
+
+ if (reqcount == 0)
+ RETURN(0);
+
+ /* if the request is about a single fid
+ * or if there is a single MDS, no need to split
+ * the request. */
+ if (reqcount == 1 || count == 1) {
+ tgt = lmv_find_target(lmv,
+ &hur->hur_user_item[0].hui_fid);
+ if (IS_ERR(tgt))
+ RETURN(PTR_ERR(tgt));
+ rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg);
+ } else {
+ /* split fid list to their respective MDS */
+ for (i = 0; i < count; i++) {
+ unsigned int nr, reqlen;
+ int rc1;
+ struct hsm_user_request *req;
+
+ nr = lmv_hsm_req_count(lmv, hur, lmv->tgts[i]);
+ if (nr == 0) /* nothing for this MDS */
+ continue;
+
+ /* build a request with fids for this MDS */
+ reqlen = offsetof(typeof(*hur),
+ hur_user_item[nr])
+ + hur->hur_request.hr_data_len;
+ OBD_ALLOC_LARGE(req, reqlen);
+ if (req == NULL)
+ RETURN(-ENOMEM);
+
+ lmv_hsm_req_build(lmv, hur, lmv->tgts[i], req);
+
+ rc1 = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp,
+ reqlen, req, uarg);
+ if (rc1 != 0 && rc == 0)
+ rc = rc1;
+ OBD_FREE_LARGE(req, reqlen);
+ }
+ }
+ break;
+ }
case LL_IOC_LOV_SWAP_LAYOUTS: {
struct md_op_data *op_data = karg;
struct lmv_tgt_desc *tgt1, *tgt2;
@@ -931,6 +1121,14 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
rc = obd_iocontrol(cmd, tgt1->ltd_exp, len, karg, uarg);
break;
}
+ case LL_IOC_HSM_CT_START: {
+ struct lustre_kernelcomm *lk = karg;
+ if (lk->lk_flags & LK_FLG_STOP)
+ rc = lmv_hsm_ct_unregister(lmv, cmd, len, lk, uarg);
+ else
+ rc = lmv_hsm_ct_register(lmv, cmd, len, lk, uarg);
+ break;
+ }
default:
for (i = 0; i < count; i++) {
struct obd_device *mdc_obd;
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index b8bf2dc..191edc6 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1771,6 +1771,9 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
GOTO(out, rc);
case LL_IOC_HSM_CT_START:
rc = mdc_ioc_hsm_ct_start(exp, karg);
+ /* ignore if it was already registered on this MDS. */
+ if (rc == -EEXIST)
+ rc = 0;
GOTO(out, rc);
case LL_IOC_HSM_PROGRESS:
rc = mdc_ioc_hsm_progress(exp, karg);
@@ -1988,19 +1991,10 @@ static int mdc_ioc_hsm_ct_start(struct obd_export *exp,
lk->lk_uid, lk->lk_group, lk->lk_flags);

if (lk->lk_flags & LK_FLG_STOP) {
- rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group);
/* Unregister with the coordinator */
- if (rc == 0)
- rc = mdc_ioc_hsm_ct_unregister(imp);
+ rc = mdc_ioc_hsm_ct_unregister(imp);
} else {
- struct file *fp = fget(lk->lk_wfd);
-
- rc = libcfs_kkuc_group_add(fp, lk->lk_uid, lk->lk_group,
- lk->lk_data);
- if (rc && fp)
- fput(fp);
- if (rc == 0)
- rc = mdc_ioc_hsm_ct_register(imp, archive);
+ rc = mdc_ioc_hsm_ct_register(imp, archive);
}

return rc;
@@ -2325,7 +2319,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
}
case IMP_EVENT_ACTIVE:
rc = obd_notify_observer(obd, obd, OBD_NOTIFY_ACTIVE, NULL);
- /* restore re-establish kuc registration after reconnecting */
+ /* redo the kuc registration after reconnecting */
if (rc == 0)
rc = mdc_kuc_reregister(imp);
break;
--
1.7.1

2013-07-24 08:36:10

by mail-agent-noreply

[permalink] [raw]
Subject: [PATCH 2/8] staging/lustre/llite: handle io init failure in ll_fault_io_init()

From: John L. Hammond <[email protected]>

In ll_fault_io_init(), if cl_io_init() has failed then cleanup and
return an ERR_PTR(). This fixes an oops in the page fault handling
code when a partially initialized io is used. In ll_page_mkwrite0() do
not call cl_io_fini() on an ERR_PTR().

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3487
Lustre-change: http://review.whamcloud.com/6735
Signed-off-by: John L. Hammond <[email protected]>
Reviewed-by: Lai Siyao <[email protected]>
Reviewed-by: Jinshan Xiong <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: Peng Tao <[email protected]>
Signed-off-by: Andreas Dilger <[email protected]>
---
drivers/staging/lustre/lustre/llite/llite_mmap.c | 36 +++++++++++++---------
1 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c
index d9590d8..8aa1dae 100644
--- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
+++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
@@ -107,11 +107,12 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma,
struct cl_env_nest *nest,
pgoff_t index, unsigned long *ra_flags)
{
- struct file *file = vma->vm_file;
- struct inode *inode = file->f_dentry->d_inode;
- struct cl_io *io;
- struct cl_fault_io *fio;
- struct lu_env *env;
+ struct file *file = vma->vm_file;
+ struct inode *inode = file->f_dentry->d_inode;
+ struct cl_io *io;
+ struct cl_fault_io *fio;
+ struct lu_env *env;
+ int rc;
ENTRY;

*env_ret = NULL;
@@ -152,17 +153,22 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma,
CDEBUG(D_MMAP, "vm_flags: %lx (%lu %d)\n", vma->vm_flags,
fio->ft_index, fio->ft_executable);

- if (cl_io_init(env, io, CIT_FAULT, io->ci_obj) == 0) {
+ rc = cl_io_init(env, io, CIT_FAULT, io->ci_obj);
+ if (rc == 0) {
struct ccc_io *cio = ccc_env_io(env);
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);

LASSERT(cio->cui_cl.cis_io == io);

- /* mmap lock must be MANDATORY
- * it has to cache pages. */
+ /* mmap lock must be MANDATORY it has to cache
+ * pages. */
io->ci_lockreq = CILR_MANDATORY;
-
- cio->cui_fd = fd;
+ cio->cui_fd = fd;
+ } else {
+ LASSERT(rc < 0);
+ cl_io_fini(env, io);
+ cl_env_nested_put(nest, env);
+ io = ERR_PTR(rc);
}

return io;
@@ -190,7 +196,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,

result = io->ci_result;
if (result < 0)
- GOTO(out, result);
+ GOTO(out_io, result);

io->u.ci_fault.ft_mkwrite = 1;
io->u.ci_fault.ft_writable = 1;
@@ -252,14 +258,14 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
}
EXIT;

-out:
+out_io:
cl_io_fini(env, io);
cl_env_nested_put(&nest, env);
-
+out:
CDEBUG(D_MMAP, "%s mkwrite with %d\n", current->comm, result);
-
LASSERT(ergo(result == 0, PageLocked(vmpage)));
- return(result);
+
+ return result;
}


--
1.7.1

2013-07-24 08:36:21

by mail-agent-noreply

[permalink] [raw]
Subject: [PATCH 6/8] staging/lustre: fix Kconfig bool defaults

From: Peng Tao <[email protected]>

Should be y instead of true.

Reported-by: Paul Bolle <[email protected]>
Cc: Andreas Dilger <[email protected]>
Signed-off-by: Peng Tao <[email protected]>
---
drivers/staging/lustre/lustre/Kconfig | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig
index 9ae7fa8..e3b3c74 100644
--- a/drivers/staging/lustre/lustre/Kconfig
+++ b/drivers/staging/lustre/lustre/Kconfig
@@ -52,4 +52,4 @@ config LUSTRE_DEBUG_EXPENSIVE_CHECK
config LUSTRE_TRANSLATE_ERRNOS
bool
depends on LUSTRE_FS && !X86
- default true
+ default y
--
1.7.1

2013-07-24 08:36:27

by mail-agent-noreply

[permalink] [raw]
Subject: [PATCH 8/8] staging/lustre: fix errno translate code on non-x86

From: Peng Tao <[email protected]>

On non-x86 we will build with Lustre's errno translate code but
it has a few issues that break build on non-x86 platforms.

Cc: Andreas Dilger <[email protected]>
Signed-off-by: Peng Tao <[email protected]>
---
drivers/staging/lustre/lustre/ptlrpc/Makefile | 2 +-
drivers/staging/lustre/lustre/ptlrpc/errno.c | 4 +---
2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/Makefile b/drivers/staging/lustre/lustre/ptlrpc/Makefile
index a379558..6d78b80 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/Makefile
+++ b/drivers/staging/lustre/lustre/ptlrpc/Makefile
@@ -16,7 +16,7 @@ ptlrpc_objs += sec.o sec_bulk.o sec_gc.o sec_config.o sec_lproc.o
ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o

ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs)
-ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.c
+ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.o

obj-$(CONFIG_PTLRPC_GSS) += gss/

diff --git a/drivers/staging/lustre/lustre/ptlrpc/errno.c b/drivers/staging/lustre/lustre/ptlrpc/errno.c
index 46e259e..1c10063 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/errno.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/errno.c
@@ -25,7 +25,7 @@
* Copyright (c) 2013, Intel Corporation.
*/

-#include <libcfs/libcfs.h>
+#include <linux/libcfs/libcfs.h>
#include <lustre/lustre_errno.h>

/*
@@ -184,7 +184,6 @@ static int lustre_errno_hton_mapping[] = {
[EBADTYPE] = LUSTRE_EBADTYPE,
[EJUKEBOX] = LUSTRE_EJUKEBOX,
[EIOCBQUEUED] = LUSTRE_EIOCBQUEUED,
- [EIOCBRETRY] = LUSTRE_EIOCBRETRY
};

static int lustre_errno_ntoh_mapping[] = {
@@ -331,7 +330,6 @@ static int lustre_errno_ntoh_mapping[] = {
[LUSTRE_EBADTYPE] = EBADTYPE,
[LUSTRE_EJUKEBOX] = EJUKEBOX,
[LUSTRE_EIOCBQUEUED] = EIOCBQUEUED,
- [LUSTRE_EIOCBRETRY] = EIOCBRETRY
};

unsigned int lustre_errno_hton(unsigned int h)
--
1.7.1

2013-07-24 08:36:19

by mail-agent-noreply

[permalink] [raw]
Subject: [PATCH 3/8] staging/lustre: fix 'data race condition' issues in at_reset()

From: Sebastien Buisson <[email protected]>

Fix 'data race condition' defects found by Coverity version
6.5.0:
Data race condition (MISSING_LOCK)
Accessing variable without holding lock. Elsewhere,
this variable is accessed with lock held.

at_reset() needs to take at->at_lock before modifying its members.

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2744
Lustre-change: http://review.whamcloud.com/6569
Signed-off-by: Sebastien Buisson <[email protected]>
Reviewed-by: Bob Glossman <[email protected]>
Reviewed-by: Keith Mannthey <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: Peng Tao <[email protected]>
Signed-off-by: Andreas Dilger <[email protected]>
---
.../staging/lustre/lustre/include/lustre_import.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h
index 3a5dd6a..67259eb 100644
--- a/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -336,9 +336,11 @@ static inline unsigned int at_timeout2est(unsigned int val)
}

static inline void at_reset(struct adaptive_timeout *at, int val) {
+ spin_lock(&at->at_lock);
at->at_current = val;
at->at_worst_ever = val;
at->at_worst_time = cfs_time_current_sec();
+ spin_unlock(&at->at_lock);
}
static inline void at_init(struct adaptive_timeout *at, int val, int flags) {
memset(at, 0, sizeof(*at));
--
1.7.1

2013-07-24 08:37:40

by mail-agent-noreply

[permalink] [raw]
Subject: [PATCH 4/8] staging/lustre/llite: fix 'data race condition' issues of lli_flags

From: Sebastien Buisson <[email protected]>

Fix 'data race condition' defects found by Coverity version
6.5.0:
Data race condition (MISSING_LOCK)
Accessing variable without holding lock. Elsewhere,
this variable is accessed with lock held.

lli->lli_flags need to be protected by lli->lli_lock.

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2744
Lustre-change: http://review.whamcloud.com/6571
Signed-off-by: Sebastien Buisson <[email protected]>
Reviewed-by: Fan Yong <[email protected]>
Reviewed-by: Keith Mannthey <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: Peng Tao <[email protected]>
Signed-off-by: Andreas Dilger <[email protected]>
---
drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ++++
drivers/staging/lustre/lustre/llite/namei.c | 5 ++++-
2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index d7d87b1..36a07fa 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1190,7 +1190,9 @@ void ll_clear_inode(struct inode *inode)
LASSERT(lli->lli_opendir_pid == 0);
}

+ spin_lock(&lli->lli_lock);
ll_i2info(inode)->lli_flags &= ~LLIF_MDS_SIZE_LOCK;
+ spin_unlock(&lli->lli_lock);
md_null_inode(sbi->ll_md_exp, ll_inode2fid(inode));

LASSERT(!lli->lli_open_fd_write_count);
@@ -1757,7 +1759,9 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
/* Use old size assignment to avoid
* deadlock bz14138 & bz14326 */
i_size_write(inode, body->size);
+ spin_lock(&lli->lli_lock);
lli->lli_flags |= LLIF_MDS_SIZE_LOCK;
+ spin_unlock(&lli->lli_lock);
}
ldlm_lock_decref(&lockh, mode);
}
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 8e948a7..333e55f 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -275,8 +275,11 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
CDEBUG(D_INODE, "invaliding layout %d.\n", rc);
}

- if (bits & MDS_INODELOCK_UPDATE)
+ if (bits & MDS_INODELOCK_UPDATE) {
+ spin_lock(&lli->lli_lock);
lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK;
+ spin_unlock(&lli->lli_lock);
+ }

if (S_ISDIR(inode->i_mode) &&
(bits & MDS_INODELOCK_UPDATE)) {
--
1.7.1

2013-07-24 08:37:37

by mail-agent-noreply

[permalink] [raw]
Subject: [PATCH 5/8] staging/lustre/obdclass: add obd_target.h

From: Liu Xuezhao <[email protected]>

Move some server-side data structures form obd.h to obd_target.h. To
remove some code dependencies use HAVE_SERVER_SUPPORT to protect some
llog/fsfilt_* functions.

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1330
Lustre-change: http://review.whamcloud.com/2678
Signed-off-by: Liu Xuezhao <[email protected]>
Signed-off-by: John L. Hammond <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
Reviewed-by: Peng Tao <[email protected]>
Reviewed-by: Mike Pershin <[email protected]>
Signed-off-by: Peng Tao <[email protected]>
Signed-off-by: Andreas Dilger <[email protected]>
---
.../lustre/lustre/include/linux/lustre_fsfilt.h | 10 -
.../staging/lustre/lustre/include/lprocfs_status.h | 36 --
drivers/staging/lustre/lustre/include/obd.h | 140 +-----
drivers/staging/lustre/lustre/lvfs/lvfs_linux.c | 1 -
drivers/staging/lustre/lustre/obdclass/Makefile | 2 +-
.../lustre/lustre/obdclass/lprocfs_jobstats.c | 560 --------------------
drivers/staging/lustre/lustre/obdclass/obd_mount.c | 1 -
7 files changed, 3 insertions(+), 747 deletions(-)
delete mode 100644 drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c

diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h b/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h
index 6c72609..e637006 100644
--- a/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h
+++ b/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h
@@ -145,16 +145,6 @@ static inline int fsfilt_commit(struct obd_device *obd, struct inode *inode,
return rc;
}

-static inline int fsfilt_map_inode_pages(struct obd_device *obd,
- struct inode *inode,
- struct page **page, int pages,
- unsigned long *blocks,
- int create, struct mutex *mutex)
-{
- return obd->obd_fsops->fs_map_inode_pages(inode, page, pages, blocks,
- create, mutex);
-}
-
static inline int fsfilt_read_record(struct obd_device *obd, struct file *file,
void *buf, loff_t size, loff_t *offs)
{
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index 7a05364..d7f1be9 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -370,18 +370,6 @@ static inline void s2dhms(struct dhms *ts, time_t secs)
#define JOBSTATS_DISABLE "disable"
#define JOBSTATS_PROCNAME_UID "procname_uid"

-typedef void (*cntr_init_callback)(struct lprocfs_stats *stats);
-
-struct obd_job_stats {
- cfs_hash_t *ojs_hash;
- struct list_head ojs_list;
- rwlock_t ojs_lock; /* protect the obj_list */
- cntr_init_callback ojs_cntr_init_fn;
- int ojs_cntr_num;
- int ojs_cleanup_interval;
- time_t ojs_last_cleanup;
-};
-
#ifdef LPROCFS

extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
@@ -748,16 +736,6 @@ struct file_operations name##_fops = { \
.release = lprocfs_single_release, \
};

-/* lprocfs_jobstats.c */
-int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
- int event, long amount);
-void lprocfs_job_stats_fini(struct obd_device *obd);
-int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
- cntr_init_callback fn);
-int lprocfs_rd_job_interval(struct seq_file *m, void *data);
-int lprocfs_wr_job_interval(struct file *file, const char *buffer,
- unsigned long count, void *data);
-
/* lproc_ptlrpc.c */
struct ptlrpc_request;
extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
@@ -1018,20 +996,6 @@ __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
#define LPROC_SEQ_FOPS_RW_TYPE(name, type)
#define LPROC_SEQ_FOPS_WR_ONLY(name, type)

-/* lprocfs_jobstats.c */
-static inline
-int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event,
- long amount)
-{ return 0; }
-static inline
-void lprocfs_job_stats_fini(struct obd_device *obd)
-{ return; }
-static inline
-int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
- cntr_init_callback fn)
-{ return 0; }
-
-
/* lproc_ptlrpc.c */
#define target_print_req NULL

diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index 797a6af..094eb96 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -49,6 +49,8 @@
#define IOC_MDC_MAX_NR 50

#include <lustre/lustre_idl.h>
+#include <lustre_lib.h>
+#include <linux/libcfs/bitmap.h>
#include <lu_ref.h>
#include <lustre_lib.h>
#include <lustre_export.h>
@@ -56,9 +58,6 @@
#include <lustre_fld.h>
#include <lustre_capa.h>

-#include <linux/libcfs/bitmap.h>
-
-
#define MAX_OBD_DEVICES 8192

struct osc_async_rc {
@@ -254,30 +253,6 @@ struct brw_page {
obd_flag flag;
};

-/* Individual type definitions */
-
-struct ost_server_data;
-
-struct osd_properties {
- size_t osd_max_ea_size;
-};
-
-#define OBT_MAGIC 0xBDDECEAE
-/* hold common fields for "target" device */
-struct obd_device_target {
- __u32 obt_magic;
- __u32 obt_instance;
- struct super_block *obt_sb;
- /** last_rcvd file */
- struct file *obt_rcvd_filp;
- __u64 obt_mount_count;
- struct rw_semaphore obt_rwsem;
- struct vfsmount *obt_vfsmnt;
- struct file *obt_health_check_filp;
- struct osd_properties obt_osd_properties;
- struct obd_job_stats obt_jobstats;
-};
-
/* llog contexts */
enum llog_ctxt_id {
LLOG_CONFIG_ORIG_CTXT = 0,
@@ -299,94 +274,6 @@ enum llog_ctxt_id {
LLOG_MAX_CTXTS
};

-#define FILTER_SUBDIR_COUNT 32 /* set to zero for no subdirs */
-
-struct filter_subdirs {
- struct dentry *dentry[FILTER_SUBDIR_COUNT];
-};
-
-
-struct filter_ext {
- __u64 fe_start;
- __u64 fe_end;
-};
-
-struct filter_obd {
- /* NB this field MUST be first */
- struct obd_device_target fo_obt;
- const char *fo_fstype;
-
- int fo_group_count;
- struct dentry *fo_dentry_O;
- struct dentry **fo_dentry_O_groups;
- struct filter_subdirs *fo_dentry_O_sub;
- struct mutex fo_init_lock; /* group initialization lock*/
- int fo_committed_group;
-
- spinlock_t fo_objidlock; /* protect fo_lastobjid */
-
- unsigned long fo_destroys_in_progress;
- struct mutex fo_create_locks[FILTER_SUBDIR_COUNT];
-
- struct list_head fo_export_list;
- int fo_subdir_count;
-
- obd_size fo_tot_dirty; /* protected by obd_osfs_lock */
- obd_size fo_tot_granted; /* all values in bytes */
- obd_size fo_tot_pending;
- int fo_tot_granted_clients;
-
- obd_size fo_readcache_max_filesize;
- spinlock_t fo_flags_lock;
- unsigned int fo_read_cache:1, /**< enable read-only cache */
- fo_writethrough_cache:1,/**< read cache writes */
- fo_mds_ost_sync:1, /**< MDS-OST orphan recovery*/
- fo_raid_degraded:1;/**< RAID device degraded */
-
- struct obd_import *fo_mdc_imp;
- struct obd_uuid fo_mdc_uuid;
- struct lustre_handle fo_mdc_conn;
- struct file **fo_last_objid_files;
- __u64 *fo_last_objids; /* last created objid for groups,
- * protected by fo_objidlock */
-
- struct mutex fo_alloc_lock;
-
- atomic_t fo_r_in_flight;
- atomic_t fo_w_in_flight;
-
- /*
- * per-filter pool of kiobuf's allocated by filter_common_setup() and
- * torn down by filter_cleanup().
- *
- * This pool contains kiobuf used by
- * filter_{prep,commit}rw_{read,write}() and is shared by all OST
- * threads.
- *
- * Locking: protected by internal lock of cfs_hash, pool can be
- * found from this hash table by t_id of ptlrpc_thread.
- */
- struct cfs_hash *fo_iobuf_hash;
-
- struct brw_stats fo_filter_stats;
-
- int fo_fmd_max_num; /* per exp filter_mod_data */
- int fo_fmd_max_age; /* jiffies to fmd expiry */
- unsigned long fo_syncjournal:1, /* sync journal on writes */
- fo_sync_lock_cancel:2;/* sync on lock cancel */
-
-
- /* sptlrpc stuff */
- rwlock_t fo_sptlrpc_lock;
- struct sptlrpc_rule_set fo_sptlrpc_rset;
-
- /* capability related */
- unsigned int fo_fl_oss_capa;
- struct list_head fo_capa_keys;
- struct hlist_head *fo_capa_hash;
- int fo_sec_level;
-};
-
struct timeout_item {
enum timeout_event ti_event;
cfs_time_t ti_timeout;
@@ -552,25 +439,6 @@ struct obd_id_info {
obd_id *data;
};

-/* */
-
-struct echo_obd {
- struct obd_device_target eo_obt;
- struct obdo eo_oa;
- spinlock_t eo_lock;
- __u64 eo_lastino;
- struct lustre_handle eo_nl_lock;
- atomic_t eo_prep;
-};
-
-struct ost_obd {
- struct ptlrpc_service *ost_service;
- struct ptlrpc_service *ost_create_service;
- struct ptlrpc_service *ost_io_service;
- struct ptlrpc_service *ost_seq_service;
- struct mutex ost_health_mutex;
-};
-
struct echo_client_obd {
struct obd_export *ec_exp; /* the local connection to osc/lov */
spinlock_t ec_lock;
@@ -1052,12 +920,8 @@ struct obd_device {
int obd_recovery_stage;

union {
- struct obd_device_target obt;
- struct filter_obd filter;
struct client_obd cli;
- struct ost_obd ost;
struct echo_client_obd echo_client;
- struct echo_obd echo;
struct lov_obd lov;
struct lmv_obd lmv;
} u;
diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c
index e70d8fe..8bfae01 100644
--- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c
+++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c
@@ -48,7 +48,6 @@
#include <linux/quotaops.h>
#include <linux/version.h>
#include <linux/libcfs/libcfs.h>
-#include <lustre_fsfilt.h>
#include <obd.h>
#include <linux/module.h>
#include <linux/init.h>
diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile
index b80c13c..8a0e08c 100644
--- a/drivers/staging/lustre/lustre/obdclass/Makefile
+++ b/drivers/staging/lustre/lustre/obdclass/Makefile
@@ -3,7 +3,7 @@ obj-$(CONFIG_LUSTRE_FS) += obdclass.o llog_test.o
obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \
llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \
genops.o uuid.o llog_ioctl.o lprocfs_status.o \
- lprocfs_jobstats.o lustre_handles.o lustre_peer.o llog_osd.o \
+ lustre_handles.o lustre_peer.o llog_osd.o \
local_storage.o statfs_pack.o obdo.o obd_config.o obd_mount.o\
mea.o lu_object.o dt_object.o capa.o cl_object.o \
cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o idmap.o \
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c
deleted file mode 100644
index 7f6072c..0000000
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c
+++ /dev/null
@@ -1,560 +0,0 @@
-/* GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2011, 2012, Intel Corporation.
- * Use is subject to license terms.
- *
- * Author: Niu Yawei <[email protected]>
- */
-/*
- * lustre/obdclass/lprocfs_jobstats.c
- */
-
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
-#define DEBUG_SUBSYSTEM S_CLASS
-
-
-#include <obd_class.h>
-#include <lprocfs_status.h>
-#include <lustre/lustre_idl.h>
-
-#if defined(LPROCFS)
-
-/*
- * JobID formats & JobID environment variable names for supported
- * job schedulers:
- *
- * SLURM:
- * JobID format: 32 bit integer.
- * JobID env var: SLURM_JOB_ID.
- * SGE:
- * JobID format: Decimal integer range to 99999.
- * JobID env var: JOB_ID.
- * LSF:
- * JobID format: 6 digit integer by default (up to 999999), can be
- * increased to 10 digit (up to 2147483646).
- * JobID env var: LSB_JOBID.
- * Loadleveler:
- * JobID format: String of machine_name.cluster_id.process_id, for
- * example: fr2n02.32.0
- * JobID env var: LOADL_STEP_ID.
- * PBS:
- * JobID format: String of sequence_number[.server_name][@server].
- * JobID env var: PBS_JOBID.
- * Maui/MOAB:
- * JobID format: Same as PBS.
- * JobID env var: Same as PBS.
- */
-
-struct job_stat {
- struct hlist_node js_hash;
- struct list_head js_list;
- atomic_t js_refcount;
- char js_jobid[JOBSTATS_JOBID_SIZE];
- time_t js_timestamp; /* seconds */
- struct lprocfs_stats *js_stats;
- struct obd_job_stats *js_jobstats;
-};
-
-static unsigned job_stat_hash(cfs_hash_t *hs, const void *key, unsigned mask)
-{
- return cfs_hash_djb2_hash(key, strlen(key), mask);
-}
-
-static void *job_stat_key(struct hlist_node *hnode)
-{
- struct job_stat *job;
- job = hlist_entry(hnode, struct job_stat, js_hash);
- return job->js_jobid;
-}
-
-static int job_stat_keycmp(const void *key, struct hlist_node *hnode)
-{
- struct job_stat *job;
- job = hlist_entry(hnode, struct job_stat, js_hash);
- return (strlen(job->js_jobid) == strlen(key)) &&
- !strncmp(job->js_jobid, key, strlen(key));
-}
-
-static void *job_stat_object(struct hlist_node *hnode)
-{
- return hlist_entry(hnode, struct job_stat, js_hash);
-}
-
-static void job_stat_get(cfs_hash_t *hs, struct hlist_node *hnode)
-{
- struct job_stat *job;
- job = hlist_entry(hnode, struct job_stat, js_hash);
- atomic_inc(&job->js_refcount);
-}
-
-static void job_free(struct job_stat *job)
-{
- LASSERT(atomic_read(&job->js_refcount) == 0);
- LASSERT(job->js_jobstats);
-
- write_lock(&job->js_jobstats->ojs_lock);
- list_del_init(&job->js_list);
- write_unlock(&job->js_jobstats->ojs_lock);
-
- lprocfs_free_stats(&job->js_stats);
- OBD_FREE_PTR(job);
-}
-
-static void job_putref(struct job_stat *job)
-{
- LASSERT(atomic_read(&job->js_refcount) > 0);
- if (atomic_dec_and_test(&job->js_refcount))
- job_free(job);
-}
-
-static void job_stat_put_locked(cfs_hash_t *hs, struct hlist_node *hnode)
-{
- struct job_stat *job;
- job = hlist_entry(hnode, struct job_stat, js_hash);
- job_putref(job);
-}
-
-static void job_stat_exit(cfs_hash_t *hs, struct hlist_node *hnode)
-{
- CERROR("Should not have any items!");
-}
-
-static cfs_hash_ops_t job_stats_hash_ops = {
- .hs_hash = job_stat_hash,
- .hs_key = job_stat_key,
- .hs_keycmp = job_stat_keycmp,
- .hs_object = job_stat_object,
- .hs_get = job_stat_get,
- .hs_put_locked = job_stat_put_locked,
- .hs_exit = job_stat_exit,
-};
-
-static int job_iter_callback(cfs_hash_t *hs, cfs_hash_bd_t *bd,
- struct hlist_node *hnode, void *data)
-{
- time_t oldest = *((time_t *)data);
- struct job_stat *job;
-
- job = hlist_entry(hnode, struct job_stat, js_hash);
- if (!oldest || job->js_timestamp < oldest)
- cfs_hash_bd_del_locked(hs, bd, hnode);
-
- return 0;
-}
-
-static void lprocfs_job_cleanup(struct obd_job_stats *stats, bool force)
-{
- time_t oldest, now;
-
- if (stats->ojs_cleanup_interval == 0)
- return;
-
- now = cfs_time_current_sec();
- if (!force && now < stats->ojs_last_cleanup +
- stats->ojs_cleanup_interval)
- return;
-
- oldest = now - stats->ojs_cleanup_interval;
- cfs_hash_for_each_safe(stats->ojs_hash, job_iter_callback,
- &oldest);
- stats->ojs_last_cleanup = cfs_time_current_sec();
-}
-
-static struct job_stat *job_alloc(char *jobid, struct obd_job_stats *jobs)
-{
- struct job_stat *job;
-
- LASSERT(jobs->ojs_cntr_num && jobs->ojs_cntr_init_fn);
-
- OBD_ALLOC_PTR(job);
- if (job == NULL)
- return NULL;
-
- job->js_stats = lprocfs_alloc_stats(jobs->ojs_cntr_num, 0);
- if (job->js_stats == NULL) {
- OBD_FREE_PTR(job);
- return NULL;
- }
-
- jobs->ojs_cntr_init_fn(job->js_stats);
-
- memcpy(job->js_jobid, jobid, JOBSTATS_JOBID_SIZE);
- job->js_timestamp = cfs_time_current_sec();
- job->js_jobstats = jobs;
- INIT_HLIST_NODE(&job->js_hash);
- INIT_LIST_HEAD(&job->js_list);
- atomic_set(&job->js_refcount, 1);
-
- return job;
-}
-
-int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
- int event, long amount)
-{
- struct obd_job_stats *stats = &obd->u.obt.obt_jobstats;
- struct job_stat *job, *job2;
- ENTRY;
-
- LASSERT(stats && stats->ojs_hash);
-
- lprocfs_job_cleanup(stats, false);
-
- if (!jobid || !strlen(jobid))
- RETURN(-EINVAL);
-
- if (strlen(jobid) >= JOBSTATS_JOBID_SIZE) {
- CERROR("Invalid jobid size (%lu), expect(%d)\n",
- (unsigned long)strlen(jobid) + 1, JOBSTATS_JOBID_SIZE);
- RETURN(-EINVAL);
- }
-
- job = cfs_hash_lookup(stats->ojs_hash, jobid);
- if (job)
- goto found;
-
- job = job_alloc(jobid, stats);
- if (job == NULL)
- RETURN(-ENOMEM);
-
- job2 = cfs_hash_findadd_unique(stats->ojs_hash, job->js_jobid,
- &job->js_hash);
- if (job2 != job) {
- job_putref(job);
- job = job2;
- /* We cannot LASSERT(!list_empty(&job->js_list)) here,
- * since we just lost the race for inserting "job" into the
- * ojs_list, and some other thread is doing it _right_now_.
- * Instead, be content the other thread is doing this, since
- * "job2" was initialized in job_alloc() already. LU-2163 */
- } else {
- LASSERT(list_empty(&job->js_list));
- write_lock(&stats->ojs_lock);
- list_add_tail(&job->js_list, &stats->ojs_list);
- write_unlock(&stats->ojs_lock);
- }
-
-found:
- LASSERT(stats == job->js_jobstats);
- LASSERT(stats->ojs_cntr_num > event);
- job->js_timestamp = cfs_time_current_sec();
- lprocfs_counter_add(job->js_stats, event, amount);
-
- job_putref(job);
- RETURN(0);
-}
-EXPORT_SYMBOL(lprocfs_job_stats_log);
-
-void lprocfs_job_stats_fini(struct obd_device *obd)
-{
- struct obd_job_stats *stats = &obd->u.obt.obt_jobstats;
- time_t oldest = 0;
-
- if (stats->ojs_hash == NULL)
- return;
- cfs_hash_for_each_safe(stats->ojs_hash, job_iter_callback, &oldest);
- cfs_hash_putref(stats->ojs_hash);
- stats->ojs_hash = NULL;
- LASSERT(list_empty(&stats->ojs_list));
-}
-EXPORT_SYMBOL(lprocfs_job_stats_fini);
-
-static void *lprocfs_jobstats_seq_start(struct seq_file *p, loff_t *pos)
-{
- struct obd_job_stats *stats = p->private;
- loff_t off = *pos;
- struct job_stat *job;
-
- read_lock(&stats->ojs_lock);
- if (off == 0)
- return SEQ_START_TOKEN;
- off--;
- list_for_each_entry(job, &stats->ojs_list, js_list) {
- if (!off--)
- return job;
- }
- return NULL;
-}
-
-static void lprocfs_jobstats_seq_stop(struct seq_file *p, void *v)
-{
- struct obd_job_stats *stats = p->private;
-
- read_unlock(&stats->ojs_lock);
-}
-
-static void *lprocfs_jobstats_seq_next(struct seq_file *p, void *v, loff_t *pos)
-{
- struct obd_job_stats *stats = p->private;
- struct job_stat *job;
- struct list_head *next;
-
- ++*pos;
- if (v == SEQ_START_TOKEN) {
- next = stats->ojs_list.next;
- } else {
- job = (struct job_stat *)v;
- next = job->js_list.next;
- }
-
- return next == &stats->ojs_list ? NULL :
- list_entry(next, struct job_stat, js_list);
-}
-
-/*
- * Example of output on MDT:
- *
- * job_stats:
- * - job_id: test_id.222.25844
- * snapshot_time: 1322494486
- * open: { samples: 3, unit: reqs }
- * close: { samples: 3, unit: reqs }
- * mknod: { samples: 0, unit: reqs }
- * link: { samples: 0, unit: reqs }
- * unlink: { samples: 0, unit: reqs }
- * mkdir: { samples: 0, unit: reqs }
- * rmdir: { samples: 0, unit: reqs }
- * rename: { samples: 1, unit: reqs }
- * getattr: { samples: 7, unit: reqs }
- * setattr: { samples: 0, unit: reqs }
- * getxattr: { samples: 0, unit: reqs }
- * setxattr: { samples: 0, unit: reqs }
- * statfs: { samples: 0, unit: reqs }
- * sync: { samples: 0, unit: reqs }
- *
- * Example of output on OST:
- *
- * job_stats:
- * - job_id 4854
- * snapshot_time: 1322494602
- * read: { samples: 0, unit: bytes, min: 0, max: 0, sum: 0 }
- * write: { samples: 1, unit: bytes, min: 10, max: 10, sum: 10 }
- * setattr: { samples: 0, unit: reqs }
- * punch: { samples: 0, unit: reqs }
- * sync: { samples: 0, unit: reqs }
- */
-
-static const char spaces[] = " ";
-
-static int inline width(const char *str, int len)
-{
- return len - min((int)strlen(str), 15);
-}
-
-static int lprocfs_jobstats_seq_show(struct seq_file *p, void *v)
-{
- struct job_stat *job = v;
- struct lprocfs_stats *s;
- struct lprocfs_counter ret;
- struct lprocfs_counter_header *cntr_header;
- int i;
-
- if (v == SEQ_START_TOKEN) {
- seq_printf(p, "job_stats:\n");
- return 0;
- }
-
- seq_printf(p, "- %-16s %s\n", "job_id:", job->js_jobid);
- seq_printf(p, " %-16s %ld\n", "snapshot_time:", job->js_timestamp);
-
- s = job->js_stats;
- for (i = 0; i < s->ls_num; i++) {
- cntr_header = &s->ls_cnt_header[i];
- lprocfs_stats_collect(s, i, &ret);
-
- seq_printf(p, " %s:%.*s { samples: %11"LPF64"u",
- cntr_header->lc_name,
- width(cntr_header->lc_name, 15), spaces,
- ret.lc_count);
- if (cntr_header->lc_units[0] != '\0')
- seq_printf(p, ", unit: %5s", cntr_header->lc_units);
-
- if (cntr_header->lc_config & LPROCFS_CNTR_AVGMINMAX) {
- seq_printf(p, ", min:%8"LPF64"u, max:%8"LPF64"u,"
- " sum:%16"LPF64"u",
- ret.lc_count ? ret.lc_min : 0,
- ret.lc_count ? ret.lc_max : 0,
- ret.lc_count ? ret.lc_sum : 0);
- }
- if (cntr_header->lc_config & LPROCFS_CNTR_STDDEV) {
- seq_printf(p, ", sumsq: %18"LPF64"u",
- ret.lc_count ? ret.lc_sumsquare : 0);
- }
-
- seq_printf(p, " }\n");
-
- }
- return 0;
-}
-
-struct seq_operations lprocfs_jobstats_seq_sops = {
- start: lprocfs_jobstats_seq_start,
- stop: lprocfs_jobstats_seq_stop,
- next: lprocfs_jobstats_seq_next,
- show: lprocfs_jobstats_seq_show,
-};
-
-static int lprocfs_jobstats_seq_open(struct inode *inode, struct file *file)
-{
- struct seq_file *seq;
- int rc;
-
- rc = seq_open(file, &lprocfs_jobstats_seq_sops);
- if (rc)
- return rc;
- seq = file->private_data;
- seq->private = PDE_DATA(inode);
- return 0;
-}
-
-static ssize_t lprocfs_jobstats_seq_write(struct file *file, const char *buf,
- size_t len, loff_t *off)
-{
- struct seq_file *seq = file->private_data;
- struct obd_job_stats *stats = seq->private;
- char jobid[JOBSTATS_JOBID_SIZE];
- int all = 0;
- struct job_stat *job;
-
- if (!memcmp(buf, "clear", strlen("clear"))) {
- all = 1;
- } else if (len < JOBSTATS_JOBID_SIZE) {
- memset(jobid, 0, JOBSTATS_JOBID_SIZE);
- /* Trim '\n' if any */
- if (buf[len - 1] == '\n')
- memcpy(jobid, buf, len - 1);
- else
- memcpy(jobid, buf, len);
- } else {
- return -EINVAL;
- }
-
- LASSERT(stats->ojs_hash);
- if (all) {
- time_t oldest = 0;
- cfs_hash_for_each_safe(stats->ojs_hash, job_iter_callback,
- &oldest);
- return len;
- }
-
- if (!strlen(jobid))
- return -EINVAL;
-
- job = cfs_hash_lookup(stats->ojs_hash, jobid);
- if (!job)
- return -EINVAL;
-
- cfs_hash_del_key(stats->ojs_hash, jobid);
-
- job_putref(job);
- return len;
-}
-
-struct file_operations lprocfs_jobstats_seq_fops = {
- .owner = THIS_MODULE,
- .open = lprocfs_jobstats_seq_open,
- .read = seq_read,
- .write = lprocfs_jobstats_seq_write,
- .llseek = seq_lseek,
- .release = lprocfs_seq_release,
-};
-
-int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
- cntr_init_callback init_fn)
-{
- struct proc_dir_entry *entry;
- struct obd_job_stats *stats;
- ENTRY;
-
- LASSERT(obd->obd_proc_entry != NULL);
- LASSERT(obd->obd_type->typ_name);
-
- if (strcmp(obd->obd_type->typ_name, LUSTRE_MDT_NAME) &&
- strcmp(obd->obd_type->typ_name, LUSTRE_OST_NAME)) {
- CERROR("Invalid obd device type.\n");
- RETURN(-EINVAL);
- }
- stats = &obd->u.obt.obt_jobstats;
-
- LASSERT(stats->ojs_hash == NULL);
- stats->ojs_hash = cfs_hash_create("JOB_STATS",
- HASH_JOB_STATS_CUR_BITS,
- HASH_JOB_STATS_MAX_BITS,
- HASH_JOB_STATS_BKT_BITS, 0,
- CFS_HASH_MIN_THETA,
- CFS_HASH_MAX_THETA,
- &job_stats_hash_ops,
- CFS_HASH_DEFAULT);
- if (stats->ojs_hash == NULL)
- RETURN(-ENOMEM);
-
- INIT_LIST_HEAD(&stats->ojs_list);
- rwlock_init(&stats->ojs_lock);
- stats->ojs_cntr_num = cntr_num;
- stats->ojs_cntr_init_fn = init_fn;
- stats->ojs_cleanup_interval = 600; /* 10 mins by default */
- stats->ojs_last_cleanup = cfs_time_current_sec();
-
- entry = proc_create_data("job_stats", 0644, obd->obd_proc_entry,
- &lprocfs_jobstats_seq_fops, stats);
- if (entry)
- RETURN(0);
- else
- RETURN(-ENOMEM);
-}
-EXPORT_SYMBOL(lprocfs_job_stats_init);
-
-int lprocfs_rd_job_interval(struct seq_file *m, void *data)
-{
- struct obd_device *obd = (struct obd_device *)data;
- struct obd_job_stats *stats;
-
- LASSERT(obd != NULL);
- stats = &obd->u.obt.obt_jobstats;
- return seq_printf(m, "%d\n", stats->ojs_cleanup_interval);
-}
-EXPORT_SYMBOL(lprocfs_rd_job_interval);
-
-int lprocfs_wr_job_interval(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- struct obd_device *obd = (struct obd_device *)data;
- struct obd_job_stats *stats;
- int val, rc;
-
- LASSERT(obd != NULL);
- stats = &obd->u.obt.obt_jobstats;
-
- rc = lprocfs_write_helper(buffer, count, &val);
- if (rc)
- return rc;
-
- stats->ojs_cleanup_interval = val;
- lprocfs_job_cleanup(stats, true);
-
- return count;
-
-}
-EXPORT_SYMBOL(lprocfs_wr_job_interval);
-
-#endif /* LPROCFS*/
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
index f5585cc..2cc6a26 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
@@ -47,7 +47,6 @@

#include <obd.h>
#include <lvfs.h>
-#include <lustre_fsfilt.h>
#include <obd_class.h>
#include <lustre/lustre_user.h>
#include <linux/version.h>
--
1.7.1

2013-07-24 08:37:36

by mail-agent-noreply

[permalink] [raw]
Subject: [PATCH 7/8] staging/lustre/obdclass: use a dummy structure for lu_ref_link

From: John L. Hammond <[email protected]>

Move the definition of struct lu_ref_link to lu_ref.h. If USE_LU_REF
is not defined then define it to be the empty struct. Change the
return type of lu_ref_add() and lu_ref_add_atomic() to void. Add
lu_ref_add_at() taking same arguments as lu_ref_add() togerther with a
pointer to a struct lu_ref_link and returning void. Adjust all
structures containing a lu_ref_link pointer to contain a struct
lu_ref_link instead. Use lu_ref_add_at() and lu_ref_del_at() to
handle embedded lu_ref_links.

[Original patch mainly changes lu_ref.[ch] but in upstream client we don't
have lu_ref code in the hope of moving to kobject refcounting. So the patch
only picks the other pieces of original patch, in order to keep code in
sync and make it easier to port future patches.]

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3059
Lustre-change: http://review.whamcloud.com/5920
Signed-off-by: John L. Hammond <[email protected]>
Reviewed-by: Alex Zhuravlev <[email protected]>
Reviewed-by: Jinshan Xiong <[email protected]>
Reviewed-by: Mike Pershin <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: Peng Tao <[email protected]>
Signed-off-by: Andreas Dilger <[email protected]>
---
drivers/staging/lustre/lustre/include/cl_object.h | 10 +++++-----
drivers/staging/lustre/lustre/include/lu_object.h | 18 +++++++++++++-----
drivers/staging/lustre/lustre/include/lu_ref.h | 14 +++++++++++++-
drivers/staging/lustre/lustre/obdclass/cl_io.c | 17 +++++++++--------
drivers/staging/lustre/lustre/obdclass/cl_lock.c | 6 +++---
drivers/staging/lustre/lustre/obdclass/cl_page.c | 5 +++--
drivers/staging/lustre/lustre/obdclass/lu_object.c | 15 ++++++++-------
drivers/staging/lustre/lustre/osc/osc_cache.c | 8 +++++---
8 files changed, 59 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h
index 4bb6880..4a47850 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -768,11 +768,11 @@ struct cl_page {
/** List of references to this page, for debugging. */
struct lu_ref cp_reference;
/** Link to an object, for debugging. */
- struct lu_ref_link *cp_obj_ref;
+ struct lu_ref_link cp_obj_ref;
/** Link to a queue, for debugging. */
- struct lu_ref_link *cp_queue_ref;
+ struct lu_ref_link cp_queue_ref;
/** Per-page flags from enum cl_page_flags. Protected by a VM lock. */
- unsigned cp_flags;
+ unsigned cp_flags;
/** Assigned if doing a sync_io */
struct cl_sync_io *cp_sync_io;
};
@@ -1625,7 +1625,7 @@ struct cl_lock {
/**
* A reference for cl_lock::cll_descr::cld_obj. For debugging.
*/
- struct lu_ref_link *cll_obj_ref;
+ struct lu_ref_link cll_obj_ref;
#ifdef CONFIG_LOCKDEP
/* "dep_map" name is assumed by lockdep.h macros. */
struct lockdep_map dep_map;
@@ -2517,7 +2517,7 @@ struct cl_req_obj {
/** object itself */
struct cl_object *ro_obj;
/** reference to cl_req_obj::ro_obj. For debugging. */
- struct lu_ref_link *ro_obj_ref;
+ struct lu_ref_link ro_obj_ref;
/* something else? Number of pages for a given object? */
};

diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h
index 9476048..8077898 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -496,7 +496,7 @@ struct lu_object {
/**
* Link to the device, for debugging.
*/
- struct lu_ref_link *lo_dev_ref;
+ struct lu_ref_link lo_dev_ref;
};

enum lu_object_header_flags {
@@ -873,11 +873,19 @@ static inline __u32 lu_object_attr(const struct lu_object *o)
return o->lo_header->loh_attr;
}

-static inline struct lu_ref_link *lu_object_ref_add(struct lu_object *o,
- const char *scope,
- const void *source)
+static inline void lu_object_ref_add(struct lu_object *o,
+ const char *scope,
+ const void *source)
{
- return lu_ref_add(&o->lo_header->loh_reference, scope, source);
+ lu_ref_add(&o->lo_header->loh_reference, scope, source);
+}
+
+static inline void lu_object_ref_add_at(struct lu_object *o,
+ struct lu_ref_link *link,
+ const char *scope,
+ const void *source)
+{
+ lu_ref_add_at(&o->lo_header->loh_reference, link, scope, source);
}

static inline void lu_object_ref_del(struct lu_object *o,
diff --git a/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h
index 624c19b..50a2a7f 100644
--- a/drivers/staging/lustre/lustre/include/lu_ref.h
+++ b/drivers/staging/lustre/lustre/include/lu_ref.h
@@ -108,7 +108,12 @@
*/


-struct lu_ref {};
+/*
+ * dummy data structures/functions to pass compile for now.
+ * We need to reimplement them with kref.
+ */
+struct lu_ref {};
+struct lu_ref_link {};

static inline void lu_ref_init(struct lu_ref *ref)
{
@@ -132,6 +137,13 @@ static inline struct lu_ref_link *lu_ref_add_atomic(struct lu_ref *ref,
return NULL;
}

+static inline void lu_ref_add_at(struct lu_ref *ref,
+ struct lu_ref_link *link,
+ const char *scope,
+ const void *source)
+{
+}
+
static inline void lu_ref_del(struct lu_ref *ref, const char *scope,
const void *source)
{
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c
index 75c9be8..f3f0315 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_io.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c
@@ -1105,7 +1105,7 @@ void cl_page_list_add(struct cl_page_list *plist, struct cl_page *page)
LASSERT(list_empty(&page->cp_batch));
list_add_tail(&page->cp_batch, &plist->pl_pages);
++plist->pl_nr;
- page->cp_queue_ref = lu_ref_add(&page->cp_reference, "queue", plist);
+ lu_ref_add_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist);
cl_page_get(page);
EXIT;
}
@@ -1126,7 +1126,7 @@ void cl_page_list_del(const struct lu_env *env,
mutex_unlock(&page->cp_mutex);
lockdep_on();
--plist->pl_nr;
- lu_ref_del_at(&page->cp_reference, page->cp_queue_ref, "queue", plist);
+ lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist);
cl_page_put(env, page);
EXIT;
}
@@ -1146,8 +1146,8 @@ void cl_page_list_move(struct cl_page_list *dst, struct cl_page_list *src,
list_move_tail(&page->cp_batch, &dst->pl_pages);
--src->pl_nr;
++dst->pl_nr;
- lu_ref_set_at(&page->cp_reference,
- page->cp_queue_ref, "queue", src, dst);
+ lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue",
+ src, dst);
EXIT;
}
EXPORT_SYMBOL(cl_page_list_move);
@@ -1202,7 +1202,8 @@ void cl_page_list_disown(const struct lu_env *env,
* XXX cl_page_disown0() will fail if page is not locked.
*/
cl_page_disown0(env, io, page);
- lu_ref_del(&page->cp_reference, "queue", plist);
+ lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue",
+ plist);
cl_page_put(env, page);
}
EXIT;
@@ -1449,7 +1450,7 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req)
struct cl_object *obj = req->crq_o[i].ro_obj;
if (obj != NULL) {
lu_object_ref_del_at(&obj->co_lu,
- req->crq_o[i].ro_obj_ref,
+ &req->crq_o[i].ro_obj_ref,
"cl_req", req);
cl_object_put(env, obj);
}
@@ -1570,8 +1571,8 @@ void cl_req_page_add(const struct lu_env *env,
if (rqo->ro_obj == NULL) {
rqo->ro_obj = obj;
cl_object_get(obj);
- rqo->ro_obj_ref = lu_object_ref_add(&obj->co_lu,
- "cl_req", req);
+ lu_object_ref_add_at(&obj->co_lu, &rqo->ro_obj_ref,
+ "cl_req", req);
break;
}
}
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c
index d34e044..958c1e5 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c
@@ -267,7 +267,7 @@ static void cl_lock_free(const struct lu_env *env, struct cl_lock *lock)
}
CS_LOCK_DEC(obj, total);
CS_LOCKSTATE_DEC(obj, lock->cll_state);
- lu_object_ref_del_at(&obj->co_lu, lock->cll_obj_ref, "cl_lock", lock);
+ lu_object_ref_del_at(&obj->co_lu, &lock->cll_obj_ref, "cl_lock", lock);
cl_object_put(env, obj);
lu_ref_fini(&lock->cll_reference);
lu_ref_fini(&lock->cll_holders);
@@ -373,8 +373,8 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env,
lock->cll_descr = *descr;
lock->cll_state = CLS_NEW;
cl_object_get(obj);
- lock->cll_obj_ref = lu_object_ref_add(&obj->co_lu,
- "cl_lock", lock);
+ lu_object_ref_add_at(&obj->co_lu, &lock->cll_obj_ref, "cl_lock",
+ lock);
INIT_LIST_HEAD(&lock->cll_layers);
INIT_LIST_HEAD(&lock->cll_linkage);
INIT_LIST_HEAD(&lock->cll_inclosure);
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c
index bb93359..d9ca5d5 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_page.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c
@@ -270,7 +270,7 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page)
}
CS_PAGE_DEC(obj, total);
CS_PAGESTATE_DEC(obj, page->cp_state);
- lu_object_ref_del_at(&obj->co_lu, page->cp_obj_ref, "cl_page", page);
+ lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page);
cl_object_put(env, obj);
lu_ref_fini(&page->cp_reference);
OBD_FREE(page, pagesize);
@@ -305,7 +305,8 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env,
atomic_inc(&page->cp_ref);
page->cp_obj = o;
cl_object_get(o);
- page->cp_obj_ref = lu_object_ref_add(&o->co_lu, "cl_page",page);
+ lu_object_ref_add_at(&o->co_lu, &page->cp_obj_ref, "cl_page",
+ page);
page->cp_index = ind;
cl_page_state_set_trust(page, CPS_CACHED);
page->cp_type = type;
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index ce0444f..896f24a 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -1147,15 +1147,16 @@ EXPORT_SYMBOL(lu_device_fini);
* Initialize object \a o that is part of compound object \a h and was created
* by device \a d.
*/
-int lu_object_init(struct lu_object *o,
- struct lu_object_header *h, struct lu_device *d)
+int lu_object_init(struct lu_object *o, struct lu_object_header *h,
+ struct lu_device *d)
{
- memset(o, 0, sizeof *o);
+ memset(o, 0, sizeof(*o));
o->lo_header = h;
- o->lo_dev = d;
+ o->lo_dev = d;
lu_device_get(d);
- o->lo_dev_ref = lu_ref_add(&d->ld_reference, "lu_object", o);
+ lu_ref_add_at(&d->ld_reference, &o->lo_dev_ref, "lu_object", o);
INIT_LIST_HEAD(&o->lo_linkage);
+
return 0;
}
EXPORT_SYMBOL(lu_object_init);
@@ -1170,8 +1171,8 @@ void lu_object_fini(struct lu_object *o)
LASSERT(list_empty(&o->lo_linkage));

if (dev != NULL) {
- lu_ref_del_at(&dev->ld_reference,
- o->lo_dev_ref , "lu_object", o);
+ lu_ref_del_at(&dev->ld_reference, &o->lo_dev_ref,
+ "lu_object", o);
lu_device_put(dev);
o->lo_dev = NULL;
}
diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
index 0a0ec6f..6b0a842 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -2064,7 +2064,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli,

while ((osc = osc_next_obj(cli)) != NULL) {
struct cl_object *obj = osc2cl(osc);
- struct lu_ref_link *link;
+ struct lu_ref_link link;

OSC_IO_DEBUG(osc, "%lu in flight\n", rpcs_in_flight(cli));

@@ -2075,7 +2075,8 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli,

cl_object_get(obj);
client_obd_list_unlock(&cli->cl_loi_list_lock);
- link = lu_object_ref_add(&obj->co_lu, "check", current);
+ lu_object_ref_add_at(&obj->co_lu, &link, "check",
+ current);

/* attempt some read/write balancing by alternating between
* reads and writes in an object. The makes_rpc checks here
@@ -2116,7 +2117,8 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli,
osc_object_unlock(osc);

osc_list_maint(cli, osc);
- lu_object_ref_del_at(&obj->co_lu, link, "check", current);
+ lu_object_ref_del_at(&obj->co_lu, &link, "check",
+ current);
cl_object_put(env, obj);

client_obd_list_lock(&cli->cl_loi_list_lock);
--
1.7.1

2013-07-24 09:57:01

by Peng Tao

[permalink] [raw]
Subject: Re: [PATCH 0/8] staging/lustre: Intel tree sync and two fixups

On Wed, Jul 24, 2013 at 4:31 PM, <[email protected]> wrote:
> From: Peng Tao <[email protected]>
>
> Hi Greg,
>
> I've fixed up the rest of Intel tree ported patches and rebased them on top
> of your staging-next. Also I found that the Lustre errno translate code breaks
> build on non-x86 systems. I've added one patch to fix it. Please queue them if
> they are OK to you.
>
btw, the build error only reveals itself after we fix the Kconfig bool
default value bug in [PATCH 6/8].

Thanks,
Tao

> Thanks,
> Tao
>
> Cc: Andreas Dilger <[email protected]>
>
> John L. Hammond (2):
> staging/lustre/llite: handle io init failure in ll_fault_io_init()
> staging/lustre/obdclass: use a dummy structure for lu_ref_link
>
> Liu Xuezhao (1):
> staging/lustre/obdclass: add obd_target.h
>
> Peng Tao (2):
> staging/lustre: fix Kconfig bool defaults
> staging/lustre: fix build on non-x86
>
> Sebastien Buisson (2):
> staging/lustre: fix 'data race condition' issues in at_reset()
> staging/lustre/llite: fix 'data race condition' issues of lli_flags
>
> Thomas Leibovici (1):
> staging/lustre/lmv: support DNE with HSM.
>
> drivers/staging/lustre/lustre/Kconfig | 2 +-
> drivers/staging/lustre/lustre/include/cl_object.h | 10 +-
> .../lustre/lustre/include/linux/lustre_fsfilt.h | 10 -
> .../staging/lustre/lustre/include/lprocfs_status.h | 36 --
> drivers/staging/lustre/lustre/include/lu_object.h | 18 +-
> drivers/staging/lustre/lustre/include/lu_ref.h | 14 +-
> .../staging/lustre/lustre/include/lustre_import.h | 2 +
> drivers/staging/lustre/lustre/include/obd.h | 140 +-----
> drivers/staging/lustre/lustre/llite/llite_lib.c | 4 +
> drivers/staging/lustre/lustre/llite/llite_mmap.c | 36 +-
> drivers/staging/lustre/lustre/llite/namei.c | 5 +-
> drivers/staging/lustre/lustre/lmv/lmv_obd.c | 200 +++++++-
> drivers/staging/lustre/lustre/lvfs/lvfs_linux.c | 1 -
> drivers/staging/lustre/lustre/mdc/mdc_request.c | 18 +-
> drivers/staging/lustre/lustre/obdclass/Makefile | 2 +-
> drivers/staging/lustre/lustre/obdclass/cl_io.c | 17 +-
> drivers/staging/lustre/lustre/obdclass/cl_lock.c | 6 +-
> drivers/staging/lustre/lustre/obdclass/cl_page.c | 5 +-
> .../lustre/lustre/obdclass/lprocfs_jobstats.c | 560 --------------------
> drivers/staging/lustre/lustre/obdclass/lu_object.c | 15 +-
> drivers/staging/lustre/lustre/obdclass/obd_mount.c | 1 -
> drivers/staging/lustre/lustre/osc/osc_cache.c | 8 +-
> drivers/staging/lustre/lustre/ptlrpc/Makefile | 2 +-
> drivers/staging/lustre/lustre/ptlrpc/errno.c | 4 +-
> 24 files changed, 301 insertions(+), 815 deletions(-)
> delete mode 100644 drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c
>

2013-07-24 15:16:32

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 6/8] staging/lustre: fix Kconfig bool defaults

On Wed, Jul 24, 2013 at 04:31:30PM +0800, [email protected] wrote:

Your email is spitting out a very invalid email address :(


> From: Peng Tao <[email protected]>

Ok, that's one email address, yet...

> Should be y instead of true.
>
> Reported-by: Paul Bolle <[email protected]>
> Cc: Andreas Dilger <[email protected]>
> Signed-off-by: Peng Tao <[email protected]>

That's the other. Which is it? Please keep them the same, as you do
have control over them.

Care to resend this series fixing this up?

thanks,

greg k-h

2013-07-24 17:19:58

by Peng Tao

[permalink] [raw]
Subject: Re: [PATCH 6/8] staging/lustre: fix Kconfig bool defaults

On Wed, Jul 24, 2013 at 11:17 PM, Greg Kroah-Hartman
<[email protected]> wrote:
> On Wed, Jul 24, 2013 at 04:31:30PM +0800, [email protected] wrote:
>
> Your email is spitting out a very invalid email address :(
>
Sorry I was using a fake email agent to send these patches... I'll fix
up and resend.

Thanks,
Tao
>
>> From: Peng Tao <[email protected]>
>
> Ok, that's one email address, yet...
>
>> Should be y instead of true.
>>
>> Reported-by: Paul Bolle <[email protected]>
>> Cc: Andreas Dilger <[email protected]>
>> Signed-off-by: Peng Tao <[email protected]>
>
> That's the other. Which is it? Please keep them the same, as you do
> have control over them.
>
> Care to resend this series fixing this up?
>
> thanks,
>
> greg k-h

2013-07-24 17:27:57

by Dilger, Andreas

[permalink] [raw]
Subject: Re: [PATCH 8/8] staging/lustre: fix errno translate code on non-x86

On 2013/07/24 2:31 AM, "[email protected]"
<[email protected]> wrote:

>From: Peng Tao <[email protected]>
>
>On non-x86 we will build with Lustre's errno translate code but
>it has a few issues that break build on non-x86 platforms.

Tao
if the build is broken, wouldn't it make sense either to merge this patch
into
the original or land it earlier in the series to minimize/eliminate the
window
of un-bisectability?

Cheers, Andreas

PS - this is a bug introduced during porting to the upstream kernel, it
does
not exist in Lustre master branch.

>Cc: Andreas Dilger <[email protected]>
>Signed-off-by: Peng Tao <[email protected]>
>---
> drivers/staging/lustre/lustre/ptlrpc/Makefile | 2 +-
> drivers/staging/lustre/lustre/ptlrpc/errno.c | 4 +---
> 2 files changed, 2 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/staging/lustre/lustre/ptlrpc/Makefile
>b/drivers/staging/lustre/lustre/ptlrpc/Makefile
>index a379558..6d78b80 100644
>--- a/drivers/staging/lustre/lustre/ptlrpc/Makefile
>+++ b/drivers/staging/lustre/lustre/ptlrpc/Makefile
>@@ -16,7 +16,7 @@ ptlrpc_objs += sec.o sec_bulk.o sec_gc.o sec_config.o
>sec_lproc.o
> ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o
>
> ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs)
>-ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.c
>+ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.o
>
> obj-$(CONFIG_PTLRPC_GSS) += gss/
>
>diff --git a/drivers/staging/lustre/lustre/ptlrpc/errno.c
>b/drivers/staging/lustre/lustre/ptlrpc/errno.c
>index 46e259e..1c10063 100644
>--- a/drivers/staging/lustre/lustre/ptlrpc/errno.c
>+++ b/drivers/staging/lustre/lustre/ptlrpc/errno.c
>@@ -25,7 +25,7 @@
> * Copyright (c) 2013, Intel Corporation.
> */
>
>-#include <libcfs/libcfs.h>
>+#include <linux/libcfs/libcfs.h>
> #include <lustre/lustre_errno.h>
>
> /*
>@@ -184,7 +184,6 @@ static int lustre_errno_hton_mapping[] = {
> [EBADTYPE] = LUSTRE_EBADTYPE,
> [EJUKEBOX] = LUSTRE_EJUKEBOX,
> [EIOCBQUEUED] = LUSTRE_EIOCBQUEUED,
>- [EIOCBRETRY] = LUSTRE_EIOCBRETRY
> };
>
> static int lustre_errno_ntoh_mapping[] = {
>@@ -331,7 +330,6 @@ static int lustre_errno_ntoh_mapping[] = {
> [LUSTRE_EBADTYPE] = EBADTYPE,
> [LUSTRE_EJUKEBOX] = EJUKEBOX,
> [LUSTRE_EIOCBQUEUED] = EIOCBQUEUED,
>- [LUSTRE_EIOCBRETRY] = EIOCBRETRY
> };
>
> unsigned int lustre_errno_hton(unsigned int h)
>--
>1.7.1
>
>


Cheers, Andreas
--
Andreas Dilger

Lustre Software Architect
Intel High Performance Data Division

2013-07-24 17:44:10

by Peng Tao

[permalink] [raw]
Subject: Re: [PATCH 8/8] staging/lustre: fix errno translate code on non-x86

On Thu, Jul 25, 2013 at 1:27 AM, Dilger, Andreas
<[email protected]> wrote:
> On 2013/07/24 2:31 AM, "[email protected]"
> <[email protected]> wrote:
>
>>From: Peng Tao <[email protected]>
>>
>>On non-x86 we will build with Lustre's errno translate code but
>>it has a few issues that break build on non-x86 platforms.
>
> Tao
> if the build is broken, wouldn't it make sense either to merge this patch
> into
> the original or land it earlier in the series to minimize/eliminate the
> window
> of un-bisectability?
>
The original one introduced the bug is already merged. See commit
2d58de78b2f6c53688a154b02bae3ada19ed15a9 in Greg's staging-next
(staging/lustre/ptlrpc: Translate between host and network errnos). So
we need to fix it in a separate patch.

And I agree with you that we need to put this one just before the
Kconfig fixup so that we don't break bisectability.

> Cheers, Andreas
>
> PS - this is a bug introduced during porting to the upstream kernel, it
> does
> not exist in Lustre master branch.
>
Lustre master also need fixing. EIOCBRETRY is removed in recent
kernels. We'll need to backport that part of the patch to Intel tree.

Thanks,
Tao


>>Cc: Andreas Dilger <[email protected]>
>>Signed-off-by: Peng Tao <[email protected]>
>>---
>> drivers/staging/lustre/lustre/ptlrpc/Makefile | 2 +-
>> drivers/staging/lustre/lustre/ptlrpc/errno.c | 4 +---
>> 2 files changed, 2 insertions(+), 4 deletions(-)
>>
>>diff --git a/drivers/staging/lustre/lustre/ptlrpc/Makefile
>>b/drivers/staging/lustre/lustre/ptlrpc/Makefile
>>index a379558..6d78b80 100644
>>--- a/drivers/staging/lustre/lustre/ptlrpc/Makefile
>>+++ b/drivers/staging/lustre/lustre/ptlrpc/Makefile
>>@@ -16,7 +16,7 @@ ptlrpc_objs += sec.o sec_bulk.o sec_gc.o sec_config.o
>>sec_lproc.o
>> ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o
>>
>> ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs)
>>-ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.c
>>+ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.o
>>
>> obj-$(CONFIG_PTLRPC_GSS) += gss/
>>
>>diff --git a/drivers/staging/lustre/lustre/ptlrpc/errno.c
>>b/drivers/staging/lustre/lustre/ptlrpc/errno.c
>>index 46e259e..1c10063 100644
>>--- a/drivers/staging/lustre/lustre/ptlrpc/errno.c
>>+++ b/drivers/staging/lustre/lustre/ptlrpc/errno.c
>>@@ -25,7 +25,7 @@
>> * Copyright (c) 2013, Intel Corporation.
>> */
>>
>>-#include <libcfs/libcfs.h>
>>+#include <linux/libcfs/libcfs.h>
>> #include <lustre/lustre_errno.h>
>>
>> /*
>>@@ -184,7 +184,6 @@ static int lustre_errno_hton_mapping[] = {
>> [EBADTYPE] = LUSTRE_EBADTYPE,
>> [EJUKEBOX] = LUSTRE_EJUKEBOX,
>> [EIOCBQUEUED] = LUSTRE_EIOCBQUEUED,
>>- [EIOCBRETRY] = LUSTRE_EIOCBRETRY
>> };
>>
>> static int lustre_errno_ntoh_mapping[] = {
>>@@ -331,7 +330,6 @@ static int lustre_errno_ntoh_mapping[] = {
>> [LUSTRE_EBADTYPE] = EBADTYPE,
>> [LUSTRE_EJUKEBOX] = EJUKEBOX,
>> [LUSTRE_EIOCBQUEUED] = EIOCBQUEUED,
>>- [LUSTRE_EIOCBRETRY] = EIOCBRETRY
>> };
>>
>> unsigned int lustre_errno_hton(unsigned int h)
>>--
>>1.7.1
>>
>>
>
>
> Cheers, Andreas
> --
> Andreas Dilger
>
> Lustre Software Architect
> Intel High Performance Data Division
>
>

2013-07-24 19:35:23

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH 6/8] staging/lustre: fix Kconfig bool defaults

On Wed, Jul 24, 2013 at 04:31:30PM +0800, [email protected] wrote:
> From: Peng Tao <[email protected]>
>
> Should be y instead of true.
>
> Reported-by: Paul Bolle <[email protected]>
> Cc: Andreas Dilger <[email protected]>
> Signed-off-by: Peng Tao <[email protected]>
> ---
> drivers/staging/lustre/lustre/Kconfig | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig
> index 9ae7fa8..e3b3c74 100644
> --- a/drivers/staging/lustre/lustre/Kconfig
> +++ b/drivers/staging/lustre/lustre/Kconfig
> @@ -52,4 +52,4 @@ config LUSTRE_DEBUG_EXPENSIVE_CHECK
> config LUSTRE_TRANSLATE_ERRNOS
> bool
> depends on LUSTRE_FS && !X86
> - default true
> + default y

This was the file that contained some buggy "default false" IIRC.
Please delete these.

Sam

2013-07-25 02:37:11

by Peng Tao

[permalink] [raw]
Subject: Re: [PATCH 6/8] staging/lustre: fix Kconfig bool defaults

On Thu, Jul 25, 2013 at 3:35 AM, Sam Ravnborg <[email protected]> wrote:
> On Wed, Jul 24, 2013 at 04:31:30PM +0800, [email protected] wrote:
>> From: Peng Tao <[email protected]>
>>
>> Should be y instead of true.
>>
>> Reported-by: Paul Bolle <[email protected]>
>> Cc: Andreas Dilger <[email protected]>
>> Signed-off-by: Peng Tao <[email protected]>
>> ---
>> drivers/staging/lustre/lustre/Kconfig | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig
>> index 9ae7fa8..e3b3c74 100644
>> --- a/drivers/staging/lustre/lustre/Kconfig
>> +++ b/drivers/staging/lustre/lustre/Kconfig
>> @@ -52,4 +52,4 @@ config LUSTRE_DEBUG_EXPENSIVE_CHECK
>> config LUSTRE_TRANSLATE_ERRNOS
>> bool
>> depends on LUSTRE_FS && !X86
>> - default true
>> + default y
>
> This was the file that contained some buggy "default false" IIRC.
> Please delete these.
>
The default false lines were already deleted by Paul Bolle.
Please see commit 68a8029799ad368ee82a5cf509a2b5b802837ce9 in Greg's
staging-next branch.

commit 68a8029799ad368ee82a5cf509a2b5b802837ce9
Author: Paul Bolle <[email protected]>
Date: Sat Jul 13 20:46:39 2013 +0200

staging/lustre/libcfs: drop bogus Kconfig default

Commit 4b5b4c7222 ("staging/lustre/libcfs: restore LINVRNT") added
"default false" to this Kconfig file. It was obviously meant to use
"default n" here. But we might as well drop this line, as a Kconfig bool
defaults to 'n' anyway.

Signed-off-by: Paul Bolle <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

Thanks,
Tao