Skip to contentSkip to conversation

lustre: sync to OpenSFS branch April 17, 2023

PATCH New James Simmons 1 participant 28 messages Apr 17, 2023 Networking

lore
Share & tools
lore
#0 lore raw

cover lustre: sync to OpenSFS branch April 17, 2023

Latest work from the Lustre community ported to the Native Linux client.

Alex Zhuravlev (3):
lustre: protocol: add OBD_BRW_COMPRESSED
lustre: obdclass: fix rpc slot leakage
lustre: llite: only first sync to MDS matter

Andreas Dilger (3):
lnet: libcfs: cleanup console messages
lustre: misc: remove unnecessary ioctl typecasts
lustre: llite: move common ioctl code to ll_iocontrol()

Bobi Jam (4):
lustre: lov: continue fsync on other OST objs even on -ENOENT
lustre: llite: protect cp_state with vmpage lock
lustre: llite: call truncate_inode_pages() under inode lock
lustre: ldlm: clear lock converting flag on resource cleanup

Chris Horn (1):
lnet: Health logging improvements

Etienne AUJAMES (1):
lustre: llite: fix LSOM blocks for ftruncate and close

James Simmons (1):
lnet: handle multi-rail setups

Li Dongyang (2):
lustre: llite: restart clio for AIO if necessary
lustre: fid: reduce LUSTRE_DATA_SEQ_MAX_WIDTH

Mr NeilBrown (3):
lnet: change LNetAddPeer() to take struct lnet_nid
lustre: obdclass: change class_add/check_uuid to large nid
lustre: obdclass: rename class_parse_nid to class_parse_nid4

Oleg Drokin (1):
lustre: update version to 2.15.54

Qian Yingjin (3):
lustre: llite: fix the wrong beyond read end calculation
lustre: readahead: clip readahead with kms
lustre: statahead: batched statahead processing

Serguei Smirnov (2):
lnet: use discovered ni status to set initial health
lnet: add 'lock_prim_nid" lnet module parameter

Timothy Day (2):
lustre: uapi: fix unused function errors
lnet: fix clang build errors

Yang Sheng (1):
lustre: statahead: statahead thread doesn't stop

 fs/lustre/fid/lproc_fid.c              |   2 +-
 fs/lustre/include/lustre_dlm.h         |  10 +-
 fs/lustre/include/lustre_fid.h         |  65 +--------
 fs/lustre/include/lustre_req_layout.h  |   7 +
 fs/lustre/include/obd.h                |   2 +
 fs/lustre/include/obd_class.h          |  11 +-
 fs/lustre/ldlm/ldlm_lib.c              |  13 +-
 fs/lustre/ldlm/ldlm_request.c          |  80 +++++++++--
 fs/lustre/ldlm/ldlm_resource.c         |   1 +
 fs/lustre/llite/acl.c                  |   2 +
 fs/lustre/llite/dir.c                  | 128 +++--------------
 fs/lustre/llite/file.c                 | 243 ++++++++++++++-------------------
 fs/lustre/llite/lcommon_cl.c           |   4 +-
 fs/lustre/llite/llite_internal.h       |  40 ++++--
 fs/lustre/llite/llite_lib.c            | 190 +++++++++++++++++++++-----
 fs/lustre/llite/lproc_llite.c          |  47 ++++++-
 fs/lustre/llite/rw.c                   |  11 +-
 fs/lustre/llite/statahead.c            | 121 +++++++++++++---
 fs/lustre/llite/vvp_io.c               |  40 +++++-
 fs/lustre/llite/vvp_object.c           |   9 +-
 fs/lustre/llite/xattr.c                |   1 +
 fs/lustre/lmv/lmv_obd.c                |  27 ++++
 fs/lustre/lov/lov_io.c                 |  10 +-
 fs/lustre/mdc/mdc_batch.c              | 163 +++++++++++++++++++++-
 fs/lustre/mdc/mdc_dev.c                |   4 +-
 fs/lustre/mdc/mdc_internal.h           |   6 +
 fs/lustre/mdc/mdc_locks.c              |  24 ++--
 fs/lustre/mdc/mdc_request.c            |   3 +
 fs/lustre/obdclass/cl_page.c           |   6 +-
 fs/lustre/obdclass/class_obd.c         |  16 +--
 fs/lustre/obdclass/genops.c            |  11 +-
 fs/lustre/obdclass/kernelcomm.c        |   7 +-
 fs/lustre/obdclass/lustre_peer.c       |  34 ++---
 fs/lustre/obdclass/obd_config.c        |  31 +++--
 fs/lustre/obdclass/obd_mount.c         |   8 +-
 fs/lustre/osc/osc_io.c                 |   5 +
 fs/lustre/osc/osc_request.c            |   5 +-
 fs/lustre/ptlrpc/layout.c              |  40 ++++++
 fs/lustre/ptlrpc/wiretest.c            |   2 +
 include/linux/lnet/api.h               |   2 +-
 include/linux/lnet/lib-lnet.h          |   4 +-
 include/linux/lnet/lib-types.h         |   5 +
 include/uapi/linux/lnet/lnet-types.h   |   4 +-
 include/uapi/linux/lustre/lustre_fid.h |  65 +++++++++
 include/uapi/linux/lustre/lustre_idl.h |   1 +
 include/uapi/linux/lustre/lustre_ver.h |   4 +-
 net/lnet/klnds/o2iblnd/o2iblnd.c       |  51 +++++--
 net/lnet/klnds/socklnd/socklnd.c       |  38 ++++--
 net/lnet/libcfs/libcfs_cpu.c           |  14 +-
 net/lnet/lnet/api-ni.c                 | 210 ++++++++++++++++------------
 net/lnet/lnet/lib-move.c               | 165 ++++++++++++++++++++--
 net/lnet/lnet/lib-msg.c                |  16 ++-
 net/lnet/lnet/peer.c                   | 132 +++++++++++-------
 net/lnet/selftest/conctl.c             |   7 +-
 54 files changed, 1488 insertions(+), 659 deletions(-)
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#1 lore raw

PATCH 1/27 lustre: llite: fix the wrong beyond read end calculation

From: Qian Yingjin <[email protected]>

During the test, we found a dead loop in the read path which retruns AOP_TRUNCATED_PAGE(0x8001) endless.
The reason is that the calculation of the ending beyond offset is
wrong: (iter->count + iocb->ki_pos).
The ending beyond offset was supposed to be not changed during the read I/O loop for each page in buffered I/O mode. However, @iter->count is decreased with read bytes when finished the read of each page: @iter->count -= read_bytes.

In this patch, we store the ending beyond page index in @lcc->lcc_end_index before call @generic_file_read_iter into a loop for each read page and solve this bug.

Fixes c9f68ebdc6 ("lustre: llite: check read page past requested")

WC-bug-id: https://jira.whamcloud.com/browse/LU-16579
Lustre-commit: ae356dc325877bd13 ("LU-16579 llite: fix the wrong beyond read end calculation")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50065

---
 fs/lustre/llite/llite_internal.h |  3 +--
 fs/lustre/llite/rw.c             | 11 +++--------
 fs/lustre/llite/vvp_io.c         |  6 ++----
 3 files changed, 6 insertions(+), 14 deletions(-)
fs/lustre/llite/llite_internal.h +1 -2
index 72de8f7..d8eee75 100644
@@ -1375,8 +1375,7 @@ struct ll_cl_context {
 	struct cl_io		*lcc_io;
 	struct cl_page		*lcc_page;
 	enum lcc_type		 lcc_type;
-	struct kiocb		*lcc_iocb;
-	struct iov_iter		*lcc_iter;
+	pgoff_t			 lcc_end_index;
 };
 
 struct ll_thread_info {
fs/lustre/llite/rw.c +3 -8
index d285ae1..0c73258 100644
@@ -1863,9 +1863,7 @@ int ll_readpage(struct file *file, struct page *vmpage)
 	struct cl_read_ahead ra = { 0 };
 	struct ll_cl_context *lcc;
 	struct cl_io *io = NULL;
-	struct iov_iter *iter;
 	struct cl_page *page;
-	struct kiocb *iocb;
 	int result;
 
 	if (OBD_FAIL_PRECHECK(OBD_FAIL_LLITE_READPAGE_PAUSE)) {
@@ -1974,11 +1972,8 @@ int ll_readpage(struct file *file, struct page *vmpage)
 	}
 
 	if (lcc && lcc->lcc_type != LCC_MMAP) {
-		iocb = lcc->lcc_iocb;
-		iter = lcc->lcc_iter;
-
-		CDEBUG(D_VFSTRACE, "pgno:%ld, cnt:%ld, pos:%lld\n",
-		       vmpage->index, iter->count, iocb->ki_pos);
+		CDEBUG(D_VFSTRACE, "pgno:%ld, beyond read end_index:%ld\n",
+		       vmpage->index, lcc->lcc_end_index);
 
 		/*
 		 * This handles a kernel bug introduced in kernel 5.12:
@@ -2004,7 +1999,7 @@ int ll_readpage(struct file *file, struct page *vmpage)
 		 * This should never occur except in kernels with the bug
 		 * mentioned above.
 		 */
-		if (cl_offset(clob, vmpage->index) >= iter->count + iocb->ki_pos) {
+		if (vmpage->index >= lcc->lcc_end_index) {
 			result = cl_io_read_ahead(env, io, vmpage->index, &ra);
 			if (result < 0 || vmpage->index > ra.cra_end_idx) {
 				cl_read_ahead_release(env, &ra);
fs/lustre/llite/vvp_io.c +2 -4
index 561ce66..50c2872 100644
@@ -871,10 +871,8 @@ static int vvp_io_read_start(const struct lu_env *env,
 	iter = *vio->vui_iter;
 
 	lcc = ll_cl_find(inode);
-	lcc->lcc_iter = &iter;
-	lcc->lcc_iocb = vio->vui_iocb;
-	CDEBUG(D_VFSTRACE, "cnt:%ld,iocb pos:%lld\n", lcc->lcc_iter->count,
-	       lcc->lcc_iocb->ki_pos);
+	lcc->lcc_end_index = DIV_ROUND_UP(pos + iter.count, PAGE_SIZE);
+	CDEBUG(D_VFSTRACE, "count:%ld iocb pos:%lld\n", iter.count, pos);
 
 	result = generic_file_read_iter(vio->vui_iocb, &iter);
 out:
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#2 lore raw

PATCH 2/27 lustre: lov: continue fsync on other OST objs even on -ENOENT

In reply to James Simmons

From: Bobi Jam <[email protected]>

When fsync races with truncate, we'd continue to other OST object's fsync even some stripe fsync returns -ENOENT, so that on client it could potentially discard caching pages by calling osc_io_fsync_start()->osc_cache_writebase_range().

WC-bug-id: https://jira.whamcloud.com/browse/LU-16263
Lustre-commit: 927b5cd49c3369d53 ("LU-16263 lov: continue fsync on other OST objs even on -ENOENT")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50005

---
 fs/lustre/lov/lov_io.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
fs/lustre/lov/lov_io.c +9 -1
index 32f028b..4c842cd 100644
@@ -1013,8 +1013,16 @@ static int lov_io_call(const struct lu_env *env, struct lov_io *lio,
 
 	list_for_each_entry(sub, &lio->lis_active, sub_linkage) {
 		rc = iofunc(sub->sub_env, &sub->sub_io);
-		if (rc)
+		if (rc) {
+			/**
+			 * fsync race with truncate, we'd continue to other
+			 * OST object's fsync to potentially discard
+			 * caching pages (osc_cache_writeback_range).
+			 */
+			if (rc == -ENOENT && parent->ci_type == CIT_FSYNC)
+				continue;
 			break;
+		}
 
 		if (parent->ci_result == 0)
 			parent->ci_result = sub->sub_io.ci_result;
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#3 lore raw

PATCH 3/27 lustre: llite: protect cp_state with vmpage lock

In reply to James Simmons

From: Bobi Jam <[email protected]>

cl_page_make_ready() calls cl_page_io_start() without vmpage lock protection, and that could mess up cl_page's cp_state/cp_owner.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16612
Lustre-commit: d03b038d0dd8360dc ("LU-16612 llite: protect cp_state with vmpage lock")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50180

---
 fs/lustre/obdclass/cl_page.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/lustre/obdclass/cl_page.c +5 -1
index 8320293..80423b7 100644
@@ -871,6 +871,7 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *cp,
 		       enum cl_req_type crt)
 {
 	struct page *vmpage = cp->cp_vmpage;
+	bool unlock = false;
 	int rc = 0;
 
 	PASSERT(env, cp, crt == CRT_WRITE);
@@ -879,6 +880,7 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *cp,
 		goto out;
 
 	lock_page(vmpage);
+	unlock = true;
 
 	if (clear_page_dirty_for_io(vmpage)) {
 		LASSERT(cp->cp_state == CPS_CACHED);
@@ -899,13 +901,15 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *cp,
 		LBUG();
 	}
 
-	unlock_page(vmpage);
 out:
 	if (rc == 0) {
 		PASSERT(env, cp, cp->cp_state == CPS_CACHED);
 		cl_page_io_start(env, cp, crt);
 	}
 
+	if (unlock)
+		unlock_page(vmpage);
+
 	CL_PAGE_HEADER(D_TRACE, env, cp, "%d %d\n", crt, rc);
 
 	return rc;
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#4 lore raw

PATCH 4/27 lustre: llite: restart clio for AIO if necessary

In reply to James Simmons

From: Li Dongyang <[email protected]>

If the clio needs to be restarted from where it left off, do it for AIO as well, so we don't end up with short IO. Limit thr number of retries to 1000, to avoid potential issues if the loop is stuck forever.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14760
Lustre-commit: 6b1e747ad5bf02915 ("LU-14760 llite: restart clio for AIO if necessary")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/43995

---
 fs/lustre/llite/file.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
fs/lustre/llite/file.c +5 -4
index 746c18f..b96efb1 100644
@@ -1689,6 +1689,7 @@ static void ll_heat_add(struct inode *inode, enum cl_io_type iot,
 	ssize_t result = 0;
 	int rc = 0;
 	int rc2 = 0;
+	int retries = 1000;
 	unsigned int retried = 0;
 	unsigned int dio_lock = 0;
 	bool is_aio = false;
@@ -1851,13 +1852,13 @@ static void ll_heat_add(struct inode *inode, enum cl_io_type iot,
 	       file->f_path.dentry->d_name.name,
 	       iot, rc, result, io->ci_need_restart);
 
-	if ((!rc || rc == -ENODATA || rc == -ENOLCK) &&
-	    count > 0 && io->ci_need_restart) {
+	if ((!rc || rc == -ENODATA || rc == -ENOLCK || rc == -EIOCBQUEUED) &&
+	    count > 0 && io->ci_need_restart && retries-- > 0) {
 		CDEBUG(D_VFSTRACE,
-		       "%s: restart %s from %lld, count:%zu, result: %zd\n",
+		       "%s: restart %s from ppos=%lld count=%zu retries=%u ret=%zd: rc = %d\n",
 		       file_dentry(file)->d_name.name,
 		       iot == CIT_READ ? "read" : "write",
-		       *ppos, count, result);
+		       *ppos, count, retries, result, rc);
 		/* preserve the tried count for FLR */
 		retried = io->ci_ndelay_tried;
 		dio_lock = io->ci_dio_lock;
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#5 lore raw

PATCH 5/27 lustre: protocol: add OBD_BRW_COMPRESSED

In reply to James Simmons

From: Alex Zhuravlev <[email protected]>

so the client can hint OST the data is compressed

WC-bug-id: https://jira.whamcloud.com/browse/LU-16603
Lustre-commit: 764e19186cfc99123 ("LU-16603 protocol: add OBD_BRW_COMPRESSED")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50154

---
 fs/lustre/ptlrpc/wiretest.c            | 2 ++
 include/uapi/linux/lustre/lustre_idl.h | 1 +
 2 files changed, 3 insertions(+)
fs/lustre/ptlrpc/wiretest.c +2 -0
index 472d155c..6e893f0 100644
@@ -2085,6 +2085,8 @@ void lustre_assert_wire_constants(void)
 		 OBD_BRW_RDMA_ONLY);
 	LASSERTF(OBD_BRW_SYS_RESOURCE == 0x40000, "found 0x%.8x\n",
 		 OBD_BRW_SYS_RESOURCE);
+	LASSERTF(OBD_BRW_COMPRESSED == 0x80000, "found 0x%.8x\n",
+		 OBD_BRW_COMPRESSED);
 
 	/* Checks for struct ost_body */
 	LASSERTF((int)sizeof(struct ost_body) == 208, "found %lld\n",
include/uapi/linux/lustre/lustre_idl.h +1 -0
index c979e24..83c8ea8 100644
@@ -1253,6 +1253,7 @@ struct hsm_state_set {
 #define OBD_BRW_ROOT_PRJQUOTA 0x10000 /* check project quota for root */
 #define OBD_BRW_RDMA_ONLY    0x20000 /* RPC contains RDMA-only pages*/
 #define OBD_BRW_SYS_RESOURCE 0x40000 /* page has CAP_SYS_RESOURCE */
+#define OBD_BRW_COMPRESSED   0x80000 /* data compressed on client */
 
 #define OBD_MAX_GRANT 0x7fffffffUL /* Max grant allowed to one client: 2 GiB */
 
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#6 lore raw

PATCH 6/27 lustre: llite: call truncate_inode_pages() under inode lock

In reply to James Simmons

From: Bobi Jam <[email protected]>

truncate_inode_pages() is required to be called under (and serialised by) inode lock.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16637
Lustre-commit: ef9be34478036db05 ("LU-16637 llite: call truncate_inode_pages() under inode lock")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50284

---
 fs/lustre/llite/llite_internal.h |  2 +-
 fs/lustre/llite/llite_lib.c      | 12 ++++++++----
 fs/lustre/llite/vvp_object.c     |  9 ++++++++-
 3 files changed, 17 insertions(+), 6 deletions(-)
fs/lustre/llite/llite_internal.h +1 -1
index d8eee75..fdc0f89 100644
@@ -1287,7 +1287,7 @@ int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs,
 void ll_update_inode_flags(struct inode *inode, unsigned int ext_flags);
 void ll_update_dir_depth(struct inode *dir, struct inode *inode);
 int ll_read_inode2(struct inode *inode, void *opaque);
-void ll_truncate_inode_pages_final(struct inode *inode);
+void ll_truncate_inode_pages_final(struct inode *inode, struct cl_io *io);
 void ll_delete_inode(struct inode *inode);
 int ll_iocontrol(struct inode *inode, struct file *file,
 		 unsigned int cmd, unsigned long arg);
fs/lustre/llite/llite_lib.c +8 -4
index 5a9bc61..049cd23 100644
@@ -2755,12 +2755,15 @@ void ll_update_dir_depth(struct inode *dir, struct inode *inode)
 	       PFID(&lli->lli_fid), lli->lli_dir_depth, lli->lli_inherit_depth);
 }
 
-void ll_truncate_inode_pages_final(struct inode *inode)
+void ll_truncate_inode_pages_final(struct inode *inode, struct cl_io *io)
 {
 	struct address_space *mapping = &inode->i_data;
 	unsigned long nrpages;
 	unsigned long flags;
 
+	LASSERTF(io == NULL || inode_is_locked(inode), "io %p (type %d)\n",
+		 io, io ? io->ci_type : 0);
+
 	truncate_inode_pages_final(mapping);
 
 	/* Workaround for LU-118: Note nrpages may not be totally updated when
@@ -2777,9 +2780,10 @@ void ll_truncate_inode_pages_final(struct inode *inode)
 		xa_unlock_irqrestore(&mapping->i_pages, flags);
 	} /* Workaround end */
 
-	LASSERTF(nrpages == 0, "%s: inode="DFID"(%p) nrpages=%lu, see https://jira.whamcloud.com/browse/LU-118\n",
+	LASSERTF(nrpages == 0, "%s: inode="DFID"(%p) nrpages=%lu io %p (io_type %d), see https://jira.whamcloud.com/browse/LU-118\n",
 		 ll_i2sbi(inode)->ll_fsname,
-		 PFID(ll_inode2fid(inode)), inode, nrpages);
+		 PFID(ll_inode2fid(inode)), inode, nrpages,
+		 io, io  ? io->ci_type : 0);
 }
 
 int ll_read_inode2(struct inode *inode, void *opaque)
@@ -2843,7 +2847,7 @@ void ll_delete_inode(struct inode *inode)
 				   CL_FSYNC_LOCAL : CL_FSYNC_DISCARD, 1);
 	}
 
-	ll_truncate_inode_pages_final(inode);
+	ll_truncate_inode_pages_final(inode, NULL);
 	ll_clear_inode(inode);
 	clear_inode(inode);
 }
fs/lustre/llite/vvp_object.c +8 -1
index 0ef055f..302f900 100644
@@ -153,6 +153,7 @@ static int vvp_conf_set(const struct lu_env *env, struct cl_object *obj,
 
 static int vvp_prune(const struct lu_env *env, struct cl_object *obj)
 {
+	struct cl_io *io = vvp_env_io(env)->vui_cl.cis_io;
 	struct inode *inode = vvp_object_inode(obj);
 	int rc;
 
@@ -163,9 +164,15 @@ static int vvp_prune(const struct lu_env *env, struct cl_object *obj)
 		return rc;
 	}
 
-	ll_truncate_inode_pages_final(inode);
+	if (io != NULL)
+		inode_lock(inode);
+
+	ll_truncate_inode_pages_final(inode, io);
 	mapping_clear_exiting(inode->i_mapping);
 
+	if (io != NULL)
+		inode_unlock(inode);
+
 	return 0;
 }
 
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#7 lore raw

PATCH 7/27 lustre: fid: reduce LUSTRE_DATA_SEQ_MAX_WIDTH

In reply to James Simmons

From: Li Dongyang <[email protected]>

Reduce LUSTRE_DATA_SEQ_MAX_WIDTH from ~4B to ~32M to limit the number of objects under /O/[seq]/d[0..31] dir on OSTs. This makes the directories stay optimial for ldiskfs, to avoid going into the largedir/3-level htree territory.

Check the seq->lcs_width which is a tunable set to LUSTRE_DATA_SEQ_MAX_WIDTH by default, allow the value up to IDIF_MAX_OID if a larger seq width is needed.

The seq will rollover when the seq width is exhausted, the default is LUSTRE_DATA_SEQ_MAX_WIDTH.
For seq >= FID_SEQ_NORMAL objects, the upper limit of seq width is OBIF_MAX_OID,
For IDIF/MDT0 objects, the upper limit is IDIF_MAX_OID. The seq FID_SEQ_OST_MDT0 will change to a normal seq after the rollover.

WC-bug-id: https://jira.whamcloud.com/browse/LU-11912
Lustre-commit: 0ecb2a167c56ffff8 ("LU-11912 ofd: reduce LUSTRE_DATA_SEQ_MAX_WIDTH")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/38424

---
 fs/lustre/fid/lproc_fid.c      | 2 +-
 fs/lustre/include/lustre_fid.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/lustre/fid/lproc_fid.c +1 -1
index 8f6a4a8..9ca2814 100644
@@ -154,7 +154,7 @@ static ssize_t ldebugfs_fid_width_seq_write(struct file *file,
 
 	spin_lock(&seq->lcs_lock);
 	if (seq->lcs_type == LUSTRE_SEQ_DATA)
-		max = LUSTRE_DATA_SEQ_MAX_WIDTH;
+		max = IDIF_MAX_OID;
 	else
 		max = LUSTRE_METADATA_SEQ_MAX_WIDTH;
 
fs/lustre/include/lustre_fid.h +2 -2
index 88a6061..5ebe362 100644
@@ -173,9 +173,9 @@ enum {
 	LUSTRE_METADATA_SEQ_MAX_WIDTH = 0x0000000000020000ULL,
 
 	/*
-	 * This is how many data FIDs could be allocated in one sequence(4B - 1)
+	 * This is how many data FIDs could be allocated in one sequence(32M - 1)
 	 */
-	LUSTRE_DATA_SEQ_MAX_WIDTH = 0x00000000FFFFFFFFULL,
+	LUSTRE_DATA_SEQ_MAX_WIDTH = 0x0000000001FFFFFFULL,
 
 	/*
 	 * How many sequences to allocate to a client at once.
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#8 lore raw

PATCH 8/27 lnet: handle multi-rail setups

In reply to James Simmons

For multi-rail setups we can push more than one interface at a time to setup the local NIs but our netlink code ignored all but one interface. Refactor both lnet_genl_parse_local_ni() and lnet_net_cmd() to setup all the passed in interfaces. Also remove setting ni to NULL in the NI deletion case which causes an oops when we have more than one interface.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9680
Lustre-commit: 6fab1fe4a5c5615d4 ("LU-9680 lnet: handle multi-rail setups")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50026

---
 fs/lustre/obdclass/kernelcomm.c |   7 +-
 net/lnet/lnet/api-ni.c          | 183 ++++++++++++++++++++++------------------
 net/lnet/selftest/conctl.c      |   7 +-
 3 files changed, 111 insertions(+), 86 deletions(-)
fs/lustre/obdclass/kernelcomm.c +6 -1
index 5682d4e..0cf3c44 100644
@@ -116,7 +116,12 @@ static int lustre_device_list_start(struct netlink_callback *cb)
 		struct nlattr *dev;
 		int rem;
 
-		nla_for_each_attr(dev, params, msg_len, rem) {
+		if (!(nla_type(params) & LN_SCALAR_ATTR_LIST)) {
+			NL_SET_ERR_MSG(extack, "no configuration");
+			goto report_err;
+		}
+
+		nla_for_each_nested(dev, params, rem) {
 			struct nlattr *prop;
 			int rem2;
 
net/lnet/lnet/api-ni.c +99 -84

243 lines not on this page · raw message

net/lnet/selftest/conctl.c +6 -1
index ea590b2..a7ec0d5 100644
@@ -1024,7 +1024,12 @@ static int lst_groups_show_start(struct netlink_callback *cb)
 	}
 	glist->lggl_verbose = true;
 
-	nla_for_each_attr(groups, params, msg_len, rem) {
+	if (!(nla_type(params) & LN_SCALAR_ATTR_LIST)) {
+		NL_SET_ERR_MSG(extack, "no configuration");
+		goto report_err;
+	}
+
+	nla_for_each_nested(groups, params, rem) {
 		struct lst_genl_group_prop *prop = NULL;
 		struct nlattr *group;
 		int rem2;
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#9 lore raw

PATCH 9/27 lustre: readahead: clip readahead with kms

In reply to James Simmons

From: Qian Yingjin <[email protected]>

During I/O test, it found that the read-ahead pages reach 255 for small files with only several KiB. The amount of read data reaches more than 1MiB.
The reason is that the granted DLM extent lock is [0, EOF], which is larger than the requested extent. During readahead, the OSC layer will also return [0, EOF] extent which will clip into stripe size (1MiB) regardless the actual object size.
In this patch, the readahead range is clipped to the known min size (kms) on OSC layer during readahead. By this way, the read-ahead data will not beyong the last page of the file.

This patch also fixes multiop to return successfully when reaching EOF instead of exiting with ENODATA during read.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16338
Lustre-commit: b33808d3aebb06cf0 ("LU-16338 readahead: clip readahead with kms")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49226

---
 fs/lustre/osc/osc_io.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/lustre/osc/osc_io.c +5 -0
index c9a3175..d0ee748 100644
@@ -83,6 +83,8 @@ static int osc_io_read_ahead(const struct lu_env *env,
 	oio->oi_is_readahead = true;
 	dlmlock = osc_dlmlock_at_pgoff(env, osc, start, 0);
 	if (dlmlock) {
+		struct lov_oinfo *oinfo = osc->oo_oinfo;
+
 		LASSERT(dlmlock->l_ast_data == osc);
 		if (dlmlock->l_req_mode != LCK_PR) {
 			struct lustre_handle lockh;
@@ -100,6 +102,9 @@ static int osc_io_read_ahead(const struct lu_env *env,
 		ra->cra_oio = oio;
 		if (ra->cra_end_idx != CL_PAGE_EOF)
 			ra->cra_contention = true;
+		ra->cra_end_idx = min_t(pgoff_t, ra->cra_end_idx,
+					cl_index(osc2cl(osc),
+						 oinfo->loi_kms - 1));
 		result = 0;
 	}
 
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#10 lore raw

PATCH 10/27 lnet: use discovered ni status to set initial health

In reply to James Simmons

From: Serguei Smirnov <[email protected]>

If not routing, track local NI status in the ping buffer such that locally recognized "down" state, for example, due to a downed network interface/link, is available to any discovering peer.
If NI 'fatal' status is changed, push update to peers.

On the active side of discovery, check peer NI status so if NI is down, decrement its health score and queue for recovery.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16563
Lustre-commit: da230373bd14306cb ("LU-16563 lnet: use discovered ni status to set initial health")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50027

---
 include/linux/lnet/lib-lnet.h    |  3 ++-
 net/lnet/klnds/o2iblnd/o2iblnd.c | 51 ++++++++++++++++++++++++++++++----------
 net/lnet/klnds/socklnd/socklnd.c | 38 +++++++++++++++++++++++-------
 net/lnet/lnet/api-ni.c           | 20 ++++++++++++++++
 net/lnet/lnet/peer.c             | 14 +++++++++++
 5 files changed, 104 insertions(+), 22 deletions(-)
include/linux/lnet/lib-lnet.h +2 -1
index e26e150..f9f4815 100644
@@ -127,7 +127,7 @@
 		return LNET_NI_STATUS_UP;
 	else if (atomic_read(&ni->ni_fatal_error_on))
 		return LNET_NI_STATUS_DOWN;
-	else if (ni->ni_status)
+	else if (the_lnet.ln_routing && ni->ni_status)
 		return *ni->ni_status;
 	else
 		return LNET_NI_STATUS_UP;
@@ -1216,4 +1216,5 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 		       old ? "up" : "down",
 		       alive ? "up" : "down");
 }
+void lnet_update_ping_buffer(void);
 #endif
net/lnet/klnds/o2iblnd/o2iblnd.c +39 -12

112 lines not on this page · raw message

net/lnet/klnds/socklnd/socklnd.c +29 -9
index b8d6e28..435762f 100644
@@ -2000,6 +2000,8 @@ static int ksocknal_get_link_status(struct net_device *dev)
 	bool found_ip = false;
 	struct ksock_interface *ksi = NULL;
 	struct sockaddr_in *sa;
+	u32 ni_state_before;
+	bool update_ping_buf = false;
 	const struct in_ifaddr *ifa;
 
 	ifindex = dev->ifindex;
@@ -2045,8 +2047,9 @@ static int ksocknal_get_link_status(struct net_device *dev)
 			CDEBUG(D_NET, "Interface %s has no IPv4 status.\n",
 			       dev->name);
 			CDEBUG(D_NET, "set link fatal state to 1\n");
-			atomic_set(&ni->ni_fatal_error_on, 1);
-			continue;
+			ni_state_before = atomic_xchg(&ni->ni_fatal_error_on,
+						      1);
+			goto ni_done;
 		}
 		in_dev_for_each_ifa_rtnl(ifa, in_dev) {
 			if (sa->sin_addr.s_addr == ifa->ifa_local)
@@ -2057,20 +2060,29 @@ static int ksocknal_get_link_status(struct net_device *dev)
 			CDEBUG(D_NET, "Interface %s has no matching ip\n",
 			       dev->name);
 			CDEBUG(D_NET, "set link fatal state to 1\n");
-			atomic_set(&ni->ni_fatal_error_on, 1);
-			continue;
+			ni_state_before = atomic_xchg(&ni->ni_fatal_error_on,
+						      1);
+			goto ni_done;
 		}
 
 		if (link_down) {
 			CDEBUG(D_NET, "set link fatal state to 1\n");
-			atomic_set(&ni->ni_fatal_error_on, link_down);
+			ni_state_before = atomic_xchg(&ni->ni_fatal_error_on,
+						      1);
 		} else {
 			CDEBUG(D_NET, "set link fatal state to %u\n",
 			       (ksocknal_get_link_status(dev) == 0));
-			atomic_set(&ni->ni_fatal_error_on,
-				   (ksocknal_get_link_status(dev) == 0));
+			ni_state_before = atomic_xchg(&ni->ni_fatal_error_on,
+						      (ksocknal_get_link_status(dev) == 0));
 		}
+ni_done:
+		if (!update_ping_buf &&
+		    (atomic_read(&ni->ni_fatal_error_on) != ni_state_before))
+			update_ping_buf = true;
 	}
+
+	if (update_ping_buf)
+		lnet_update_ping_buffer();
 out:
 	return 0;
 }
@@ -2086,6 +2098,8 @@ static int ksocknal_get_link_status(struct net_device *dev)
 	int ifindex;
 	struct ksock_interface *ksi = NULL;
 	struct sockaddr_in *sa;
+	u32 ni_state_before;
+	bool update_ping_buf = false;
 
 	if (!ksocknal_data.ksnd_nnets)
 		goto out;
@@ -2106,10 +2120,16 @@ static int ksocknal_get_link_status(struct net_device *dev)
 			CDEBUG(D_NET, "set link fatal state to %u\n",
 			       (event == NETDEV_DOWN));
 			ni = net->ksnn_ni;
-			atomic_set(&ni->ni_fatal_error_on,
-				   (event == NETDEV_DOWN));
+			ni_state_before = atomic_xchg(&ni->ni_fatal_error_on,
+						      (event == NETDEV_DOWN));
+			if (!update_ping_buf &&
+			    ((event == NETDEV_DOWN) != ni_state_before))
+				update_ping_buf = true;
 		}
 	}
+
+	if (update_ping_buf)
+		lnet_update_ping_buffer();
 out:
 	return 0;
 }
net/lnet/lnet/api-ni.c +20 -0
index 8b0ab53..9f01dbe 100644
@@ -3841,6 +3841,26 @@ int lnet_dyn_del_ni(struct lnet_nid *nid)
 	return rc;
 }
 
+void lnet_update_ping_buffer(void)
+{
+	struct lnet_ping_buffer *pbuf;
+	struct lnet_handle_md ping_mdh;
+
+	if (the_lnet.ln_routing)
+		return;
+
+	mutex_lock(&the_lnet.ln_api_mutex);
+
+	if (!lnet_ping_target_setup(&pbuf, &ping_mdh,
+				    LNET_PING_INFO_HDR_SIZE +
+				    lnet_get_ni_bytes(),
+				    false))
+		lnet_ping_target_update(pbuf, ping_mdh);
+
+	mutex_unlock(&the_lnet.ln_api_mutex);
+}
+EXPORT_SYMBOL(lnet_update_ping_buffer);
+
 void lnet_incr_dlc_seq(void)
 {
 	atomic_inc(&lnet_dlc_seq_no);
net/lnet/lnet/peer.c +14 -0
index 619973b..ef924ce 100644
@@ -3079,6 +3079,15 @@ int ping_info_count_entries(struct lnet_ping_buffer *pbuf)
 	return nnis;
 }
 
+static inline void handle_disc_lpni_health(struct lnet_peer_ni *lpni)
+{
+	if (lpni->lpni_ns_status == LNET_NI_STATUS_DOWN)
+		lnet_handle_remote_failure_locked(lpni);
+	else if (lpni->lpni_ns_status == LNET_NI_STATUS_UP &&
+		 !lpni->lpni_last_alive)
+		atomic_set(&lpni->lpni_healthv, LNET_MAX_HEALTH_VALUE);
+}
+
 /*
  * Build a peer from incoming data.
  *
@@ -3118,6 +3127,7 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
 	int i;
 	int j;
 	int rc;
+	u32 old_st;
 
 	flags = LNET_PEER_DISCOVERED;
 	if (pbuf->pb_info.pi_features & LNET_PING_FEAT_MULTI_RAIL)
@@ -3194,7 +3204,10 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
 				 */
 				lpni = lnet_peer_ni_find_locked(&curnis[i]);
 				if (lpni) {
+					old_st = lpni->lpni_ns_status;
 					lpni->lpni_ns_status = *stp;
+					if (old_st != lpni->lpni_ns_status)
+						handle_disc_lpni_health(lpni);
 					lnet_peer_ni_decref_locked(lpni);
 				}
 				break;
@@ -3224,6 +3237,7 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
 		lpni = lnet_peer_ni_find_locked(&addnis[i].ns_nid);
 		if (lpni) {
 			lpni->lpni_ns_status = addnis[i].ns_status;
+			handle_disc_lpni_health(lpni);
 			lnet_peer_ni_decref_locked(lpni);
 		}
 	}
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#11 lore raw

PATCH 11/27 lnet: add 'lock_prim_nid" lnet module parameter

In reply to James Simmons

From: Serguei Smirnov <[email protected]>

Add 'lock_prim_nid' lnet module parameter to allow control of how Lustre peer primary NID is selected.
If set to 1 (default), the NID specified by Lustre when calling LNet API is designated as primary for the peer, allowing for non-blocking discovery in the background. If set to 0, peer discovery is blocking until complete and the NID listed first in discovery response is designated as primary.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14668
Lustre-commit: fc7a0d6013b46ebc1 ("LU-14668 lnet: add 'lock_prim_nid" lnet module parameter")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50159

---
 include/linux/lnet/lib-lnet.h |   1 +
 net/lnet/lnet/api-ni.c        |   5 ++
 net/lnet/lnet/peer.c          | 105 +++++++++++++++++++++++++++---------------
 3 files changed, 73 insertions(+), 38 deletions(-)
include/linux/lnet/lib-lnet.h +1 -0
index f9f4815..4aa1e5c 100644
@@ -565,6 +565,7 @@ unsigned int lnet_nid_cpt_hash(struct lnet_nid *nid,
 extern int live_router_check_interval;
 extern int dead_router_check_interval;
 extern int portal_rotor;
+extern int lock_prim_nid;
 
 int lnet_lib_init(void);
 void lnet_lib_exit(void);
net/lnet/lnet/api-ni.c +5 -0
index 9f01dbe..fb596ed 100644
@@ -208,6 +208,11 @@ static int response_tracking_set(const char *val,
 MODULE_PARM_DESC(lnet_response_tracking,
 		 "(0|1|2|3) LNet Internal Only|GET Reply only|PUT ACK only|Full Tracking (default)");
 
+int lock_prim_nid = 1;
+module_param(lock_prim_nid, int, 0444);
+MODULE_PARM_DESC(lock_prim_nid,
+		 "Whether nid passed down by Lustre is locked as primary");
+
 #define LNET_LND_TIMEOUT_DEFAULT ((LNET_TRANSACTION_TIMEOUT_DEFAULT - 1) / \
 				  (LNET_RETRY_COUNT_DEFAULT + 1))
 unsigned int lnet_lnd_timeout = LNET_LND_TIMEOUT_DEFAULT;
net/lnet/lnet/peer.c +67 -38

168 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#12 lore raw

PATCH 12/27 lustre: obdclass: fix rpc slot leakage

In reply to James Simmons

From: Alex Zhuravlev <[email protected]>

obd_get_mod_rpc_slot() can race with obd_put_mod_rpc_slot():
finishing wait_woken() resets WQ_FLAG_WOKEN (which is set when the corresponding thread gets a slot incrementing cl_mod_rpcs_in_flight. then another thread execting __wake_up_locked_key() may find that wq_entry again and call claim_mod_rpc_function() one more time again incrementing cl_mod_rpc_in_flight. thus it's incremented twice for a single obd_get_mod_rpc_slot().

flags &= ~WQ_FLAG_WOKEN
list_add()
wait_woken()
schedule claim_mod_rpc_function()

                                cl_mod_rpcs_in_flight++
                                wake_up()

flags &= ~WQ_FLAG_WOKEN

                        #3: obd_put_mod_rpc_slot()
                        claim_mod_rpc_function()
                                cl_mod_rpcs_in_flight++
                                wake_up()

list_del()

the patch introduces a replacement for WQ_FLAG_WOKEN which is never reset once set.

Fixes 6d398c0843 ("lustre: obdclass: improve precision of wakeups for mod_rpcs")

WC-bug-id: https://jira.whamcloud.com/browse/LU-16633
Lustre-commit: 91a3726f313df33e09 ("LU-16633 obdclass: fix rpc slot leakage")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50261

---
 fs/lustre/mdc/mdc_request.c |  3 +++
 fs/lustre/obdclass/genops.c | 11 +++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)
fs/lustre/mdc/mdc_request.c +3 -0
index 58ea982..15e58e8 100644
@@ -2964,6 +2964,9 @@ static int mdc_precleanup(struct obd_device *obd)
 
 static int mdc_cleanup(struct obd_device *obd)
 {
+	struct client_obd *cli = &obd->u.cli;
+
+	LASSERT(cli->cl_mod_rpcs_in_flight == 0);
 	return osc_cleanup_common(obd);
 }
 
fs/lustre/obdclass/genops.c +7 -4
index b6bde00..43772aa 100644
@@ -1487,6 +1487,7 @@ int obd_mod_rpc_stats_seq_show(struct client_obd *cli, struct seq_file *seq)
 struct mod_waiter {
 	struct client_obd *cli;
 	bool close_req;
+	bool woken;
 	wait_queue_entry_t wqe;
 };
 static int claim_mod_rpc_function(wait_queue_entry_t *wq_entry,
@@ -1499,10 +1500,9 @@ static int claim_mod_rpc_function(wait_queue_entry_t *wq_entry,
 	int ret;
 
 	/* As woken_wake_function() doesn't remove us from the wait_queue,
-	 * we could get called twice for the same thread - take care.
+	 * we use own flag to ensure we're called just once.
 	 */
-	if (wq_entry->flags & WQ_FLAG_WOKEN)
-		/* Already woke this thread, don't try again */
+	if (w->woken)
 		return 0;
 
 	/* A slot is available if
@@ -1516,6 +1516,7 @@ static int claim_mod_rpc_function(wait_queue_entry_t *wq_entry,
 		if (w->close_req)
 			cli->cl_close_rpcs_in_flight++;
 		ret = woken_wake_function(wq_entry, mode, flags, key);
+		w->woken = true;
 	} else if (cli->cl_close_rpcs_in_flight)
 		/* No other waiter could be woken */
 		ret = -1;
@@ -1543,6 +1544,7 @@ u16 obd_get_mod_rpc_slot(struct client_obd *cli, u32 opc)
 	struct mod_waiter wait = {
 		.cli = cli,
 		.close_req = (opc == MDS_CLOSE),
+		.woken = false,
 	};
 	u16 i, max;
 
@@ -1556,7 +1558,8 @@ u16 obd_get_mod_rpc_slot(struct client_obd *cli, u32 opc)
 	 * and there will be no need to wait.
 	 */
 	wake_up_locked(&cli->cl_mod_rpcs_waitq);
-	if (!(wait.wqe.flags & WQ_FLAG_WOKEN)) {
+	/* XXX: handle spurious wakeups (from unknown yet source */
+	while (wait.woken == false) {
 		spin_unlock_irq(&cli->cl_mod_rpcs_waitq.lock);
 		wait_woken(&wait.wqe, TASK_UNINTERRUPTIBLE,
 			   MAX_SCHEDULE_TIMEOUT);
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#13 lore raw

PATCH 13/27 lnet: libcfs: cleanup console messages

In reply to James Simmons

From: Andreas Dilger <[email protected]>

Change early libcfs cfs_cpu_init() messages from CERROR() to pr_err() to avoid circular dependencies on libcfs setup before printing an error message to the console during module init.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16639
Lustre-commit: 8f40a3d7110da1af8e ("LU-16639 misc: cleanup concole messages")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50283

---
 net/lnet/libcfs/libcfs_cpu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
net/lnet/libcfs/libcfs_cpu.c +7 -7
index dca92cd..a5bf4f6 100644
@@ -1177,27 +1177,27 @@ int cfs_cpu_init(void)
 	if (*cpu_pattern) {
 		cfs_cpt_tab = cfs_cpt_table_create_pattern(cpu_pattern);
 		if (IS_ERR(cfs_cpt_tab)) {
-			CERROR("Failed to create cptab from pattern '%s'\n",
-			       cpu_pattern);
 			ret = PTR_ERR(cfs_cpt_tab);
+			pr_err("libcfs: failed to create cptab from pattern '%s': rc = %d\n",
+			       cpu_pattern, ret);
 			goto failed_alloc_table;
 		}
 
 	} else {
 		cfs_cpt_tab = cfs_cpt_table_create(cpu_npartitions);
 		if (IS_ERR(cfs_cpt_tab)) {
-			CERROR("Failed to create cptab with npartitions %d\n",
-			       cpu_npartitions);
 			ret = PTR_ERR(cfs_cpt_tab);
+			pr_err("libcfs: failed to create cptab with npartitions=%d: rc = %d\n",
+			       cpu_npartitions, ret);
 			goto failed_alloc_table;
 		}
 	}
 
 	put_online_cpus();
 
-	LCONSOLE(0, "HW NUMA nodes: %d, HW CPU cores: %d, npartitions: %d\n",
-		 num_online_nodes(), num_online_cpus(),
-		 cfs_cpt_number(cfs_cpt_tab));
+	pr_notice("libcfs: HW NUMA nodes: %d, HW CPU cores: %d, npartitions: %d\n",
+		  num_online_nodes(), num_online_cpus(),
+		  cfs_cpt_number(cfs_cpt_tab));
 	return 0;
 
 failed_alloc_table:
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#14 lore raw

PATCH 14/27 lustre: ldlm: clear lock converting flag on resource cleanup

In reply to James Simmons

From: Bobi Jam <[email protected]>

During resource cleanup clear lock's converting flag so that ldlm_cli_cancel() won't erroneously trip the assertion, the assertion is used for normal lock revoke callbacks.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16371
Lustre-commit: 4990f4ef5eb81d8017 ("LU-16371 ldlm: clear lock converting flag on resource cleanup")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49339

---
 fs/lustre/ldlm/ldlm_resource.c | 1 +
 1 file changed, 1 insertion(+)
fs/lustre/ldlm/ldlm_resource.c +1 -0
index 9a269cb..28f64b6 100644
@@ -794,6 +794,7 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
 		 */
 		ldlm_set_cbpending(lock);
 		ldlm_set_failed(lock);
+		ldlm_clear_converting(lock);
 		lock->l_flags |= flags;
 
 		/* ... without sending a CANCEL message for local_only. */
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#15 lore raw

PATCH 15/27 lustre: statahead: statahead thread doesn't stop

In reply to James Simmons

From: Yang Sheng <[email protected]>

Add a barrier to ensure sai_task changing can be seen when access it without locking. Else the statahead thread could sleep forever since wake_up was lost.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15660
Lustre-commit: b977caa2dc7dddcec ("LU-15660 statahead: statahead thread doesn't stop")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/47673

---
 fs/lustre/llite/statahead.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
fs/lustre/llite/statahead.c +15 -8
index e6ea2ee..12d8266 100644
@@ -1005,7 +1005,8 @@ static int ll_statahead_thread(void *arg)
 		goto out;
 	}
 
-	while (pos != MDS_DIR_END_OFF && sai->sai_task) {
+	/* matches smp_store_release() in ll_deauthorize_statahead() */
+	while (pos != MDS_DIR_END_OFF && smp_load_acquire(&sai->sai_task)) {
 		struct lu_dirpage *dp;
 		struct lu_dirent *ent;
 
@@ -1029,7 +1030,9 @@ static int ll_statahead_thread(void *arg)
 
 		dp = page_address(page);
 		for (ent = lu_dirent_start(dp);
-		     ent && sai->sai_task && !sa_low_hit(sai);
+		     /* matches smp_store_release() in ll_deauthorize_statahead() */
+		     ent && smp_load_acquire(&sai->sai_task) &&
+		     !sa_low_hit(sai);
 		     ent = lu_dirent_next(ent)) {
 			struct lu_fid fid;
 			u64 hash;
@@ -1081,7 +1084,10 @@ static int ll_statahead_thread(void *arg)
 			fid_le_to_cpu(&fid, &ent->lde_fid);
 
 			while (({set_current_state(TASK_IDLE);
-				 sai->sai_task; })) {
+				 /* matches smp_store_release() in
+				  * ll_deauthorize_statahead()
+				  */
+				 smp_load_acquire(&sai->sai_task); })) {
 				spin_lock(&lli->lli_agl_lock);
 				while (sa_sent_full(sai) &&
 				       !agl_list_empty(sai)) {
@@ -1163,7 +1169,8 @@ static int ll_statahead_thread(void *arg)
 	 * for file release closedir() call to stop me.
 	 */
 	while (({set_current_state(TASK_IDLE);
-		 sai->sai_task; })) {
+		/* matches smp_store_release() in ll_deauthorize_statahead() */
+		smp_load_acquire(&sai->sai_task); })) {
 		schedule();
 	}
 	__set_current_state(TASK_RUNNING);
@@ -1244,7 +1251,8 @@ void ll_deauthorize_statahead(struct inode *dir, void *key)
 		 */
 		struct task_struct *task = sai->sai_task;
 
-		sai->sai_task = NULL;
+		/* matches smp_load_acquire() in ll_statahead_thread() */
+		smp_store_release(&sai->sai_task, NULL);
 		wake_up_process(task);
 	}
 	spin_unlock(&lli->lli_sa_lock);
@@ -1634,11 +1642,10 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry,
 		goto out;
 	}
 
-	if (test_bit(LL_SBI_AGL_ENABLED, ll_i2sbi(parent->d_inode)->ll_flags) &&
-	    agl)
+	if (test_bit(LL_SBI_AGL_ENABLED, sbi->ll_flags) && agl)
 		ll_start_agl(parent, sai);
 
-	atomic_inc(&ll_i2sbi(parent->d_inode)->ll_sa_total);
+	atomic_inc(&sbi->ll_sa_total);
 	sai->sai_task = task;
 
 	wake_up_process(task);
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#16 lore raw

PATCH 16/27 lustre: uapi: fix unused function errors

In reply to James Simmons

From: Timothy Day <[email protected]>

Clang has default errors related to unused functions. The errors related to 'fid_flatten' and 'fid_flatten32' were resolved by moving the definitions of these functions to the 'lustre_fid' header. This is a better place for them, since they are small 'static inline' functions and has the added benefit of cutting down code duplication.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16518
Lustre-commit: 0991267eab728e9a6 ("LU-16518 utils: fix unused function errors")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49901

---
 fs/lustre/include/lustre_fid.h         | 61 ++-----------------------------
 fs/lustre/llite/lcommon_cl.c           |  4 +--
 include/uapi/linux/lustre/lustre_fid.h | 65 ++++++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+), 60 deletions(-)
fs/lustre/include/lustre_fid.h +3 -58
index 5ebe362..bc3f058 100644
@@ -536,68 +536,13 @@ static inline void ost_fid_build_resid(const struct lu_fid *fid,
 	}
 }
 
-/**
- * Flatten 128-bit FID values into a 64-bit value for use as an inode number.
- * For non-IGIF FIDs this starts just over 2^32, and continues without
- * conflict until 2^64, at which point we wrap the high 24 bits of the SEQ
- * into the range where there may not be many OID values in use, to minimize
- * the risk of conflict.
- *
- * Suppose LUSTRE_SEQ_MAX_WIDTH less than (1 << 24) which is currently true,
- * the time between re-used inode numbers is very long - 2^40 SEQ numbers,
- * or about 2^40 client mounts, if clients create less than 2^24 files/mount.
- */
-static inline u64 fid_flatten(const struct lu_fid *fid)
-{
-	u64 ino;
-	u64 seq;
-
-	if (fid_is_igif(fid)) {
-		ino = lu_igif_ino(fid);
-		return ino;
-	}
-
-	seq = fid_seq(fid);
-
-	ino = (seq << 24) + ((seq >> 24) & 0xffffff0000ULL) + fid_oid(fid);
-
-	return ino ? ino : fid_oid(fid);
-}
-
 static inline u32 fid_hash(const struct lu_fid *f, int bits)
 {
-	/* all objects with same id and different versions will belong to same
+	/*
+	 * All objects with same id and different versions will belong to same
 	 * collisions list.
 	 */
-	return hash_long(fid_flatten(f), 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;
-
-	if (fid_is_igif(fid)) {
-		ino = lu_igif_ino(fid);
-		return ino;
-	}
-
-	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);
-
-	return ino ? ino : fid_oid(fid);
+	return hash_long(fid_flatten64(f), bits);
 }
 
 static inline int lu_fid_diff(const struct lu_fid *fid1,
fs/lustre/llite/lcommon_cl.c +2 -2
index 2735d5c..9b0c6bc 100644
@@ -280,7 +280,7 @@ u64 cl_fid_build_ino(const struct lu_fid *fid, bool api32)
 	if (BITS_PER_LONG == 32 || api32)
 		return fid_flatten32(fid);
 	else
-		return fid_flatten(fid);
+		return fid_flatten64(fid);
 }
 
 /*
@@ -292,5 +292,5 @@ u32 cl_fid_build_gen(const struct lu_fid *fid)
 	if (fid_is_igif(fid))
 		return lu_igif_gen(fid);
 
-	return fid_flatten(fid) >> 32;
+	return fid_flatten64(fid) >> 32;
 }
include/uapi/linux/lustre/lustre_fid.h +65 -0

69 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#17 lore raw

PATCH 17/27 lnet: Health logging improvements

In reply to James Simmons

From: Chris Horn <[email protected]>

LNet health activity can generate noise in console logs. The NI/Peer NI recovery pings could be expected to fail and the related messages from lnet_handle_recovery_reply() are generally redundant.

Improve this logging by having the lnet_monitor_thread() provide a summary of NIs in recovery.

Another useful metric in spotting network trouble is if we have messages exceeding their deadline. We do not currently log this information. Keep a count of messages that have exceeded their deadline and track the total excess time. The lnet_monitor_thread() will then provide a summary of the number of messages and their average excess time at a regular interval. These stats are then reset when the monitor thread prints this information to the console.

Because NIs can be in recovery for extended periods of time, the interval of console updates will increase from 1 to 5 minutes. The interval is reset when it is detected that there are no longer any NIs in recovery and there haven't been any messages past their deadline since the last console update.

HPE-bug-id: LUS-11500
WC-bug-id: https://jira.whamcloud.com/browse/LU-16643
Lustre-commit: 0cb3d86c4004d7581 ("LU-16643 lnet: Health logging improvements")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50305

---
 include/linux/lnet/lib-types.h |   5 ++
 net/lnet/lnet/api-ni.c         |   2 +
 net/lnet/lnet/lib-move.c       | 165 +++++++++++++++++++++++++++++++++++++++--
 net/lnet/lnet/lib-msg.c        |  16 +++-
 4 files changed, 176 insertions(+), 12 deletions(-)
include/linux/lnet/lib-types.h +5 -0
index eb54e75..1ae4530 100644
@@ -1529,6 +1529,11 @@ struct lnet {
 	struct completion		ln_started;
 	/* UDSP list */
 	struct list_head		ln_udsp_list;
+
+	/* Number of messages that have exceeded their message deadline */
+	atomic_t			ln_late_msg_count;
+	/* Total amount of time past their deadline for all late ^ messages */
+	atomic64_t			ln_late_msg_nsecs;
 };
 
 struct genl_filter_list {
net/lnet/lnet/api-ni.c +2 -0
index fb596ed..f3f9aee 100644
@@ -1295,6 +1295,8 @@ struct list_head **
 	init_waitqueue_head(&the_lnet.ln_dc_waitq);
 	the_lnet.ln_mt_handler = NULL;
 	init_completion(&the_lnet.ln_started);
+	atomic_set(&the_lnet.ln_late_msg_count, 0);
+	atomic64_set(&the_lnet.ln_late_msg_nsecs, 0);
 
 	rc = lnet_slab_setup();
 	if (rc != 0)
net/lnet/lnet/lib-move.c +157 -8

235 lines not on this page · raw message

net/lnet/lnet/lib-msg.c +12 -4
index 82d117d..420236d 100644
@@ -761,6 +761,7 @@
 	bool attempt_remote_resend;
 	bool handle_local_health;
 	bool handle_remote_health;
+	ktime_t now;
 
 	/* if we're shutting down no point in handling health. */
 	if (the_lnet.ln_mt_state != LNET_MT_STATE_RUNNING)
@@ -778,10 +779,6 @@
 		 nid_is_lo0(&msg->msg_txni->ni_nid))
 		lo = true;
 
-	if (hstatus != LNET_MSG_STATUS_OK &&
-	    ktime_after(ktime_get(), msg->msg_deadline))
-		return -1;
-
 	/* always prefer txni/txpeer if they message is committed for both
 	 * directions.
 	 */
@@ -802,6 +799,17 @@
 	else
 		LASSERT(ni);
 
+	now = ktime_get();
+	if (ktime_after(now, msg->msg_deadline)) {
+		s64 time = ktime_to_ns(ktime_sub(now, msg->msg_deadline));
+
+		atomic64_add(time, &the_lnet.ln_late_msg_nsecs);
+		atomic_inc(&the_lnet.ln_late_msg_count);
+
+		if (hstatus != LNET_MSG_STATUS_OK)
+			return -1;
+	}
+
 	CDEBUG(D_NET, "health check: %s->%s: %s: %s\n",
 	       libcfs_nidstr(&ni->ni_nid),
 	       (lo) ? "self" : libcfs_nidstr(&lpni->lpni_nid),
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#18 lore raw

PATCH 18/27 lustre: update version to 2.15.54

In reply to James Simmons

From: Oleg Drokin <[email protected]>

New tag 2.15.54

---
 include/uapi/linux/lustre/lustre_ver.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/lustre/lustre_ver.h +2 -2
index bc7a49c..4a72d70 100644
@@ -3,9 +3,9 @@
 
 #define LUSTRE_MAJOR 2
 #define LUSTRE_MINOR 15
-#define LUSTRE_PATCH 54
+#define LUSTRE_PATCH 55
 #define LUSTRE_FIX 0
-#define LUSTRE_VERSION_STRING "2.15.54"
+#define LUSTRE_VERSION_STRING "2.15.55"
 
 #define OBD_OCD_VERSION(major, minor, patch, fix)			\
 	(((major) << 24) + ((minor) << 16) + ((patch) << 8) + (fix))
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#19 lore raw

PATCH 19/27 lustre: misc: remove unnecessary ioctl typecasts

In reply to James Simmons

From: Andreas Dilger <[email protected]>

Declare "void __user *uarg" in the ioctl handling code so that it isn't typecast on every access in the ioctl handler. Unnecessary typecast risks hiding compiler warnings and bugs.

Convert indentation to tabs for lines previously using spaces. Change local variable declarations to use only a single space.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16634
Lustre-commit: 4a1465577e1310ce09 ("LU-16634 misc: remove unnecessary ioctl typecasts")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50333

---
 fs/lustre/include/obd_class.h    |   2 +-
 fs/lustre/llite/dir.c            |  62 +++++++++--------
 fs/lustre/llite/file.c           | 142 +++++++++++++++++----------------------
 fs/lustre/llite/llite_internal.h |  14 ++--
 fs/lustre/llite/llite_lib.c      |  15 ++---
 fs/lustre/obdclass/class_obd.c   |  16 ++---
 6 files changed, 115 insertions(+), 136 deletions(-)
fs/lustre/include/obd_class.h +1 -1
index 123a214..0c95c3c 100644
@@ -58,7 +58,7 @@
 
 /* OBD Operations Declarations */
 struct obd_device *class_exp2obd(struct obd_export *exp);
-int class_handle_ioctl(unsigned int cmd, unsigned long arg);
+int class_handle_ioctl(unsigned int cmd, void __user *uarg);
 int lustre_get_jobid(char *jobid, size_t len);
 void jobid_cache_fini(void);
 int jobid_cache_init(void);
fs/lustre/llite/dir.c +30 -32

203 lines not on this page · raw message

fs/lustre/llite/file.c +63 -79

437 lines not on this page · raw message

fs/lustre/llite/llite_internal.h +6 -8
index fdc0f89..6590399 100644
@@ -1222,12 +1222,10 @@ int ll_get_fid_by_name(struct inode *parent, const char *name,
 int ll_inode_permission(struct inode *inode, int mask);
 int ll_ioctl_check_project(struct inode *inode, u32 xflags, u32 projid);
 int ll_ioctl_fsgetxattr(struct inode *inode, unsigned int cmd,
-			unsigned long arg);
+			void __user *uarg);
 int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd,
-			unsigned long arg);
-int ll_ioctl_project(struct file *file, unsigned int cmd,
-		     unsigned long arg);
-
+			void __user *uarg);
+int ll_ioctl_project(struct file *file, unsigned int cmd, void __user *uarg);
 int ll_lov_setstripe_ea_info(struct inode *inode, struct dentry *dentry,
 			     u64 flags, struct lov_user_md *lum,
 			     int lum_size);
@@ -1290,7 +1288,7 @@ int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs,
 void ll_truncate_inode_pages_final(struct inode *inode, struct cl_io *io);
 void ll_delete_inode(struct inode *inode);
 int ll_iocontrol(struct inode *inode, struct file *file,
-		 unsigned int cmd, unsigned long arg);
+		 unsigned int cmd, void __user *uarg);
 int ll_flush_ctx(struct inode *inode);
 void ll_umount_begin(struct super_block *sb);
 int ll_remount_fs(struct super_block *sb, int *flags, char *data);
@@ -1298,7 +1296,7 @@ int ll_iocontrol(struct inode *inode, struct file *file,
 void ll_dirty_page_discard_warn(struct inode *inode, int ioret);
 int ll_prep_inode(struct inode **inode, struct req_capsule *pill,
 		  struct super_block *sb, struct lookup_intent *it);
-int ll_obd_statfs(struct inode *inode, void __user *arg);
+int ll_obd_statfs(struct inode *inode, void __user *uarg);
 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
 int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize);
 int ll_set_default_mdsize(struct ll_sb_info *sbi, int default_mdsize);
@@ -1310,7 +1308,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
 				      u32 mode, enum md_op_code opc,
 				      void *data);
 void ll_finish_md_op_data(struct md_op_data *op_data);
-int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg);
+int ll_get_obd_name(struct inode *inode, unsigned int cmd, void __user *uarg);
 void ll_compute_rootsquash_state(struct ll_sb_info *sbi);
 ssize_t ll_copy_user_md(const struct lov_user_md __user *md,
 			struct lov_user_md **kbuf);
fs/lustre/llite/llite_lib.c +7 -8
index 049cd23..913e096 100644
@@ -2853,7 +2853,7 @@ void ll_delete_inode(struct inode *inode)
 }
 
 int ll_iocontrol(struct inode *inode, struct file *file,
-		 unsigned int cmd, unsigned long arg)
+		 unsigned int cmd, void __user *uarg)
 {
 	struct ll_sb_info *sbi = ll_i2sbi(inode);
 	struct ptlrpc_request *req = NULL;
@@ -2891,7 +2891,7 @@ int ll_iocontrol(struct inode *inode, struct file *file,
 
 		ptlrpc_req_finished(req);
 
-		return put_user(flags, (int __user *)arg);
+		return put_user(flags, (int __user *)uarg);
 	}
 	case FS_IOC_SETFLAGS: {
 		struct md_op_data *op_data;
@@ -2899,7 +2899,7 @@ int ll_iocontrol(struct inode *inode, struct file *file,
 		struct iattr *attr;
 		struct fsxattr fa = { 0 };
 
-		if (get_user(flags, (int __user *)arg))
+		if (get_user(flags, (int __user *)uarg))
 			return -EFAULT;
 
 		fa.fsx_projid = ll_i2info(inode)->lli_projid;
@@ -3219,7 +3219,7 @@ int ll_prep_inode(struct inode **inode, struct req_capsule *pill,
 	return rc;
 }
 
-int ll_obd_statfs(struct inode *inode, void __user *arg)
+int ll_obd_statfs(struct inode *inode, void __user *uarg)
 {
 	struct ll_sb_info *sbi = NULL;
 	struct obd_export *exp;
@@ -3238,7 +3238,7 @@ int ll_obd_statfs(struct inode *inode, void __user *arg)
 		goto out_statfs;
 	}
 
-	rc = obd_ioctl_getdata(&data, &len, arg);
+	rc = obd_ioctl_getdata(&data, &len, uarg);
 	if (rc)
 		goto out_statfs;
 
@@ -3491,7 +3491,7 @@ int ll_show_options(struct seq_file *seq, struct dentry *dentry)
 /**
  * Get obd name by cmd, and copy out to user space
  */
-int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg)
+int ll_get_obd_name(struct inode *inode, unsigned int cmd, void __user *uarg)
 {
 	struct ll_sb_info *sbi = ll_i2sbi(inode);
 	struct obd_device *obd;
@@ -3506,8 +3506,7 @@ int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg)
 	if (!obd)
 		return -ENOENT;
 
-	if (copy_to_user((void __user *)arg, obd->obd_name,
-			 strlen(obd->obd_name) + 1))
+	if (copy_to_user(uarg, obd->obd_name, strlen(obd->obd_name) + 1))
 		return -EFAULT;
 
 	return 0;
fs/lustre/obdclass/class_obd.c +8 -8
index 67a9422..a7a2a6c 100644
@@ -277,14 +277,14 @@ int obd_ioctl_getdata(struct obd_ioctl_data **datap, int *len, void __user *arg)
 }
 EXPORT_SYMBOL(obd_ioctl_getdata);
 
-int class_handle_ioctl(unsigned int cmd, unsigned long arg)
+int class_handle_ioctl(unsigned int cmd, void __user *uarg)
 {
 	struct obd_ioctl_data *data;
 	struct obd_device *obd = NULL;
 	int err = 0, len = 0;
 
 	CDEBUG(D_IOCTL, "cmd = %x\n", cmd);
-	if (obd_ioctl_getdata(&data, &len, (void __user *)arg)) {
+	if (obd_ioctl_getdata(&data, &len, uarg)) {
 		CERROR("OBD ioctl: data error\n");
 		return -EINVAL;
 	}
@@ -341,7 +341,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 		memcpy(data->ioc_bulk, LUSTRE_VERSION_STRING,
 		       strlen(LUSTRE_VERSION_STRING) + 1);
 
-		if (copy_to_user((void __user *)arg, data, len))
+		if (copy_to_user(uarg, data, len))
 			err = -EFAULT;
 		goto out;
 	}
@@ -359,7 +359,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 			goto out;
 		}
 
-		if (copy_to_user((void __user *)arg, data, sizeof(*data)))
+		if (copy_to_user(uarg, data, sizeof(*data)))
 			err = -EFAULT;
 		goto out;
 	}
@@ -396,7 +396,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 		CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
 		       dev);
 
-		if (copy_to_user((void __user *)arg, data, sizeof(*data)))
+		if (copy_to_user(uarg, data, sizeof(*data)))
 			err = -EFAULT;
 		goto out;
 	}
@@ -438,7 +438,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 			 obd->obd_name, obd->obd_uuid.uuid,
 			 atomic_read(&obd->obd_refcount));
 
-		if (copy_to_user((void __user *)arg, data, len))
+		if (copy_to_user(uarg, data, len))
 			err = -EFAULT;
 		goto out;
 	}
@@ -479,7 +479,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 	if (err)
 		goto out;
 
-	if (copy_to_user((void __user *)arg, data, len))
+	if (copy_to_user(uarg, data, len))
 		err = -EFAULT;
 out:
 	kvfree(data);
@@ -497,7 +497,7 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd,
 	if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */
 		return -ENOTTY;
 
-	return class_handle_ioctl(cmd, (unsigned long)arg);
+	return class_handle_ioctl(cmd, (void __user *)arg);
 }
 
 /* declare character device */
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#20 lore raw

PATCH 20/27 lustre: llite: move common ioctl code to ll_iocontrol()

In reply to James Simmons

From: Andreas Dilger <[email protected]>

Move common ioctl cases from ll_dir_ioctl() and ll_file_ioctl() into ll_iocontrol() to avoid duplicate code.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16634
Lustre-commit: 3be425883918528ef9 ("LU-16634 llite: move common ioctl code to ll_iocontrol()")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50335

---
 fs/lustre/llite/dir.c       |  92 ++-------------------------
 fs/lustre/llite/file.c      |  57 ++---------------
 fs/lustre/llite/llite_lib.c | 152 ++++++++++++++++++++++++++++++++++++++------
 3 files changed, 143 insertions(+), 158 deletions(-)
fs/lustre/llite/dir.c +5 -87
index 6bb95ad..9caff36 100644
@@ -1476,31 +1476,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 	ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_IOCTL, 1);
 	switch (cmd) {
-	case FS_IOC_GETFLAGS:
-	case FS_IOC_SETFLAGS:
-		return ll_iocontrol(inode, file, cmd, uarg);
-	case FSFILT_IOC_GETVERSION:
-	case FS_IOC_GETVERSION:
-		return put_user(inode->i_generation, (int __user *)arg);
-	/* We need to special case any other ioctls we want to handle,
-	 * to send them to the MDS/OST as appropriate and to properly
-	 * network encode the arg field.
-	 */
-	case FS_IOC_SETVERSION:
-		return -ENOTSUPP;
-
-	case LL_IOC_GET_MDTIDX: {
-		int mdtidx;
-
-		mdtidx = ll_get_mdt_idx(inode);
-		if (mdtidx < 0)
-			return mdtidx;
-
-		if (put_user((int)mdtidx, (int __user *)arg))
-			return -EFAULT;
-
-		return 0;
-	}
 	case IOC_MDC_LOOKUP: {
 		int namelen, len = 0;
 		char *filename;
@@ -1840,23 +1815,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		ptlrpc_req_finished(root_request);
 		return rc;
 	}
-
-	case LL_IOC_UNLOCK_FOREIGN:
-		/* if not a foreign symlink do nothing */
-		if (ll_foreign_is_removable(dentry, true)) {
-			CDEBUG(D_INFO,
-			       "prevent rmdir of non-foreign dir ("DFID")\n",
-			       PFID(ll_inode2fid(inode)));
-			return -EOPNOTSUPP;
-		}
-		return 0;
-
 	case LL_IOC_RMFID:
 		return ll_rmfid(file, (void __user *)arg);
 	case LL_IOC_LOV_SWAP_LAYOUTS:
 		return -EPERM;
-	case IOC_OBD_STATFS:
-		return ll_obd_statfs(inode, (void __user *)arg);
 	case LL_IOC_LOV_GETSTRIPE:
 	case LL_IOC_LOV_GETSTRIPE_NEW:
 	case LL_IOC_MDC_GETINFO_V1:
@@ -2088,14 +2050,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		kfree(qctl);
 		return rc;
 	}
-	case OBD_IOC_GETNAME_OLD:
-		fallthrough;
-	case OBD_IOC_GETDTNAME:
-		fallthrough;
-	case OBD_IOC_GETMDNAME:
-		return ll_get_obd_name(inode, cmd, uarg);
-	case LL_IOC_FLUSHCTX:
-		return ll_flush_ctx(inode);
 	case LL_IOC_GETOBDCOUNT: {
 		int count, vallen;
 		struct obd_export *exp;
@@ -2118,11 +2072,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 		return 0;
 	}
-	case LL_IOC_PATH2FID:
-		if (copy_to_user(uarg, ll_inode2fid(inode),
-				 sizeof(struct lu_fid)))
-			return -EFAULT;
-		return 0;
 	case LL_IOC_GET_CONNECT_FLAGS: {
 		return obd_iocontrol(cmd, sbi->ll_md_exp, 0, NULL,
 				     uarg);
@@ -2305,12 +2254,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 		return rc;
 	}
-	case FS_IOC_FSGETXATTR:
-		return ll_ioctl_fsgetxattr(inode, cmd, uarg);
-	case FS_IOC_FSSETXATTR:
-		return ll_ioctl_fssetxattr(inode, cmd, uarg);
-	case LL_IOC_PROJECT:
-		return ll_ioctl_project(file, cmd, uarg);
 	case LL_IOC_PCC_DETACH_BY_FID: {
 		struct lu_pcc_detach_fid *detach;
 		struct lu_fid *fid;
@@ -2356,38 +2299,13 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		kfree(detach);
 		return rc;
 	}
-#ifdef CONFIG_FS_ENCRYPTION
-	case FS_IOC_SET_ENCRYPTION_POLICY:
-		if (!ll_sbi_has_encrypt(ll_i2sbi(inode)))
-			return -EOPNOTSUPP;
-		return fscrypt_ioctl_set_policy(file, uarg);
-	case FS_IOC_GET_ENCRYPTION_POLICY_EX:
-		if (!ll_sbi_has_encrypt(ll_i2sbi(inode)))
-			return -EOPNOTSUPP;
-		return fscrypt_ioctl_get_policy_ex(file, uarg);
-	case FS_IOC_ADD_ENCRYPTION_KEY:
-		if (!ll_sbi_has_encrypt(ll_i2sbi(inode)))
-			return -EOPNOTSUPP;
-		rc = fscrypt_ioctl_add_key(file, uarg);
-		if (!rc)
-			sptlrpc_enc_pool_add_user();
-		return rc;
-	case FS_IOC_REMOVE_ENCRYPTION_KEY:
-		if (!ll_sbi_has_encrypt(ll_i2sbi(inode)))
-			return -EOPNOTSUPP;
-		return fscrypt_ioctl_remove_key(file, uarg);
-	case FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS:
-		if (!ll_sbi_has_encrypt(ll_i2sbi(inode)))
-			return -EOPNOTSUPP;
-		return fscrypt_ioctl_remove_key_all_users(file, uarg);
-	case FS_IOC_GET_ENCRYPTION_KEY_STATUS:
-		if (!ll_sbi_has_encrypt(ll_i2sbi(inode)))
-			return -EOPNOTSUPP;
-		return fscrypt_ioctl_get_key_status(file, uarg);
-#endif
 	default:
-		return obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL, uarg);
+		rc = ll_iocontrol(inode, file, cmd, uarg);
+		if (rc == -ENOTTY)
+			rc = obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL, uarg);
+		break;
 	}
+	return rc;
 }
 
 static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin)
fs/lustre/llite/file.c +7 -50

77 lines not on this page · raw message

fs/lustre/llite/llite_lib.c +131 -21

216 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#21 lore raw

PATCH 21/27 lnet: change LNetAddPeer() to take struct lnet_nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Rather than an array of lnet_nid_t, LNetAddPeer now takes an array of struct lnet_nid.

The array passed is *always* from struct uuid_nid_data, so that data structure is changed to store struct lnet_nid.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 42b49afdc8a4d2ec65 ("LU-10391 lnet: change LNetAddPeer() to take struct lnet_nid")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50085

---
 fs/lustre/obdclass/lustre_peer.c | 34 +++++++++++++++++++---------------
 include/linux/lnet/api.h         |  2 +-
 net/lnet/lnet/peer.c             | 17 +++++++----------
 3 files changed, 27 insertions(+), 26 deletions(-)
fs/lustre/obdclass/lustre_peer.c +19 -15
index 5eae2eb..2049c41 100644
@@ -44,7 +44,7 @@ struct uuid_nid_data {
 	struct list_head	un_list;
 	struct obd_uuid		un_uuid;
 	int			un_nid_count;
-	lnet_nid_t		un_nids[MTI_NIDS_MAX];
+	struct lnet_nid		un_nids[MTI_NIDS_MAX];
 };
 
 /* FIXME: This should probably become more elegant than a global linked list */
@@ -65,7 +65,7 @@ int lustre_uuid_to_peer(const char *uuid, struct lnet_nid *peer_nid, int index)
 				break;
 
 			rc = 0;
-			lnet_nid4_to_nid(data->un_nids[index], peer_nid);
+			*peer_nid = data->un_nids[index];
 			break;
 		}
 	}
@@ -77,13 +77,15 @@ int lustre_uuid_to_peer(const char *uuid, struct lnet_nid *peer_nid, int index)
 /* Add a nid to a niduuid.  Multiple nids can be added to a single uuid;
  * LNET will choose the best one.
  */
-int class_add_uuid(const char *uuid, u64 nid)
+int class_add_uuid(const char *uuid, lnet_nid_t nid4)
 {
 	struct uuid_nid_data *data, *entry;
+	struct lnet_nid nid;
 	int found = 0;
 	int rc;
 
-	LASSERT(nid != 0);  /* valid newconfig NID is never zero */
+	LASSERT(nid4 != 0);  /* valid newconfig NID is never zero */
+	lnet_nid4_to_nid(nid4, &nid);
 
 	if (strlen(uuid) > UUID_MAX - 1)
 		return -EOVERFLOW;
@@ -103,7 +105,7 @@ int class_add_uuid(const char *uuid, u64 nid)
 
 			found = 1;
 			for (i = 0; i < entry->un_nid_count; i++)
-				if (nid == entry->un_nids[i])
+				if (nid_same(&nid, &entry->un_nids[i]))
 					break;
 
 			if (i == entry->un_nid_count) {
@@ -119,16 +121,16 @@ int class_add_uuid(const char *uuid, u64 nid)
 
 	if (found) {
 		CDEBUG(D_INFO, "found uuid %s %s cnt=%d\n", uuid,
-		       libcfs_nid2str(nid), entry->un_nid_count);
+		       libcfs_nidstr(&nid), entry->un_nid_count);
 		rc = LNetAddPeer(entry->un_nids, entry->un_nid_count);
 		CDEBUG(D_INFO, "Add peer %s rc = %d\n",
-		       libcfs_nid2str(data->un_nids[0]), rc);
+		       libcfs_nidstr(&data->un_nids[0]), rc);
 		kfree(data);
 	} else {
-		CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nid2str(nid));
+		CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nidstr(&nid));
 		rc = LNetAddPeer(data->un_nids, data->un_nid_count);
 		CDEBUG(D_INFO, "Add peer %s rc = %d\n",
-		       libcfs_nid2str(data->un_nids[0]), rc);
+		       libcfs_nidstr(&data->un_nids[0]), rc);
 	}
 	return 0;
 }
@@ -167,7 +169,7 @@ int class_del_uuid(const char *uuid)
 
 		CDEBUG(D_INFO, "del uuid %s %s/%d\n",
 		       obd_uuid2str(&data->un_uuid),
-		       libcfs_nid2str(data->un_nids[0]),
+		       libcfs_nidstr(&data->un_nids[0]),
 		       data->un_nid_count);
 
 		kfree(data);
@@ -200,7 +202,7 @@ int class_add_nids_to_uuid(struct obd_uuid *uuid, lnet_nid_t *nids,
 		matched = true;
 		CDEBUG(D_NET, "Updating UUID '%s'\n", obd_uuid2str(uuid));
 		for (i = 0; i < nid_count; i++)
-			entry->un_nids[i] = nids[i];
+			lnet_nid4_to_nid(nids[i], &entry->un_nids[i]);
 		entry->un_nid_count = nid_count;
 		break;
 	}
@@ -208,7 +210,7 @@ int class_add_nids_to_uuid(struct obd_uuid *uuid, lnet_nid_t *nids,
 	if (matched) {
 		rc = LNetAddPeer(entry->un_nids, entry->un_nid_count);
 		CDEBUG(D_INFO, "Add peer %s rc = %d\n",
-		       libcfs_nid2str(entry->un_nids[0]), rc);
+		       libcfs_nidstr(&entry->un_nids[0]), rc);
 	}
 
 	return 0;
@@ -216,13 +218,15 @@ int class_add_nids_to_uuid(struct obd_uuid *uuid, lnet_nid_t *nids,
 EXPORT_SYMBOL(class_add_nids_to_uuid);
 
 /* check if @nid exists in nid list of @uuid */
-int class_check_uuid(struct obd_uuid *uuid, u64 nid)
+int class_check_uuid(struct obd_uuid *uuid, lnet_nid_t nid4)
 {
 	struct uuid_nid_data *entry;
+	struct lnet_nid nid;
 	int found = 0;
 
+	lnet_nid4_to_nid(nid4, &nid);
 	CDEBUG(D_INFO, "check if uuid %s has %s.\n",
-	       obd_uuid2str(uuid), libcfs_nid2str(nid));
+	       obd_uuid2str(uuid), libcfs_nidstr(&nid));
 
 	spin_lock(&g_uuid_lock);
 	list_for_each_entry(entry, &g_uuid_list, un_list) {
@@ -233,7 +237,7 @@ int class_check_uuid(struct obd_uuid *uuid, u64 nid)
 
 		/* found the uuid, check if it has @nid */
 		for (i = 0; i < entry->un_nid_count; i++) {
-			if (entry->un_nids[i] == nid) {
+			if (nid_same(&entry->un_nids[i], &nid)) {
 				found = 1;
 				break;
 			}
include/linux/lnet/api.h +1 -1
index 7ea61cb..f6d6c17 100644
@@ -164,7 +164,7 @@ int LNetGet(struct lnet_nid *self,
 int LNetCtl(unsigned int cmd, void *arg);
 void LNetDebugPeer(struct lnet_processid *id);
 int LNetGetPeerDiscoveryStatus(void);
-int LNetAddPeer(lnet_nid_t *nids, u32 num_nids);
+int LNetAddPeer(struct lnet_nid *nids, u32 num_nids);
 
 /** @} lnet_misc */
 
net/lnet/lnet/peer.c +7 -10
index f1b0eb0d..9168641 100644
@@ -1341,7 +1341,7 @@ struct lnet_peer_ni *
 }
 
 int
-LNetAddPeer(lnet_nid_t *nids, u32 num_nids)
+LNetAddPeer(struct lnet_nid *nids, u32 num_nids)
 {
 	struct lnet_nid pnid = LNET_ANY_NID;
 	bool mr;
@@ -1361,14 +1361,11 @@ struct lnet_peer_ni *
 
 	rc = 0;
 	for (i = 0; i < num_nids; i++) {
-		struct lnet_nid nid;
-
-		if (nids[i] == LNET_NID_LO_0)
+		if (nid_is_lo0(&nids[i]))
 			continue;
 
-		lnet_nid4_to_nid(nids[i], &nid);
 		if (LNET_NID_IS_ANY(&pnid)) {
-			lnet_nid4_to_nid(nids[i], &pnid);
+			pnid = nids[i];
 			rc = lnet_add_peer_ni(&pnid, &LNET_ANY_NID, mr, flags);
 			if (rc == -EALREADY) {
 				struct lnet_peer *lp;
@@ -1384,11 +1381,11 @@ struct lnet_peer_ni *
 				lnet_peer_decref_locked(lp);
 			}
 		} else if (lnet_peer_discovery_disabled) {
-			lnet_nid4_to_nid(nids[i], &nid);
-			rc = lnet_add_peer_ni(&nid, &LNET_ANY_NID, mr, flags);
+			rc = lnet_add_peer_ni(&nids[i], &LNET_ANY_NID, mr,
+					      flags);
 		} else {
-			lnet_nid4_to_nid(nids[i], &nid);
-			rc = lnet_add_peer_ni(&pnid, &nid, mr, flags);
+			rc = lnet_add_peer_ni(&pnid, &nids[i], mr,
+					      flags);
 		}
 
 		if (rc && rc != -EEXIST)
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#22 lore raw

PATCH 22/27 lustre: obdclass: change class_add/check_uuid to large nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

class_add_uuid() and class_check_uuid() are changed to take a struct lnet_nid* rather than a u64 (aka lnet_nid_t).

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 16d84b030520c431da ("LU-10391 obdclass: change class_add/check_uuid to large nid")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50086

---
 fs/lustre/include/obd_class.h    |  4 ++--
 fs/lustre/ldlm/ldlm_lib.c        | 13 +++++++++----
 fs/lustre/obdclass/lustre_peer.c | 24 ++++++++++--------------
 fs/lustre/obdclass/obd_config.c  |  5 +++--
 4 files changed, 24 insertions(+), 22 deletions(-)
fs/lustre/include/obd_class.h +2 -2
index 0c95c3c..f77fd12 100644
@@ -1742,11 +1742,11 @@ struct lwp_register_item {
 /* lustre_peer.c    */
 int lustre_uuid_to_peer(const char *uuid, struct lnet_nid *peer_nid,
 			int index);
-int class_add_uuid(const char *uuid, u64 nid);
+int class_add_uuid(const char *uuid, struct lnet_nid *nid);
 int class_del_uuid(const char *uuid);
 int class_add_nids_to_uuid(struct obd_uuid *uuid, lnet_nid_t *nids,
 			   int nid_count);
-int class_check_uuid(struct obd_uuid *uuid, u64 nid);
+int class_check_uuid(struct obd_uuid *uuid, struct lnet_nid *nid);
 
 /* class_obd.c */
 extern char obd_jobid_name[];
fs/lustre/ldlm/ldlm_lib.c +9 -4
index b1ce0d4..4f9cf5f 100644
@@ -141,16 +141,18 @@ int client_import_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
 EXPORT_SYMBOL(client_import_add_conn);
 
 int client_import_dyn_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
-			       lnet_nid_t prim_nid, int priority)
+			       lnet_nid_t prim_nid4, int priority)
 {
 	struct ptlrpc_connection *ptlrpc_conn;
+	struct lnet_nid prim_nid;
 	int rc;
 
-	ptlrpc_conn = ptlrpc_uuid_to_connection(uuid, LNET_NIDNET(prim_nid));
+	lnet_nid4_to_nid(prim_nid4, &prim_nid);
+	ptlrpc_conn = ptlrpc_uuid_to_connection(uuid, LNET_NID_NET(&prim_nid));
 	if (!ptlrpc_conn) {
 		const char *str_uuid = obd_uuid2str(uuid);
 
-		rc = class_add_uuid(str_uuid, prim_nid);
+		rc = class_add_uuid(str_uuid, &prim_nid);
 		if (rc) {
 			CERROR("%s: failed to add UUID '%s': rc = %d\n",
 			       imp->imp_obd->obd_name, str_uuid, rc);
@@ -172,7 +174,10 @@ int client_import_add_nids_to_conn(struct obd_import *imp, lnet_nid_t *nids,
 
 	spin_lock(&imp->imp_lock);
 	list_for_each_entry(conn, &imp->imp_conn_list, oic_item) {
-		if (class_check_uuid(&conn->oic_uuid, nids[0])) {
+		struct lnet_nid nid;
+
+		lnet_nid4_to_nid(nids[0], &nid);
+		if (class_check_uuid(&conn->oic_uuid, &nid)) {
 			*uuid = conn->oic_uuid;
 			spin_unlock(&imp->imp_lock);
 			rc = class_add_nids_to_uuid(&conn->oic_uuid, nids,
fs/lustre/obdclass/lustre_peer.c +10 -14
index 2049c41..aae69d3 100644
@@ -77,15 +77,13 @@ int lustre_uuid_to_peer(const char *uuid, struct lnet_nid *peer_nid, int index)
 /* Add a nid to a niduuid.  Multiple nids can be added to a single uuid;
  * LNET will choose the best one.
  */
-int class_add_uuid(const char *uuid, lnet_nid_t nid4)
+int class_add_uuid(const char *uuid, struct lnet_nid *nid)
 {
 	struct uuid_nid_data *data, *entry;
-	struct lnet_nid nid;
 	int found = 0;
 	int rc;
 
-	LASSERT(nid4 != 0);  /* valid newconfig NID is never zero */
-	lnet_nid4_to_nid(nid4, &nid);
+	LASSERT(nid->nid_type != 0);  /* valid newconfig NID is never zero */
 
 	if (strlen(uuid) > UUID_MAX - 1)
 		return -EOVERFLOW;
@@ -95,7 +93,7 @@ int class_add_uuid(const char *uuid, lnet_nid_t nid4)
 		return -ENOMEM;
 
 	obd_str2uuid(&data->un_uuid, uuid);
-	data->un_nids[0] = nid;
+	data->un_nids[0] = *nid;
 	data->un_nid_count = 1;
 
 	spin_lock(&g_uuid_lock);
@@ -105,12 +103,12 @@ int class_add_uuid(const char *uuid, lnet_nid_t nid4)
 
 			found = 1;
 			for (i = 0; i < entry->un_nid_count; i++)
-				if (nid_same(&nid, &entry->un_nids[i]))
+				if (nid_same(nid, &entry->un_nids[i]))
 					break;
 
 			if (i == entry->un_nid_count) {
 				LASSERT(entry->un_nid_count < MTI_NIDS_MAX);
-				entry->un_nids[entry->un_nid_count++] = nid;
+				entry->un_nids[entry->un_nid_count++] = *nid;
 			}
 			break;
 		}
@@ -121,13 +119,13 @@ int class_add_uuid(const char *uuid, lnet_nid_t nid4)
 
 	if (found) {
 		CDEBUG(D_INFO, "found uuid %s %s cnt=%d\n", uuid,
-		       libcfs_nidstr(&nid), entry->un_nid_count);
+		       libcfs_nidstr(nid), entry->un_nid_count);
 		rc = LNetAddPeer(entry->un_nids, entry->un_nid_count);
 		CDEBUG(D_INFO, "Add peer %s rc = %d\n",
 		       libcfs_nidstr(&data->un_nids[0]), rc);
 		kfree(data);
 	} else {
-		CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nidstr(&nid));
+		CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nidstr(nid));
 		rc = LNetAddPeer(data->un_nids, data->un_nid_count);
 		CDEBUG(D_INFO, "Add peer %s rc = %d\n",
 		       libcfs_nidstr(&data->un_nids[0]), rc);
@@ -218,15 +216,13 @@ int class_add_nids_to_uuid(struct obd_uuid *uuid, lnet_nid_t *nids,
 EXPORT_SYMBOL(class_add_nids_to_uuid);
 
 /* check if @nid exists in nid list of @uuid */
-int class_check_uuid(struct obd_uuid *uuid, lnet_nid_t nid4)
+int class_check_uuid(struct obd_uuid *uuid, struct lnet_nid *nid)
 {
 	struct uuid_nid_data *entry;
-	struct lnet_nid nid;
 	int found = 0;
 
-	lnet_nid4_to_nid(nid4, &nid);
 	CDEBUG(D_INFO, "check if uuid %s has %s.\n",
-	       obd_uuid2str(uuid), libcfs_nidstr(&nid));
+	       obd_uuid2str(uuid), libcfs_nidstr(nid));
 
 	spin_lock(&g_uuid_lock);
 	list_for_each_entry(entry, &g_uuid_list, un_list) {
@@ -237,7 +233,7 @@ int class_check_uuid(struct obd_uuid *uuid, lnet_nid_t nid4)
 
 		/* found the uuid, check if it has @nid */
 		for (i = 0; i < entry->un_nid_count; i++) {
-			if (nid_same(&entry->un_nids[i], &nid)) {
+			if (nid_same(&entry->un_nids[i], nid)) {
 				found = 1;
 				break;
 			}
fs/lustre/obdclass/obd_config.c +3 -2
index f2173df..81021e1 100644
@@ -822,6 +822,7 @@ static int process_param2_config(struct lustre_cfg *lcfg)
 int class_process_config(struct lustre_cfg *lcfg)
 {
 	struct obd_device *obd;
+	struct lnet_nid nid;
 	int err;
 
 	LASSERT(lcfg && !IS_ERR(lcfg));
@@ -839,8 +840,8 @@ int class_process_config(struct lustre_cfg *lcfg)
 		       lustre_cfg_string(lcfg, 1), lcfg->lcfg_nid,
 		       libcfs_nid2str(lcfg->lcfg_nid));
 
-		err = class_add_uuid(lustre_cfg_string(lcfg, 1),
-				     lcfg->lcfg_nid);
+		lnet_nid4_to_nid(lcfg->lcfg_nid, &nid);
+		err = class_add_uuid(lustre_cfg_string(lcfg, 1), &nid);
 		goto out;
 	}
 	case LCFG_DEL_UUID: {
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#23 lore raw

PATCH 23/27 lustre: obdclass: rename class_parse_nid to class_parse_nid4

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Use the name "nid4" for class_parse_nid(), class_parse_nid_quiet(), parse_nid() and CLASS_PARSE_NID. This will allow a new class_parse_nid which handle larger nids.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: b4a28a3269fadb1059 ("LU-10391 lustre: rename class_parse_nid to class_parse_nid4")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50088

---
 fs/lustre/include/obd_class.h   |  5 ++---
 fs/lustre/obdclass/obd_config.c | 26 +++++++++++++-------------
 fs/lustre/obdclass/obd_mount.c  |  8 ++++----
 3 files changed, 19 insertions(+), 20 deletions(-)
fs/lustre/include/obd_class.h +2 -3
index f77fd12..2b66bc4 100644
@@ -144,10 +144,9 @@ struct cfg_interop_param {
 struct cfg_interop_param *class_find_old_param(const char *param,
 					       struct cfg_interop_param *ptr);
 int class_get_next_param(char **params, char *copy);
-int class_parse_nid(char *buf, lnet_nid_t *nid, char **endh);
-int class_parse_nid_quiet(char *buf, lnet_nid_t *nid, char **endh);
+int class_parse_nid4(char *buf, lnet_nid_t *nid4, char **endh);
+int class_parse_nid4_quiet(char *buf, lnet_nid_t *nid4, char **endh);
 int class_parse_net(char *buf, u32 *net, char **endh);
-int class_match_nid(char *buf, char *key, lnet_nid_t nid);
 int class_match_net(char *buf, char *key, u32 net);
 
 struct obd_device *class_incref(struct obd_device *obd,
fs/lustre/obdclass/obd_config.c +13 -13
index 81021e1..eb14ca8 100644
@@ -152,12 +152,12 @@ static int class_match_param(char *buf, const char *key, char **valp)
 	return 0;
 }
 
-static int parse_nid(char *buf, void *value, int quiet)
+static int parse_nid4(char *buf, void *value, int quiet)
 {
-	lnet_nid_t *nid = value;
+	lnet_nid_t *nid4 = value;
 
-	*nid = libcfs_str2nid(buf);
-	if (*nid != LNET_NID_ANY)
+	*nid4 = libcfs_str2nid(buf);
+	if (*nid4 != LNET_NID_ANY)
 		return 0;
 
 	if (!quiet)
@@ -175,7 +175,7 @@ static int parse_net(char *buf, void *value)
 }
 
 enum {
-	CLASS_PARSE_NID = 1,
+	CLASS_PARSE_NID4 = 1,
 	CLASS_PARSE_NET,
 };
 
@@ -208,8 +208,8 @@ static int class_parse_value(char *buf, int opc, void *value, char **endh,
 	switch (opc) {
 	default:
 		LBUG();
-	case CLASS_PARSE_NID:
-		rc = parse_nid(buf, value, quiet);
+	case CLASS_PARSE_NID4:
+		rc = parse_nid4(buf, value, quiet);
 		break;
 	case CLASS_PARSE_NET:
 		rc = parse_net(buf, value);
@@ -223,17 +223,17 @@ static int class_parse_value(char *buf, int opc, void *value, char **endh,
 	return 0;
 }
 
-int class_parse_nid(char *buf, lnet_nid_t *nid, char **endh)
+int class_parse_nid4(char *buf, lnet_nid_t *nid4, char **endh)
 {
-	return class_parse_value(buf, CLASS_PARSE_NID, (void *)nid, endh, 0);
+	return class_parse_value(buf, CLASS_PARSE_NID4, (void *)nid4, endh, 0);
 }
-EXPORT_SYMBOL(class_parse_nid);
+EXPORT_SYMBOL(class_parse_nid4);
 
-int class_parse_nid_quiet(char *buf, lnet_nid_t *nid, char **endh)
+int class_parse_nid4_quiet(char *buf, lnet_nid_t *nid4, char **endh)
 {
-	return class_parse_value(buf, CLASS_PARSE_NID, (void *)nid, endh, 1);
+	return class_parse_value(buf, CLASS_PARSE_NID4, (void *)nid4, endh, 1);
 }
-EXPORT_SYMBOL(class_parse_nid_quiet);
+EXPORT_SYMBOL(class_parse_nid4_quiet);
 
 char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index)
 {
fs/lustre/obdclass/obd_mount.c +4 -4
index 58ca72d..6eaa214 100644
@@ -228,7 +228,7 @@ int lustre_start_mgc(struct super_block *sb)
 
 	/* Use nids from mount line: uml1,1@elan:uml2,2@elan:/lustre */
 	ptr = lsi->lsi_lmd->lmd_dev;
-	if (class_parse_nid(ptr, &nid, &ptr) == 0)
+	if (class_parse_nid4(ptr, &nid, &ptr) == 0)
 		i++;
 	if (i == 0) {
 		CERROR("No valid MGS nids found.\n");
@@ -314,7 +314,7 @@ int lustre_start_mgc(struct super_block *sb)
 	i = 0;
 	/* Use nids from mount line: uml1,1@elan:uml2,2@elan:/lustre */
 	ptr = lsi->lsi_lmd->lmd_dev;
-	while (class_parse_nid(ptr, &nid, &ptr) == 0) {
+	while (class_parse_nid4(ptr, &nid, &ptr) == 0) {
 		rc = do_lcfg(mgcname, nid,
 			     LCFG_ADD_UUID, niduuid, NULL, NULL, NULL);
 		if (!rc)
@@ -354,7 +354,7 @@ int lustre_start_mgc(struct super_block *sb)
 		/* New failover node */
 		sprintf(niduuid, "%s_%x", mgcname, i);
 		j = 0;
-		while (class_parse_nid_quiet(ptr, &nid, &ptr) == 0) {
+		while (class_parse_nid4_quiet(ptr, &nid, &ptr) == 0) {
 			rc = do_lcfg(mgcname, nid, LCFG_ADD_UUID, niduuid,
 				     NULL, NULL, NULL);
 			if (!rc)
@@ -870,7 +870,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)
 	int oldlen = 0;
 
 	/* Find end of nidlist */
-	while (class_parse_nid_quiet(tail, &nid, &tail) == 0)
+	while (class_parse_nid4_quiet(tail, &nid, &tail) == 0)
 		;
 	length = tail - *ptr;
 	if (length == 0) {
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#24 lore raw

PATCH 24/27 lustre: llite: only first sync to MDS matter

In reply to James Simmons

From: Alex Zhuravlev <[email protected]>

fsync() is supposed to sync metadata and data, but given file's layout the only first MDS_SYNC matters to ensure the file creation has been committed, everything else go to OSTs (data and attributes) also, uid/gid/mode, EAs and ACLs must be subject to sync.

WC-bug-id: https://jira.whamcloud.com/browse/LU-11404
Lustre-commit: 1c8a49bedff2746775 ("LU-11404 llite: only first sync to MDS matter")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/33175

---
 fs/lustre/llite/acl.c            |  2 ++
 fs/lustre/llite/file.c           | 19 ++++++++++++++-----
 fs/lustre/llite/llite_internal.h |  1 +
 fs/lustre/llite/llite_lib.c      |  1 +
 fs/lustre/llite/xattr.c          |  1 +
 5 files changed, 19 insertions(+), 5 deletions(-)
fs/lustre/llite/acl.c +2 -0
index bd045cc..91a7421 100644
@@ -94,6 +94,8 @@ int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 	rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
 			 value ? OBD_MD_FLXATTR : OBD_MD_FLXATTRRM,
 			 name, value, value_size, 0, 0, &req);
+	if (!rc)
+		ll_i2info(inode)->lli_synced_to_mds = false;
 
 	ptlrpc_req_finished(req);
 out_value:
fs/lustre/llite/file.c +14 -5
index ceac08c..0186db4 100644
@@ -4758,11 +4758,20 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 		}
 	}
 
-	err = md_fsync(ll_i2sbi(inode)->ll_md_exp, ll_inode2fid(inode), &req);
-	if (!rc)
-		rc = err;
-	if (!err)
-		ptlrpc_req_finished(req);
+	if (S_ISREG(inode->i_mode) && !lli->lli_synced_to_mds) {
+		/*
+		 * only the first sync on MDS makes sense,
+		 * everything else is stored on OSTs
+		 */
+		err = md_fsync(ll_i2sbi(inode)->ll_md_exp,
+			       ll_inode2fid(inode), &req);
+		if (!rc)
+			rc = err;
+		if (!err) {
+			lli->lli_synced_to_mds = true;
+			ptlrpc_req_finished(req);
+		}
+	}
 
 	if (S_ISREG(inode->i_mode)) {
 		struct ll_file_data *fd = file->private_data;
fs/lustre/llite/llite_internal.h +1 -0
index 6590399..129c817 100644
@@ -155,6 +155,7 @@ struct ll_inode_info {
 	s64				lli_ctime;
 	s64				lli_btime;
 	spinlock_t			lli_agl_lock;
+	bool				lli_synced_to_mds;
 
 	/* inode specific open lock caching threshold */
 	u32				lli_open_thrsh_count;
fs/lustre/llite/llite_lib.c +1 -0
index c54ca1f..002e870 100644
@@ -2181,6 +2181,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr,
 	rc = ll_md_setattr(dentry, op_data);
 	if (rc)
 		goto out;
+	lli->lli_synced_to_mds = false;
 
 	if (!S_ISREG(inode->i_mode) || hsm_import) {
 		rc = 0;
fs/lustre/llite/xattr.c +1 -0
index c90f501..ceaad60 100644
@@ -160,6 +160,7 @@ static int ll_xattr_set_common(const struct xattr_handler *handler,
 		}
 		return rc;
 	}
+	ll_i2info(inode)->lli_synced_to_mds = false;
 
 	ptlrpc_req_finished(req);
 
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#25 lore raw

PATCH 25/27 lustre: statahead: batched statahead processing

In reply to James Simmons

From: Qian Yingjin <[email protected]>

Batched metadata processing can get a big performance boost. In this patch, it implements a batched statahead mechanism which can also increase the performance for a directory traverse or listing such as the command 'ls'.

For the batched statahead, one batch getattr() RPC equals to 'N' normal lookup/getattr RPCs. It can pack a number of dentry name getting from the readdir() call and prepared lock handles one client side lock namespace into one large batched RPC transferring via bulk I/O to obtain ibits DLM locks and associated attributes for a lot of files in one blow. When MDS receives a batched getattr() RPC, it executes the sub requests in it one by one serially.

A tunable parameter named "statahead_batch_max" is defined, it means the maximal items can be batched and processed within one aggregate RPC. Once the number of sub requests exceeds this predefined limit, it will pack and trigger the batched RPC. The batched RPC will also be triggered explicitly when the readdir() call comes to the end position of the directory or the statahead thread exits abnormally.

Batched metadata processing can get a big performance boost. The mdtest performance results without/with this patch series are as follow:
mdtest-easy-stat 720.562369 kIOPS : time 118.695 seconds
mdtest-easy-stat 1218.290192 kIOPS : time 70.656 seconds

In this patch, we set statahead_batch_max=0 and disabled batched statahead by default. It will enable accordingly once some subsequent fixes about batched RPC have been merged.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14139
Lustre-commit: 4435d0121f72aac3ad ("LU-14139 statahead: batched statahead processing")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/40720

---
 fs/lustre/include/lustre_dlm.h        |  10 ++-
 fs/lustre/include/lustre_req_layout.h |   7 ++
 fs/lustre/include/obd.h               |   2 +
 fs/lustre/ldlm/ldlm_request.c         |  80 ++++++++++++++---
 fs/lustre/llite/llite_internal.h      |  18 +++-
 fs/lustre/llite/llite_lib.c           |   4 +-
 fs/lustre/llite/lproc_llite.c         |  47 ++++++++--
 fs/lustre/llite/statahead.c           |  98 +++++++++++++++++---
 fs/lustre/lmv/lmv_obd.c               |  27 ++++++
 fs/lustre/mdc/mdc_batch.c             | 163 +++++++++++++++++++++++++++++++++-
 fs/lustre/mdc/mdc_dev.c               |   4 +-
 fs/lustre/mdc/mdc_internal.h          |   6 ++
 fs/lustre/mdc/mdc_locks.c             |  24 ++---
 fs/lustre/osc/osc_request.c           |   5 +-
 fs/lustre/ptlrpc/layout.c             |  40 +++++++++
 15 files changed, 485 insertions(+), 50 deletions(-)
fs/lustre/include/lustre_dlm.h +9 -1
index d08c48f..a3a339f 100644
@@ -1342,11 +1342,19 @@ int ldlm_prep_elc_req(struct obd_export *exp,
 		      struct list_head *cancels, int count);
 
 struct ptlrpc_request *ldlm_enqueue_pack(struct obd_export *exp, int lvb_len);
-int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
+int ldlm_cli_enqueue_fini(struct obd_export *exp, struct req_capsule *pill,
 			  struct ldlm_enqueue_info *einfo, u8 with_policy,
 			  u64 *flags, void *lvb, u32 lvb_len,
 			  const struct lustre_handle *lockh, int rc,
 			  bool request_slot);
+int ldlm_cli_lock_create_pack(struct obd_export *exp,
+			      struct ldlm_request *dlmreq,
+			      struct ldlm_enqueue_info *einfo,
+			      const struct ldlm_res_id *res_id,
+			      union ldlm_policy_data const *policy,
+			      u64 *flags, void *lvb, u32 lvb_len,
+			      enum lvb_type lvb_type,
+			      struct lustre_handle *lockh);
 int ldlm_cli_convert_req(struct ldlm_lock *lock, u32 *flags, u64 new_bits);
 int ldlm_cli_convert(struct ldlm_lock *lock,
 		     enum ldlm_cancel_flags cancel_flags);
fs/lustre/include/lustre_req_layout.h +7 -0
index a7ed89b..505e9a1 100644
@@ -80,6 +80,12 @@ void req_capsule_init(struct req_capsule *pill, struct ptlrpc_request *req,
 void req_capsule_fini(struct req_capsule *pill);
 
 void req_capsule_set(struct req_capsule *pill, const struct req_format *fmt);
+void req_capsule_subreq_init(struct req_capsule *pill,
+			     const struct req_format *fmt,
+			     struct ptlrpc_request *req,
+			     struct lustre_msg *reqmsg,
+			     struct lustre_msg *repmsg,
+			     enum req_location loc);
 size_t req_capsule_filled_sizes(struct req_capsule *pill,
 				enum req_location loc);
 int req_capsule_server_pack(struct req_capsule *pill);
@@ -282,6 +288,7 @@ static inline void req_capsule_set_rep_swabbed(struct req_capsule *pill,
 extern struct req_format RQF_CONNECT;
 
 /* Batch UpdaTe req_format */
+extern struct req_format RQF_BUT_GETATTR;
 extern struct req_format RQF_MDS_BATCH;
 
 /* Batch UpdaTe format */
fs/lustre/include/obd.h +2 -0
index bd167ac..4d65775 100644
@@ -852,6 +852,8 @@ struct md_op_item {
 	struct inode			*mop_dir;
 	struct req_capsule		*mop_pill;
 	struct work_struct		 mop_work;
+	u64				 mop_lock_flags;
+	unsigned int			 mop_subpill_allocated:1;
 };
 
 enum lu_batch_flags {
fs/lustre/ldlm/ldlm_request.c +69 -11

129 lines not on this page · raw message

fs/lustre/llite/llite_internal.h +14 -4
index 129c817..6088da08 100644
@@ -792,6 +792,9 @@ struct ll_sb_info {
 	unsigned int		ll_sa_running_max; /* max concurrent
 						    * statahead instances
 						    */
+	unsigned int		ll_sa_batch_max;/* max SUB request count in
+						 * a batch PTLRPC request
+						 */
 	unsigned int		ll_sa_max;	/* max statahead RPCs */
 	atomic_t		ll_sa_total;	/* statahead thread started
 						 * count
@@ -1520,9 +1523,10 @@ enum ras_update_flags {
 void ll_ra_stats_inc(struct inode *inode, enum ra_stat which);
 
 /* statahead.c */
-#define LL_SA_RPC_MIN	   2
-#define LL_SA_RPC_DEF	   32
-#define LL_SA_RPC_MAX		512
+
+#define LL_SA_RPC_MIN		8
+#define LL_SA_RPC_DEF		32
+#define LL_SA_RPC_MAX		2048
 
 /* XXX: If want to support more concurrent statahead instances,
  *	please consider to decentralize the RPC lists attached
@@ -1532,7 +1536,10 @@ enum ras_update_flags {
 #define LL_SA_RUNNING_MAX	256
 #define LL_SA_RUNNING_DEF	16
 
-#define LL_SA_CACHE_BIT	 5
+#define LL_SA_BATCH_MAX		1024
+#define LL_SA_BATCH_DEF		0
+
+#define LL_SA_CACHE_BIT		5
 #define LL_SA_CACHE_SIZE	BIT(LL_SA_CACHE_BIT)
 #define LL_SA_CACHE_MASK	(LL_SA_CACHE_SIZE - 1)
 
@@ -1576,6 +1583,9 @@ struct ll_statahead_info {
 	struct list_head	sai_cache[LL_SA_CACHE_SIZE];
 	spinlock_t		sai_cache_lock[LL_SA_CACHE_SIZE];
 	atomic_t		sai_cache_count; /* entry count in cache */
+	struct lu_batch		*sai_bh;
+	u32			sai_max_batch_count;
+	u64			sai_index_end;
 };
 
 int ll_revalidate_statahead(struct inode *dir, struct dentry **dentry,
fs/lustre/llite/llite_lib.c +3 -1
index 002e870..b1bbeb3 100644
@@ -167,6 +167,7 @@ static struct ll_sb_info *ll_init_sbi(struct lustre_sb_info *lsi)
 
 	/* metadata statahead is enabled by default */
 	sbi->ll_sa_running_max = LL_SA_RUNNING_DEF;
+	sbi->ll_sa_batch_max = LL_SA_BATCH_DEF;
 	sbi->ll_sa_max = LL_SA_RPC_DEF;
 	atomic_set(&sbi->ll_sa_total, 0);
 	atomic_set(&sbi->ll_sa_wrong, 0);
@@ -324,7 +325,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 				   OBD_CONNECT2_GETATTR_PFID |
 				   OBD_CONNECT2_DOM_LVB |
 				   OBD_CONNECT2_REP_MBITS |
-				   OBD_CONNECT2_ATOMIC_OPEN_LOCK;
+				   OBD_CONNECT2_ATOMIC_OPEN_LOCK |
+				   OBD_CONNECT2_BATCH_RPC;
 
 	if (test_bit(LL_SBI_LRU_RESIZE, sbi->ll_flags))
 		data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
fs/lustre/llite/lproc_llite.c +42 -5

66 lines not on this page · raw message

fs/lustre/llite/statahead.c +87 -11

200 lines not on this page · raw message

fs/lustre/lmv/lmv_obd.c +27 -0
index 157498c..54f8673 100644
@@ -3913,11 +3913,38 @@ static int lmv_batch_flush(struct obd_export *exp, struct lu_batch *bh,
 static inline struct lmv_tgt_desc *
 lmv_batch_locate_tgt(struct lmv_obd *lmv, struct md_op_item *item)
 {
+	struct md_op_data *op_data = &item->mop_data;
 	struct lmv_tgt_desc *tgt;
 
 	switch (item->mop_opc) {
+	case MD_OP_GETATTR:
+		if (fid_is_sane(&op_data->op_fid2)) {
+			struct lmv_tgt_desc *ptgt;
+
+			ptgt = lmv_locate_tgt(lmv, op_data);
+			if (IS_ERR(ptgt)) {
+				tgt = ptgt;
+			} else {
+				tgt = lmv_fid2tgt(lmv, &op_data->op_fid2);
+				if (!IS_ERR(tgt)) {
+					/*
+					 * Remote object needs two RPCs to
+					 * lookup and getattr, considering
+					 * the complexity don't support
+					 * statahead for now.
+					 */
+					if (tgt != ptgt)
+						tgt = ERR_PTR(-EREMOTE);
+				}
+			}
+		} else {
+			tgt = ERR_PTR(-EINVAL);
+		}
+		break;
+
 	default:
 		tgt = ERR_PTR(-EOPNOTSUPP);
+		break;
 	}
 
 	return tgt;
fs/lustre/mdc/mdc_batch.c +161 -2

176 lines not on this page · raw message

fs/lustre/mdc/mdc_dev.c +2 -2
index 984d1a8..74911da 100644
@@ -663,8 +663,8 @@ int mdc_enqueue_interpret(const struct lu_env *env, struct ptlrpc_request *req,
 	OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_CP_ENQ_RACE, 1);
 
 	/* Complete obtaining the lock procedure. */
-	rc = ldlm_cli_enqueue_fini(aa->oa_exp, req, &einfo, 1, aa->oa_flags,
-				   aa->oa_lvb, aa->oa_lvb ?
+	rc = ldlm_cli_enqueue_fini(aa->oa_exp, &req->rq_pill, &einfo, 1,
+				   aa->oa_flags, aa->oa_lvb, aa->oa_lvb ?
 				   sizeof(*aa->oa_lvb) : 0, lockh, rc, true);
 	/* Complete mdc stuff. */
 	rc = mdc_enqueue_fini(aa->oa_exp, req, aa->oa_upcall, aa->oa_cookie,
fs/lustre/mdc/mdc_internal.h +6 -0
index ae12a37..e752414 100644
@@ -194,6 +194,12 @@ int mdc_ldlm_blocking_ast(struct ldlm_lock *dlmlock,
 int mdc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data);
 int mdc_fill_lvb(struct req_capsule *pill, struct ost_lvb *lvb);
 
+int mdc_finish_enqueue(struct obd_export *exp,
+		       struct req_capsule *pill,
+		       struct ldlm_enqueue_info *einfo,
+		       struct lookup_intent *it,
+		       struct lustre_handle *lockh, int rc);
+
 /* the minimum inline repsize should be PAGE_SIZE at least */
 #define MDC_DOM_DEF_INLINE_REPSIZE max(8192UL, PAGE_SIZE)
 #define MDC_DOM_MAX_INLINE_REPSIZE XATTR_SIZE_MAX
fs/lustre/mdc/mdc_locks.c +13 -11
index f36e0ec..7695c78 100644
@@ -665,13 +665,13 @@ static struct ptlrpc_request *mdc_enqueue_pack(struct obd_export *exp,
 	return req;
 }
 
-static int mdc_finish_enqueue(struct obd_export *exp,
-			      struct ptlrpc_request *req,
-			      struct ldlm_enqueue_info *einfo,
-			      struct lookup_intent *it,
-			      struct lustre_handle *lockh, int rc)
+int mdc_finish_enqueue(struct obd_export *exp,
+		       struct req_capsule *pill,
+		       struct ldlm_enqueue_info *einfo,
+		       struct lookup_intent *it,
+		       struct lustre_handle *lockh, int rc)
 {
-	struct req_capsule *pill = &req->rq_pill;
+	struct ptlrpc_request *req = pill->rc_req;
 	struct ldlm_request *lockreq;
 	struct ldlm_reply *lockrep;
 	struct ldlm_lock *lock;
@@ -1067,7 +1067,7 @@ int mdc_enqueue_base(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
 		goto resend;
 	}
 
-	rc = mdc_finish_enqueue(exp, req, einfo, it, lockh, rc);
+	rc = mdc_finish_enqueue(exp, &req->rq_pill, einfo, it, lockh, rc);
 	if (rc < 0) {
 		if (lustre_handle_is_used(lockh)) {
 			ldlm_lock_decref(lockh, einfo->ei_mode);
@@ -1369,13 +1369,14 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env,
 	struct ldlm_enqueue_info *einfo = &item->mop_einfo;
 	struct lookup_intent *it = &item->mop_it;
 	struct lustre_handle *lockh = &item->mop_lockh;
+	struct req_capsule *pill = &req->rq_pill;
 	struct ldlm_reply *lockrep;
 	u64 flags = LDLM_FL_HAS_INTENT;
 
 	if (OBD_FAIL_CHECK(OBD_FAIL_MDC_GETATTR_ENQUEUE))
 		rc = -ETIMEDOUT;
 
-	rc = ldlm_cli_enqueue_fini(exp, req, einfo, 1, &flags, NULL, 0,
+	rc = ldlm_cli_enqueue_fini(exp, pill, einfo, 1, &flags, NULL, 0,
 				   lockh, rc, true);
 	if (rc < 0) {
 		CERROR("%s: ldlm_cli_enqueue_fini() failed: rc = %d\n",
@@ -1384,19 +1385,20 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env,
 		goto out;
 	}
 
-	lockrep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP);
+	lockrep = req_capsule_server_get(pill, &RMF_DLM_REP);
+	LASSERT(lockrep);
 
 	lockrep->lock_policy_res2 =
 		ptlrpc_status_ntoh(lockrep->lock_policy_res2);
 
-	rc = mdc_finish_enqueue(exp, req, einfo, it, lockh, rc);
+	rc = mdc_finish_enqueue(exp, pill, einfo, it, lockh, rc);
 	if (rc)
 		goto out;
 
 	rc = mdc_finish_intent_lock(exp, req, &item->mop_data, it, lockh);
 
 out:
-	item->mop_pill = &req->rq_pill;
+	item->mop_pill = pill;
 	item->mop_cb(item, rc);
 	return 0;
 }
fs/lustre/osc/osc_request.c +3 -2
index 6ea1db6..35dd009 100644
@@ -2990,8 +2990,9 @@ int osc_enqueue_interpret(const struct lu_env *env, struct ptlrpc_request *req,
 	}
 
 	/* Complete obtaining the lock procedure. */
-	rc = ldlm_cli_enqueue_fini(aa->oa_exp, req, &einfo, 1, aa->oa_flags,
-				   lvb, lvb_len, lockh, rc, false);
+	rc = ldlm_cli_enqueue_fini(aa->oa_exp, &req->rq_pill, &einfo, 1,
+				   aa->oa_flags, lvb, lvb_len, lockh, rc,
+				   false);
 	/* Complete osc stuff. */
 	rc = osc_enqueue_fini(req, aa->oa_upcall, aa->oa_cookie, lockh, mode,
 			      aa->oa_flags, aa->oa_speculative, rc);
fs/lustre/ptlrpc/layout.c +40 -0
index 0fe74ff..5beebb7 100644
@@ -722,6 +722,26 @@
 	&RMF_GENERIC_DATA,
 };
 
+static const struct req_msg_field *mds_batch_getattr_client[] = {
+	&RMF_DLM_REQ,
+	&RMF_LDLM_INTENT,
+	&RMF_MDT_BODY,     /* coincides with mds_getattr_name_client[] */
+	&RMF_CAPA1,
+	&RMF_NAME,
+	&RMF_FILE_SECCTX_NAME
+};
+
+static const struct req_msg_field *mds_batch_getattr_server[] = {
+	&RMF_DLM_REP,
+	&RMF_MDT_BODY,
+	&RMF_MDT_MD,
+	&RMF_ACL,
+	&RMF_CAPA1,
+	&RMF_FILE_SECCTX,
+	&RMF_DEFAULT_MDT_MD,
+	&RMF_FILE_ENCCTX,
+};
+
 static struct req_format *req_formats[] = {
 	&RQF_OBD_PING,
 	&RQF_OBD_SET_INFO,
@@ -811,6 +831,7 @@
 	&RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK,
 	&RQF_LLOG_ORIGIN_HANDLE_READ_HEADER,
 	&RQF_CONNECT,
+	&RQF_BUT_GETATTR,
 	&RQF_MDS_BATCH,
 };
 
@@ -1701,6 +1722,11 @@ struct req_format RQF_OST_LADVISE =
 	DEFINE_REQ_FMT0("OST_LADVISE", ost_ladvise, ost_body_only);
 EXPORT_SYMBOL(RQF_OST_LADVISE);
 
+struct req_format RQF_BUT_GETATTR =
+	DEFINE_REQ_FMT0("MDS_BATCH_GETATTR", mds_batch_getattr_client,
+			mds_batch_getattr_server);
+EXPORT_SYMBOL(RQF_BUT_GETATTR);
+
 /* Convenience macro */
 #define FMT_FIELD(fmt, i, j) ((fmt)->rf_fields[(i)].d[(j)])
 
@@ -2472,6 +2498,20 @@ void req_capsule_shrink(struct req_capsule *pill,
 }
 EXPORT_SYMBOL(req_capsule_shrink);
 
+void req_capsule_subreq_init(struct req_capsule *pill,
+			     const struct req_format *fmt,
+			     struct ptlrpc_request *req,
+			     struct lustre_msg *reqmsg,
+			     struct lustre_msg *repmsg,
+			     enum req_location loc)
+{
+	req_capsule_init(pill, req, loc);
+	req_capsule_set(pill, fmt);
+	pill->rc_reqmsg = reqmsg;
+	pill->rc_repmsg = repmsg;
+}
+EXPORT_SYMBOL(req_capsule_subreq_init);
+
 void req_capsule_set_replen(struct req_capsule *pill)
 {
 	if (req_capsule_ptlreq(pill)) {
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#26 lore raw

PATCH 26/27 lustre: llite: fix LSOM blocks for ftruncate and close

In reply to James Simmons

From: Etienne AUJAMES <[email protected]>

LSOM is updated on close and setattr request.
For the setattr, clients do not know the numbers blocks yet (OSTs setattr requests have to finish). So the blocks number is set to 1 by the server.

The close request send after a ftruncate() will wrongly update LSOM back to its old blocks number. This is because clients do not update the inode.i_blocks after an OST setattr.

Then the MDS will denied a client close request to update LSOM to its correct blocks number. Only truncates are allowed to decrease the blocks number (server side).

This patch force the client inode update at the end of an OST setattr. And it tries (if no contention on the inode_size) to update the inode at the end of an OST fsync or a sync IO.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16465
Lustre-commit: dfb08bbf77a1362f79 ("LU-16465 llite: fix LSOM blocks for ftruncate and close")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49675

---
 fs/lustre/llite/file.c           | 36 +++++++++++++++++++++++++++---------
 fs/lustre/llite/llite_internal.h |  2 ++
 fs/lustre/llite/llite_lib.c      | 10 ++++++++++
 fs/lustre/llite/vvp_io.c         | 34 ++++++++++++++++++++++++++++++++--
 4 files changed, 71 insertions(+), 11 deletions(-)
fs/lustre/llite/file.c +27 -9
index 0186db4..05a75ae 100644
@@ -1417,7 +1417,7 @@ static int ll_lease_file_resync(struct obd_client_handle *och,
 	return rc;
 }
 
-int ll_merge_attr(const struct lu_env *env, struct inode *inode)
+static int ll_merge_attr_nolock(const struct lu_env *env, struct inode *inode)
 {
 	struct ll_inode_info *lli = ll_i2info(inode);
 	struct cl_object *obj = lli->lli_clob;
@@ -1427,10 +1427,7 @@ int ll_merge_attr(const struct lu_env *env, struct inode *inode)
 	s64 ctime;
 	int rc = 0;
 
-	ll_inode_size_lock(inode);
-
-	/*
-	 * merge timestamps the most recently obtained from MDS with
+	/* merge timestamps the most recently obtained from MDS with
 	 * timestamps obtained from OSTSs.
 	 *
 	 * Do not overwrite atime of inode because it may be refreshed
@@ -1463,7 +1460,7 @@ int ll_merge_attr(const struct lu_env *env, struct inode *inode)
 	if (rc != 0) {
 		if (rc == -ENODATA)
 			rc = 0;
-		goto out_size_unlock;
+		goto out;
 	}
 
 	if (atime < attr->cat_atime)
@@ -1475,8 +1472,8 @@ int ll_merge_attr(const struct lu_env *env, struct inode *inode)
 	if (mtime < attr->cat_mtime)
 		mtime = attr->cat_mtime;
 
-	CDEBUG(D_VFSTRACE, DFID " updating i_size %llu\n",
-	       PFID(&lli->lli_fid), attr->cat_size);
+	CDEBUG(D_VFSTRACE, DFID" updating i_size %llu i_block %llu\n",
+	       PFID(&lli->lli_fid), attr->cat_size, attr->cat_blocks);
 
 	if (fscrypt_require_key(inode) == -ENOKEY) {
 		/* Without the key, round up encrypted file size to next
@@ -1495,13 +1492,34 @@ int ll_merge_attr(const struct lu_env *env, struct inode *inode)
 	inode->i_mtime.tv_sec = mtime;
 	inode->i_atime.tv_sec = atime;
 	inode->i_ctime.tv_sec = ctime;
+out:
+	return rc;
+}
 
-out_size_unlock:
+int ll_merge_attr(const struct lu_env *env, struct inode *inode)
+{
+	int rc;
+
+	ll_inode_size_lock(inode);
+	rc = ll_merge_attr_nolock(env, inode);
 	ll_inode_size_unlock(inode);
 
 	return rc;
 }
 
+/* Use to update size and blocks on inode for LSOM if there is no contention */
+int ll_merge_attr_try(const struct lu_env *env, struct inode *inode)
+{
+	int rc = 0;
+
+	if (ll_inode_size_trylock(inode)) {
+		rc = ll_merge_attr_nolock(env, inode);
+		ll_inode_size_unlock(inode);
+	}
+
+	return rc;
+}
+
 /**
  * Set designated mirror for I/O.
  *
fs/lustre/llite/llite_internal.h +2 -0
index 6088da08..88dbd6c 100644
@@ -551,6 +551,7 @@ static inline void obd_connect_set_enc_fid2path(struct obd_connect_data *data)
 
 void ll_inode_size_lock(struct inode *inode);
 void ll_inode_size_unlock(struct inode *inode);
+int ll_inode_size_trylock(struct inode *inode);
 
 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
 {
@@ -1248,6 +1249,7 @@ int ll_dir_getstripe(struct inode *inode, void **plmm, int *plmm_size,
 		     struct ptlrpc_request **request, u64 valid);
 int ll_fsync(struct file *file, loff_t start, loff_t end, int data);
 int ll_merge_attr(const struct lu_env *env, struct inode *inode);
+int ll_merge_attr_try(const struct lu_env *env, struct inode *inode);
 int ll_fid2path(struct inode *inode, void __user *arg);
 int __ll_fid2path(struct inode *inode, struct getinfo_fid2path *gfout,
 		  size_t outsize, u32 pathlen_orig);
fs/lustre/llite/llite_lib.c +10 -0
index b1bbeb3..2c286e8 100644
@@ -2558,6 +2558,16 @@ void ll_inode_size_unlock(struct inode *inode)
 	mutex_unlock(&lli->lli_size_mutex);
 }
 
+int ll_inode_size_trylock(struct inode *inode)
+{
+	struct ll_inode_info *lli;
+
+	LASSERT(!S_ISDIR(inode->i_mode));
+
+	lli = ll_i2info(inode);
+	return mutex_trylock(&lli->lli_size_mutex);
+}
+
 void ll_update_inode_flags(struct inode *inode, unsigned int ext_flags)
 {
 	struct ll_inode_info *lli = ll_i2info(inode);
fs/lustre/llite/vvp_io.c +32 -2
index 50c2872..31a3992 100644
@@ -763,6 +763,10 @@ static void vvp_io_setattr_end(const struct lu_env *env,
 		vvp_do_vmtruncate(inode, size);
 		mutex_unlock(&lli->lli_setattr_mutex);
 		trunc_sem_up_write(&lli->lli_trunc_sem);
+
+		/* Update size and blocks for LSOM */
+		if (!io->ci_ignore_layout)
+			ll_merge_attr(env, inode);
 	} else if (cl_io_is_fallocate(io)) {
 		int mode = io->u.ci_setattr.sa_falloc_mode;
 
@@ -1306,6 +1310,20 @@ static void vvp_io_rw_end(const struct lu_env *env,
 	trunc_sem_up_read(&lli->lli_trunc_sem);
 }
 
+static void vvp_io_write_end(const struct lu_env *env,
+			     const struct cl_io_slice *ios)
+{
+	struct inode *inode = vvp_object_inode(ios->cis_obj);
+	struct cl_io *io = ios->cis_io;
+
+	vvp_io_rw_end(env, ios);
+
+	/* Update size and blocks for LSOM (best effort) */
+	if (!io->ci_ignore_layout && cl_io_is_sync_write(io))
+		ll_merge_attr_try(env, inode);
+}
+
+
 static int vvp_io_kernel_fault(struct vvp_fault_io *cfio)
 {
 	struct vm_fault *vmf = cfio->ft_vmf;
@@ -1559,6 +1577,17 @@ static int vvp_io_fsync_start(const struct lu_env *env,
 	return 0;
 }
 
+static void vvp_io_fsync_end(const struct lu_env *env,
+			     const struct cl_io_slice *ios)
+{
+	struct inode *inode = vvp_object_inode(ios->cis_obj);
+	struct cl_io *io = ios->cis_io;
+
+	/* Update size and blocks for LSOM (best effort) */
+	if (!io->ci_ignore_layout)
+		ll_merge_attr_try(env, inode);
+}
+
 static int vvp_io_read_ahead(const struct lu_env *env,
 			     const struct cl_io_slice *ios,
 			     pgoff_t start, struct cl_read_ahead *ra)
@@ -1639,7 +1668,7 @@ static void vvp_io_lseek_end(const struct lu_env *env,
 			.cio_iter_fini	= vvp_io_write_iter_fini,
 			.cio_lock	= vvp_io_write_lock,
 			.cio_start	= vvp_io_write_start,
-			.cio_end	= vvp_io_rw_end,
+			.cio_end	= vvp_io_write_end,
 			.cio_advance	= vvp_io_advance,
 		},
 		[CIT_SETATTR] = {
@@ -1658,7 +1687,8 @@ static void vvp_io_lseek_end(const struct lu_env *env,
 		},
 		[CIT_FSYNC] = {
 			.cio_start	= vvp_io_fsync_start,
-			.cio_fini	= vvp_io_fini
+			.cio_fini	= vvp_io_fini,
+			.cio_end	= vvp_io_fsync_end,
 		},
 		[CIT_GLIMPSE] = {
 			.cio_fini	= vvp_io_fini
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#27 lore raw

PATCH 27/27 lnet: fix clang build errors

In reply to James Simmons

From: Timothy Day <[email protected]>

LNET_PID_ANY and LNET_NID_ANY were defined outside the range of an u64. They were moved from -1 to the maximum value for u64.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16518
Lustre-commit: b0297a1056a4b0ee65 ("LU-16518 lnet: fix clang build errors")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50318

---
 include/uapi/linux/lnet/lnet-types.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/lnet/lnet-types.h +2 -2
index 6c6a66eb..959d9af 100644
@@ -60,9 +60,9 @@
 #define LNET_RESERVED_PORTAL	0
 
 /** wildcard NID that matches any end-point address */
-#define LNET_NID_ANY	((lnet_nid_t)(-1))
+#define LNET_NID_ANY	(~(lnet_nid_t) 0)
 /** wildcard PID that matches any lnet_pid_t */
-#define LNET_PID_ANY	((lnet_pid_t)(-1))
+#define LNET_PID_ANY	(~(lnet_pid_t) 0)
 
 static inline int LNET_NID_IS_ANY(const struct lnet_nid *nid)
 {
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org