lustre-devel-lustre.org archive mirror
 help / color / mirror / Atom feed
* [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today
@ 2020-05-25 22:07 James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 01/45] lustre: fid: revert seq_client_rpc patch James Simmons
                   ` (45 more replies)
  0 siblings, 46 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

Merge the client side patches that landed to the OpenSFS
tree since Apirl 30 to today. Include a fid missing patches
as well and one patch to fix issues with 2 patches from the
earlier 600+ patch set. Please review to ensure their correctness.

Alexander Boyko (1):
  lustre: llog: allow delete of zero size llog

Amir Shehata (2):
  lnet: restrict gateway selection
  lnet: use the same src nid for discovery

Andreas Dilger (5):
  lustre: llite: verify truncated xattr is handled
  lustre: obd: fix printing of client connection UUID
  lustre: llite: restore ll_dcompare()
  lustre: ldlm: use proper units for timeouts
  lustre: lmv: do not print MDTs that are inactive

Andriy Skulysh (1):
  lustre: ptlrpc: connect to MDT stucks

Bobi Jam (2):
  lustre: lov: lov_io_sub_init()) ASSERTION
  lustre: llite: do not flush COW pages from mapping

Chris Horn (2):
  lnet: Introduce constant for the lolnd NID
  lnet: Add MD options for response tracking

James Simmons (2):
  lustre: cleanups and bug fixes
  lnet: stop using struct timeval

Lai Siyao (3):
  lustre: uapi: add OBD_CONNECT2_FIDMAP
  lustre: dne: support directory restripe
  lustre: dne: improve temp file name check

Mr NeilBrown (13):
  lnet: merge lnet_md_alloc into lnet_md_build.
  lnet: always put a page list into struct lnet_libmd
  lnet: discard kvec option from lnet_libmd.
  lnet: remove msg_iov from lnet_msg.
  lnet: o2iblnd: discard kiblnd_setup_rd_iov
  lustre: Remove inappropriate uses of BIT() macro.
  lnet: libcfs: use BIT() macro where appropriate
  lustre: llite: clean up pcc_layout_wait()
  lustre: misc: declare static chars as const where possible.
  lnet: use kmem_cache_zalloc as appropriate.
  lnet: remove lnet_extract_iov()
  lnet: simplify ksock_tx.
  lnet: socklnd: discard tx_iov.

NeilBrown (2):
  lustre: fid: revert seq_client_rpc patch.
  lustre: fld: convert cache_flush file to LPROC_SEQ_FOPS

Oleg Drokin (3):
  lustre: ptlrpc: return proper write count from ping_store
  lustre: osc: Do not wait for grants for too long
  lustre: osc: Ensure immediate departure of sync write pages

Qian Yingjin (1):
  lustre: Send file creation time to clients

Sebastien Buisson (2):
  lustre: sec: check permissions for changelogs access
  lustre: mgc: protect from NULL exp in mgc_enqueue()

Sergey Cheremencev (1):
  lustre: quota: quota pools for OSTs

Shaun Tancheff (1):
  lustre: all: Cleanup LASSERTF uses missing newlines

Swapnil Pimpale (1):
  lustre: fallocate: Implement fallocate preallocate operation

Wang Shilong (3):
  lustre: llite: fix to make jobstats work for async ra
  lustre: llite: fix possible divide zero in ll_use_fast_io()
  lustre: llite: check if page truncated in ll_write_begin()

 fs/lustre/fid/fid_request.c             |  12 +--
 fs/lustre/fld/fld_cache.c               |  40 --------
 fs/lustre/fld/fld_internal.h            |   7 --
 fs/lustre/fld/lproc_fld.c               |  31 +++---
 fs/lustre/include/cl_object.h           |  44 ++++++++-
 fs/lustre/include/lu_object.h           |  16 +--
 fs/lustre/include/lustre_dlm.h          |  17 ++--
 fs/lustre/include/lustre_import.h       |   4 +-
 fs/lustre/include/lustre_lmv.h          |  94 ++++++++++++++++--
 fs/lustre/include/lustre_req_layout.h   |   3 +
 fs/lustre/include/lustre_swab.h         |   2 +-
 fs/lustre/include/obd_support.h         |   5 +-
 fs/lustre/include/obd_target.h          |  54 ++++++++++
 fs/lustre/ldlm/ldlm_lockd.c             |   3 +-
 fs/lustre/ldlm/ldlm_request.c           |   1 +
 fs/lustre/ldlm/ldlm_resource.c          |  11 ++-
 fs/lustre/llite/dcache.c                |  56 ++++++++---
 fs/lustre/llite/dir.c                   |  33 +++++--
 fs/lustre/llite/file.c                  |  84 +++++++++++++++-
 fs/lustre/llite/lcommon_cl.c            |   2 +
 fs/lustre/llite/llite_internal.h        |   6 +-
 fs/lustre/llite/llite_lib.c             |   6 +-
 fs/lustre/llite/llite_mmap.c            |   2 +-
 fs/lustre/llite/lproc_llite.c           |  19 ++--
 fs/lustre/llite/namei.c                 |   5 +-
 fs/lustre/llite/pcc.c                   |  17 ++--
 fs/lustre/llite/rw.c                    |  13 ++-
 fs/lustre/llite/rw26.c                  |  16 ++-
 fs/lustre/llite/statahead.c             |   2 +-
 fs/lustre/llite/vvp_io.c                |  19 ++--
 fs/lustre/llite/vvp_object.c            |   2 +-
 fs/lustre/llite/xattr.c                 |  15 ++-
 fs/lustre/lmv/lmv_obd.c                 |  66 +++++++++----
 fs/lustre/lov/lov_cl_internal.h         |   6 +-
 fs/lustre/lov/lov_io.c                  |  31 ++++--
 fs/lustre/mdc/mdc_changelog.c           |   1 +
 fs/lustre/mdc/mdc_request.c             |  41 +++++---
 fs/lustre/mgc/mgc_request.c             |  11 ++-
 fs/lustre/obdclass/cl_page.c            |   1 -
 fs/lustre/obdclass/class_obd.c          |  35 +++----
 fs/lustre/obdclass/llog.c               |   9 +-
 fs/lustre/obdclass/llog_cat.c           |   3 +-
 fs/lustre/obdclass/lprocfs_status.c     |   8 +-
 fs/lustre/obdclass/obd_mount.c          |   2 +-
 fs/lustre/osc/osc_cache.c               |  33 ++++++-
 fs/lustre/osc/osc_internal.h            |   3 +
 fs/lustre/osc/osc_io.c                  |  56 +++++++++--
 fs/lustre/osc/osc_request.c             |  70 ++++++++++++-
 fs/lustre/ptlrpc/client.c               |   2 +-
 fs/lustre/ptlrpc/events.c               |   2 +-
 fs/lustre/ptlrpc/import.c               |   4 +-
 fs/lustre/ptlrpc/layout.c               |  26 ++++-
 fs/lustre/ptlrpc/llog_client.c          |   4 +
 fs/lustre/ptlrpc/lproc_ptlrpc.c         |   4 +-
 fs/lustre/ptlrpc/pack_generic.c         |  16 ++-
 fs/lustre/ptlrpc/ptlrpc_internal.h      |  19 ++++
 fs/lustre/ptlrpc/wiretest.c             |  16 ++-
 include/linux/lnet/lib-lnet.h           |  56 +----------
 include/linux/lnet/lib-types.h          |  15 +--
 include/uapi/linux/lnet/lnet-types.h    |  11 +++
 include/uapi/linux/lnet/lnetst.h        |   8 +-
 include/uapi/linux/lustre/lustre_idl.h  |  28 ++++--
 include/uapi/linux/lustre/lustre_user.h |  51 +++++++++-
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c     | 122 +++--------------------
 net/lnet/klnds/socklnd/socklnd.h        |  16 +--
 net/lnet/klnds/socklnd/socklnd_cb.c     |  68 +++++--------
 net/lnet/klnds/socklnd/socklnd_lib.c    |  32 +++---
 net/lnet/klnds/socklnd/socklnd_proto.c  |  10 +-
 net/lnet/libcfs/debug.c                 |   2 +-
 net/lnet/libcfs/libcfs_string.c         |   4 +-
 net/lnet/libcfs/module.c                |  17 ++--
 net/lnet/lnet/api-ni.c                  |  16 +--
 net/lnet/lnet/config.c                  |  16 +--
 net/lnet/lnet/lib-md.c                  | 168 ++++++++++++++++----------------
 net/lnet/lnet/lib-me.c                  |   2 +-
 net/lnet/lnet/lib-move.c                | 167 ++++++++++++++-----------------
 net/lnet/lnet/lib-msg.c                 |   5 +-
 net/lnet/lnet/lib-socket.c              |  34 ++-----
 net/lnet/lnet/lo.c                      |  17 +---
 net/lnet/lnet/peer.c                    |  17 +++-
 net/lnet/lnet/router.c                  |   2 +-
 net/lnet/selftest/conctl.c              |   1 -
 net/lnet/selftest/conrpc.c              |   6 +-
 net/lnet/selftest/conrpc.h              |   1 -
 net/lnet/selftest/console.h             |   1 -
 85 files changed, 1201 insertions(+), 802 deletions(-)
 create mode 100644 fs/lustre/include/obd_target.h

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 01/45] lustre: fid: revert seq_client_rpc patch.
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 02/45] lustre: fld: convert cache_flush file to LPROC_SEQ_FOPS James Simmons
                   ` (44 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: NeilBrown <neilb@suse.de>

This reverts commit 5955572b19f6 ("staging: lustre: fid: perform sanity
checks before committing").  The patch isn't really needed, and
keeping it caused unnecessary differences from out-of-free
lustre.

Reviewed-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: NeilBrown <neilb@suse.de>
---
 fs/lustre/fid/fid_request.c    | 10 +++++-----
 fs/lustre/include/lustre_lmv.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/lustre/fid/fid_request.c b/fs/lustre/fid/fid_request.c
index 6cede30..a1c3bd9 100644
--- a/fs/lustre/fid/fid_request.c
+++ b/fs/lustre/fid/fid_request.c
@@ -118,22 +118,22 @@ static int seq_client_rpc(struct lu_client_seq *seq,
 		goto out_req;
 
 	out = req_capsule_server_get(&req->rq_pill, &RMF_SEQ_RANGE);
+	*output = *out;
 
-	if (!lu_seq_range_is_sane(out)) {
+	if (!lu_seq_range_is_sane(output)) {
 		CERROR("%s: Invalid range received from server: "
-		       DRANGE "\n", seq->lcs_name, PRANGE(out));
+		       DRANGE "\n", seq->lcs_name, PRANGE(output));
 		rc = -EINVAL;
 		goto out_req;
 	}
 
-	if (lu_seq_range_is_exhausted(out)) {
+	if (lu_seq_range_is_exhausted(output)) {
 		CERROR("%s: Range received from server is exhausted: "
-		       DRANGE "]\n", seq->lcs_name, PRANGE(out));
+		       DRANGE "]\n", seq->lcs_name, PRANGE(output));
 		rc = -EINVAL;
 		goto out_req;
 	}
 
-	*output = *out;
 	CDEBUG_LIMIT(debug_mask, "%s: Allocated %s-sequence " DRANGE "]\n",
 		     seq->lcs_name, opcname, PRANGE(output));
 
diff --git a/fs/lustre/include/lustre_lmv.h b/fs/lustre/include/lustre_lmv.h
index 305b56d..8780480 100644
--- a/fs/lustre/include/lustre_lmv.h
+++ b/fs/lustre/include/lustre_lmv.h
@@ -68,7 +68,7 @@ static inline bool lmv_dir_foreign(const struct lmv_stripe_md *lsm)
 static inline bool lmv_dir_layout_changing(const struct lmv_stripe_md *lsm)
 {
 	return lmv_dir_striped(lsm) &&
-	       (lsm->lsm_md_hash_type & LMV_HASH_FLAG_MIGRATION);
+	       (lsm->lsm_md_hash_type & LMV_HASH_FLAG_LAYOUT_CHANGE);
 }
 
 static inline bool lmv_dir_bad_hash(const struct lmv_stripe_md *lsm)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 02/45] lustre: fld: convert cache_flush file to LPROC_SEQ_FOPS
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 01/45] lustre: fid: revert seq_client_rpc patch James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 03/45] lustre: cleanups and bug fixes James Simmons
                   ` (43 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: NeilBrown <neilb@suse.de>

Commit 827650494fbe ("staging/lustre/fld: move all files from procfs to
debugfs") converted files to debugfs, but missed the opportunity to
provide a simpler implementation for cache_flush.  When that patch was
taken to OpenSFS lustre in Commit 6d2b66d22c25 ("LU-8066 fld: move all
files from procfs to debugfs"), that opportunity was taken.

So we now copy that improvement back to Linux.

Reviewed-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: NeilBrown <neilb@suse.de>
---
 fs/lustre/fld/lproc_fld.c        | 31 +++++++++++--------------------
 fs/lustre/include/lustre_lmv.h   |  4 ++--
 fs/lustre/llite/dcache.c         |  3 +--
 fs/lustre/llite/llite_internal.h |  4 ++--
 fs/lustre/llite/lproc_llite.c    |  4 ++--
 fs/lustre/llite/namei.c          |  2 +-
 6 files changed, 19 insertions(+), 29 deletions(-)

diff --git a/fs/lustre/fld/lproc_fld.c b/fs/lustre/fld/lproc_fld.c
index bef359f..e8c8bc7 100644
--- a/fs/lustre/fld/lproc_fld.c
+++ b/fs/lustre/fld/lproc_fld.c
@@ -117,10 +117,11 @@
 }
 
 static ssize_t
-fld_debugfs_cache_flush_write(struct file *file, const char __user *buffer,
-			      size_t count, loff_t *pos)
+lprocfs_wr_cache_flush(struct file *file, const char __user *buffer,
+		      size_t count, loff_t *pos)
 {
-	struct lu_client_fld *fld = file->private_data;
+	struct seq_file *m = file->private_data;
+	struct lu_client_fld *fld = m->private;
 
 	fld_cache_flush(fld->lcf_cache);
 
@@ -129,26 +130,16 @@
 	return count;
 }
 
-static int
-fld_debugfs_cache_flush_release(struct inode *inode, struct file *file)
-{
-	file->private_data = NULL;
-	return 0;
-}
-
-static const struct file_operations fld_debugfs_cache_flush_fops = {
-	.owner		= THIS_MODULE,
-	.open		= simple_open,
-	.write		= fld_debugfs_cache_flush_write,
-	.release	= fld_debugfs_cache_flush_release,
-};
-
 LPROC_SEQ_FOPS_RO(fld_debugfs_targets);
 LPROC_SEQ_FOPS(fld_debugfs_hash);
+LPROC_SEQ_FOPS_WR_ONLY(fld, cache_flush);
 
 struct lprocfs_vars fld_client_debugfs_list[] = {
-	{ "targets",	 &fld_debugfs_targets_fops },
-	{ "hash",	 &fld_debugfs_hash_fops },
-	{ "cache_flush", &fld_debugfs_cache_flush_fops },
+	{ .name =	"targets",
+	  .fops =	&fld_debugfs_targets_fops	},
+	{ .name =	"hash",
+	  .fops =	&fld_debugfs_hash_fops		},
+	{ .name =	"cache_flush",
+	  .fops =	&fld_cache_flush_fops	},
 	{ NULL }
 };
diff --git a/fs/lustre/include/lustre_lmv.h b/fs/lustre/include/lustre_lmv.h
index 8780480..645eee3 100644
--- a/fs/lustre/include/lustre_lmv.h
+++ b/fs/lustre/include/lustre_lmv.h
@@ -299,8 +299,8 @@ static inline u32 crush_hash(u32 a, u32 b)
 	if (stripe_count > 1) {
 		switch (hash_type & LMV_HASH_TYPE_MASK) {
 		case LMV_HASH_TYPE_ALL_CHARS:
-			stripe_index  = lmv_hash_all_chars(stripe_count, name,
-							   namelen);
+			stripe_index = lmv_hash_all_chars(stripe_count, name,
+							  namelen);
 			break;
 		case LMV_HASH_TYPE_FNV_1A_64:
 			stripe_index = lmv_hash_fnv1a(stripe_count, name,
diff --git a/fs/lustre/llite/dcache.c b/fs/lustre/llite/dcache.c
index 395c454a..5fab108 100644
--- a/fs/lustre/llite/dcache.c
+++ b/fs/lustre/llite/dcache.c
@@ -58,7 +58,6 @@ static void ll_release(struct dentry *de)
 
 	LASSERT(de);
 	lld = ll_d2d(de);
-
 	call_rcu(&lld->lld_rcu_head, free_dentry_data);
 }
 
@@ -118,7 +117,7 @@ void ll_intent_drop_lock(struct lookup_intent *it)
 			handle.cookie = it->it_remote_lock_handle;
 
 			CDEBUG(D_DLMTRACE,
-			       "releasing remote lock with cookie%#llx from it %p\n",
+			       "releasing remote lock with cookie %#llx from it %p\n",
 			       handle.cookie, it);
 			ldlm_lock_decref(&handle,
 					 it->it_remote_lock_mode);
diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h
index 724b795..671bceb 100644
--- a/fs/lustre/llite/llite_internal.h
+++ b/fs/lustre/llite/llite_internal.h
@@ -414,10 +414,10 @@ static inline struct pcc_inode *ll_i2pcci(struct inode *inode)
 /* default to use at least 16M for fast read if possible */
 #define RA_REMAIN_WINDOW_MIN			MiB_TO_PAGES(16UL)
 
-/* default to about 64M of readahead on a given system. */
+/* default readahead on a given system. */
 #define SBI_DEFAULT_READ_AHEAD_MAX		MiB_TO_PAGES(64UL)
 
-/* default to read-ahead full files smaller than 2MB on the second read */
+/* default read-ahead full files smaller than 2MB on the second read */
 #define SBI_DEFAULT_READ_AHEAD_WHOLE_MAX	MiB_TO_PAGES(2UL)
 
 enum ra_stat {
diff --git a/fs/lustre/llite/lproc_llite.c b/fs/lustre/llite/lproc_llite.c
index 0ef418a..a38b25e 100644
--- a/fs/lustre/llite/lproc_llite.c
+++ b/fs/lustre/llite/lproc_llite.c
@@ -354,7 +354,7 @@ static ssize_t max_read_ahead_mb_store(struct kobject *kobj,
 	pages_number = round_up(ra_max_mb, 1024 * 1024) >> PAGE_SHIFT;
 	if (pages_number > totalram_pages() / 2) {
 		/* 1/2 of RAM */
-		CERROR("%s: cannot set max_readahead_mb=%llu > %luMB\n",
+		CERROR("%s: cannot set max_read_ahead_mb=%llu > totalram/2=%luMB\n",
 		       sbi->ll_fsname, PAGES_TO_MiB(pages_number),
 		       PAGES_TO_MiB(totalram_pages() / 2));
 		return -ERANGE;
@@ -399,7 +399,7 @@ static ssize_t max_read_ahead_per_file_mb_store(struct kobject *kobj,
 
 	pages_number = round_up(ra_max_file_mb, 1024 * 1024) >> PAGE_SHIFT;
 	if (pages_number > sbi->ll_ra_info.ra_max_pages) {
-		CERROR("%s: cannot set max_readahead_per_file_mb=%llu > max_read_ahead_mb=%lu\n",
+		CERROR("%s: cannot set max_read_ahead_per_file_mb=%llu > max_read_ahead_mb=%lu\n",
 		       sbi->ll_fsname, PAGES_TO_MiB(pages_number),
 		       PAGES_TO_MiB(sbi->ll_ra_info.ra_max_pages));
 		return -ERANGE;
diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c
index 97fbbee..2ca6bd2 100644
--- a/fs/lustre/llite/namei.c
+++ b/fs/lustre/llite/namei.c
@@ -978,7 +978,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
 	int rc = 0;
 
 	CDEBUG(D_VFSTRACE,
-	       "VFS Op:name=%pd, dir=" DFID "(%p),file %p,open_flags %x,mode %x\n",
+	       "VFS Op:name=%pd, dir=" DFID "(%p), file %p, open_flags %x, mode %x\n",
 	       dentry, PFID(ll_inode2fid(dir)), dir, file, open_flags, mode);
 
 	/* Only negative dentries enter here */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 03/45] lustre: cleanups and bug fixes
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 01/45] lustre: fid: revert seq_client_rpc patch James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 02/45] lustre: fld: convert cache_flush file to LPROC_SEQ_FOPS James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 04/45] lnet: merge lnet_md_alloc into lnet_md_build James Simmons
                   ` (42 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

Fix various bugs in the Linux Lustre client. Small styles fixes
as well.

Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/fid/fid_request.c         |  2 +-
 fs/lustre/fld/fld_cache.c           | 40 -------------------------------------
 fs/lustre/fld/fld_internal.h        |  7 -------
 fs/lustre/llite/llite_internal.h    |  2 +-
 fs/lustre/llite/llite_lib.c         |  2 --
 fs/lustre/llite/lproc_llite.c       | 10 +++++-----
 fs/lustre/llite/statahead.c         |  2 +-
 fs/lustre/llite/xattr.c             |  1 +
 fs/lustre/mdc/mdc_changelog.c       |  1 +
 fs/lustre/mgc/mgc_request.c         |  8 +++++---
 fs/lustre/obdclass/cl_page.c        |  1 -
 fs/lustre/obdclass/class_obd.c      | 23 ++++++++++-----------
 fs/lustre/obdclass/lprocfs_status.c |  6 +++---
 fs/lustre/osc/osc_cache.c           |  2 +-
 fs/lustre/osc/osc_request.c         |  5 ++---
 fs/lustre/ptlrpc/import.c           |  2 +-
 16 files changed, 33 insertions(+), 81 deletions(-)

diff --git a/fs/lustre/fid/fid_request.c b/fs/lustre/fid/fid_request.c
index a1c3bd9..a7013d1 100644
--- a/fs/lustre/fid/fid_request.c
+++ b/fs/lustre/fid/fid_request.c
@@ -179,7 +179,7 @@ static int seq_client_alloc_seq(const struct lu_env *env,
 		rc = seq_client_alloc_meta(env, seq);
 		if (rc) {
 			if (rc != -EINPROGRESS)
-				CERROR("%s: Can't allocate new meta-sequence, rc = %d\n",
+				CERROR("%s: Cannot allocate new meta-sequence, rc = %d\n",
 				       seq->lcs_name, rc);
 			*seqnr = U64_MAX;
 			return rc;
diff --git a/fs/lustre/fld/fld_cache.c b/fs/lustre/fld/fld_cache.c
index 79b10bb..f288907 100644
--- a/fs/lustre/fld/fld_cache.c
+++ b/fs/lustre/fld/fld_cache.c
@@ -431,46 +431,6 @@ int fld_cache_insert(struct fld_cache *cache,
 }
 
 /**
- * Delete FLD entry in FLD cache.
- *
- */
-
-struct fld_cache_entry
-*fld_cache_entry_lookup_nolock(struct fld_cache *cache,
-			      struct lu_seq_range *range)
-{
-	struct fld_cache_entry *flde;
-	struct fld_cache_entry *got = NULL;
-	struct list_head *head;
-
-	head = &cache->fci_entries_head;
-	list_for_each_entry(flde, head, fce_list) {
-		if (range->lsr_start == flde->fce_range.lsr_start ||
-		    (range->lsr_end == flde->fce_range.lsr_end &&
-		     range->lsr_flags == flde->fce_range.lsr_flags)) {
-			got = flde;
-			break;
-		}
-	}
-
-	return got;
-}
-
-/**
- * lookup @seq sequence for range in fld cache.
- */
-struct fld_cache_entry
-*fld_cache_entry_lookup(struct fld_cache *cache, struct lu_seq_range *range)
-{
-	struct fld_cache_entry *got = NULL;
-
-	read_lock(&cache->fci_lock);
-	got = fld_cache_entry_lookup_nolock(cache, range);
-	read_unlock(&cache->fci_lock);
-	return got;
-}
-
-/**
  * lookup @seq sequence for range in fld cache.
  */
 int fld_cache_lookup(struct fld_cache *cache,
diff --git a/fs/lustre/fld/fld_internal.h b/fs/lustre/fld/fld_internal.h
index 53648d2..d44e378 100644
--- a/fs/lustre/fld/fld_internal.h
+++ b/fs/lustre/fld/fld_internal.h
@@ -151,13 +151,6 @@ struct fld_cache_entry
 int fld_cache_lookup(struct fld_cache *cache,
 		     const u64 seq, struct lu_seq_range *range);
 
-struct fld_cache_entry*
-fld_cache_entry_lookup(struct fld_cache *cache, struct lu_seq_range *range);
-
-struct fld_cache_entry
-*fld_cache_entry_lookup_nolock(struct fld_cache *cache,
-			      struct lu_seq_range *range);
-
 static inline const char *
 fld_target_name(struct lu_fld_target *tar)
 {
diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h
index 671bceb..c3f60bb 100644
--- a/fs/lustre/llite/llite_internal.h
+++ b/fs/lustre/llite/llite_internal.h
@@ -417,7 +417,7 @@ static inline struct pcc_inode *ll_i2pcci(struct inode *inode)
 /* default readahead on a given system. */
 #define SBI_DEFAULT_READ_AHEAD_MAX		MiB_TO_PAGES(64UL)
 
-/* default read-ahead full files smaller than 2MB on the second read */
+/* default read-ahead full files smaller than limit on the second read */
 #define SBI_DEFAULT_READ_AHEAD_WHOLE_MAX	MiB_TO_PAGES(2UL)
 
 enum ra_stat {
diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c
index 89e0428..84ec734 100644
--- a/fs/lustre/llite/llite_lib.c
+++ b/fs/lustre/llite/llite_lib.c
@@ -2347,8 +2347,6 @@ void ll_umount_begin(struct super_block *sb)
 		ssleep(1);
 		cnt++;
 	}
-
-	schedule();
 }
 
 int ll_remount_fs(struct super_block *sb, int *flags, char *data)
diff --git a/fs/lustre/llite/lproc_llite.c b/fs/lustre/llite/lproc_llite.c
index a38b25e..5b10ed0 100644
--- a/fs/lustre/llite/lproc_llite.c
+++ b/fs/lustre/llite/lproc_llite.c
@@ -349,9 +349,9 @@ static ssize_t max_read_ahead_mb_store(struct kobject *kobj,
 	if (rc)
 		return rc;
 
+	pages_number = round_up(ra_max_mb, 1024 * 1024) >> PAGE_SHIFT;
 	CDEBUG(D_INFO, "%s: set max_read_ahead_mb=%llu (%llu pages)\n",
 	       sbi->ll_fsname, PAGES_TO_MiB(pages_number), pages_number);
-	pages_number = round_up(ra_max_mb, 1024 * 1024) >> PAGE_SHIFT;
 	if (pages_number > totalram_pages() / 2) {
 		/* 1/2 of RAM */
 		CERROR("%s: cannot set max_read_ahead_mb=%llu > totalram/2=%luMB\n",
@@ -571,7 +571,7 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file,
 			break;
 
 		if (!sbi->ll_dt_exp) { /* being initialized */
-			rc = 0;
+			rc = -ENODEV;
 			goto out;
 		}
 
@@ -1111,9 +1111,9 @@ static ssize_t max_read_ahead_async_active_show(struct kobject *kobj,
 }
 
 static ssize_t max_read_ahead_async_active_store(struct kobject *kobj,
-						struct attribute *attr,
-						const char *buffer,
-						size_t count)
+						 struct attribute *attr,
+						 const char *buffer,
+						 size_t count)
 {
 	struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
 					      ll_kset.kobj);
diff --git a/fs/lustre/llite/statahead.c b/fs/lustre/llite/statahead.c
index ba7ebab..04e013f 100644
--- a/fs/lustre/llite/statahead.c
+++ b/fs/lustre/llite/statahead.c
@@ -1568,7 +1568,7 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry)
 	 * statahead thread won't be notified to quit.
 	 */
 	spin_lock(&lli->lli_sa_lock);
-	if (unlikely(lli->lli_sai || lli->lli_opendir_key ||
+	if (unlikely(lli->lli_sai || !lli->lli_opendir_key ||
 		     lli->lli_opendir_pid != current->pid)) {
 		spin_unlock(&lli->lli_sa_lock);
 		rc = -EPERM;
diff --git a/fs/lustre/llite/xattr.c b/fs/lustre/llite/xattr.c
index 5d0f7b2..9e7ba21 100644
--- a/fs/lustre/llite/xattr.c
+++ b/fs/lustre/llite/xattr.c
@@ -264,6 +264,7 @@ static int ll_setstripe_ea(struct dentry *dentry, struct lov_user_md *lump,
 		 */
 		return -ERANGE;
 	}
+
 	rc = ll_adjust_lum(inode, lump);
 	if (rc)
 		return rc;
diff --git a/fs/lustre/mdc/mdc_changelog.c b/fs/lustre/mdc/mdc_changelog.c
index 61f3d29..3aace7e 100644
--- a/fs/lustre/mdc/mdc_changelog.c
+++ b/fs/lustre/mdc/mdc_changelog.c
@@ -840,6 +840,7 @@ int mdc_changelog_cdev_init(struct obd_device *obd)
 	entry->ced_device = device;
 
 	entry = NULL;	/* prevent it from being freed below */
+	rc = 0;
 	goto out_unlock;
 
 out_cdev:
diff --git a/fs/lustre/mgc/mgc_request.c b/fs/lustre/mgc/mgc_request.c
index eb7d22e..81f3873 100644
--- a/fs/lustre/mgc/mgc_request.c
+++ b/fs/lustre/mgc/mgc_request.c
@@ -970,9 +970,11 @@ static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp,
 		       imp->imp_deactive, imp->imp_invalid,
 		       imp->imp_replayable, imp->imp_obd->obd_replayable,
 		       ptlrpc_import_state_name(imp->imp_state));
-		/* Resurrect if we previously died */
-		if ((imp->imp_state != LUSTRE_IMP_FULL &&
-		     imp->imp_state != LUSTRE_IMP_NEW) || value > 1)
+		/* Resurrect the import immediately if
+		 * 1. we previously got disconnected,
+		 * 2. value > 1 (at the same node with MGS)
+		 */
+		if (imp->imp_state != LUSTRE_IMP_NEW || value > 1)
 			ptlrpc_reconnect_import(imp);
 		return 0;
 	}
diff --git a/fs/lustre/obdclass/cl_page.c b/fs/lustre/obdclass/cl_page.c
index 3ed8e73..d5be0c5 100644
--- a/fs/lustre/obdclass/cl_page.c
+++ b/fs/lustre/obdclass/cl_page.c
@@ -200,7 +200,6 @@ struct cl_page *cl_page_alloc(const struct lu_env *env,
 	struct cl_page *page;
 	struct cl_object *o2;
 
-	page = kzalloc(cl_object_header(o)->coh_page_bufsize, GFP_NOFS);
 	page = __cl_page_alloc(o);
 	if (page) {
 		int result = 0;
diff --git a/fs/lustre/obdclass/class_obd.c b/fs/lustre/obdclass/class_obd.c
index 0e07fea..038ee62 100644
--- a/fs/lustre/obdclass/class_obd.c
+++ b/fs/lustre/obdclass/class_obd.c
@@ -512,7 +512,7 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd,
 	u64 __size;							       \
 	int __ret;							       \
 									       \
-	BUILD_BUG_ON(strlen(value) >= 23);				       \
+	BUILD_BUG_ON(sizeof(value) >= 23);				       \
 	__ret = sysfs_memparse(value, sizeof(value) - 1, &__size, def_unit);   \
 	if (__ret != __rc)						       \
 		CERROR("string_helper: parsing '%s' expect rc %d != got %d\n", \
@@ -531,9 +531,6 @@ static int __init obd_init_checks(void)
 	char buf[64];
 	int len, ret = 0;
 
-	CDEBUG(D_INFO, "LPU64=%s, LPD64=%s, LPX64=%s\n", "%llu", "%lld",
-	       "%#llx");
-
 	CDEBUG(D_INFO, "OBD_OBJECT_EOF = %#llx\n", (u64)OBD_OBJECT_EOF);
 
 	u64val = OBD_OBJECT_EOF;
@@ -545,7 +542,7 @@ static int __init obd_init_checks(void)
 	}
 	len = snprintf(buf, sizeof(buf), "%#llx", u64val);
 	if (len != 18) {
-		CWARN("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len);
+		CERROR("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len);
 		ret = -EINVAL;
 	}
 
@@ -559,37 +556,39 @@ static int __init obd_init_checks(void)
 	if (u64val >> 8 != OBD_OBJECT_EOF >> 8) {
 		CERROR("u64 %#llx(%d) != 0xffffffffffffffff\n",
 		       u64val, (int)sizeof(u64val));
-		return -EOVERFLOW;
+		ret = -EOVERFLOW;
 	}
 	if (do_div(div64val, 256) != (u64val & 255)) {
 		CERROR("do_div(%#llx,256) != %llu\n", u64val, u64val & 255);
-		return -EOVERFLOW;
+		ret = -EOVERFLOW;
 	}
 	if (u64val >> 8 != div64val) {
 		CERROR("do_div(%#llx,256) %llu != %llu\n",
 		       u64val, div64val, u64val >> 8);
-		return -EOVERFLOW;
+		ret = -EOVERFLOW;
 	}
 	len = snprintf(buf, sizeof(buf), "%#llx", u64val);
 	if (len != 18) {
-		CWARN("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len);
+		CERROR("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len);
 		ret = -EINVAL;
 	}
 	len = snprintf(buf, sizeof(buf), "%llu", u64val);
 	if (len != 20) {
-		CWARN("LPU64 wrong length! strlen(%s)=%d != 20\n", buf, len);
+		CERROR("LPU64 wrong length! strlen(%s)=%d != 20\n", buf, len);
 		ret = -EINVAL;
 	}
 	len = snprintf(buf, sizeof(buf), "%lld", u64val);
 	if (len != 2) {
-		CWARN("LPD64 wrong length! strlen(%s)=%d != 2\n", buf, len);
+		CERROR("LPD64 wrong length! strlen(%s)=%d != 2\n", buf, len);
 		ret = -EINVAL;
 	}
 	if ((u64val & ~PAGE_MASK) >= PAGE_SIZE) {
-		CWARN("mask failed: u64val %llu >= %llu\n", u64val,
+		CERROR("mask failed: u64val %llu >= %llu\n", u64val,
 		      (u64)PAGE_SIZE);
 		ret = -EINVAL;
 	}
+	if (ret)
+		return ret;
 
 	/* invalid string */
 	if (!test_string_to_size_err("256B34", 256, "B", -EINVAL)) {
diff --git a/fs/lustre/obdclass/lprocfs_status.c b/fs/lustre/obdclass/lprocfs_status.c
index e2b74cf..5f94669 100644
--- a/fs/lustre/obdclass/lprocfs_status.c
+++ b/fs/lustre/obdclass/lprocfs_status.c
@@ -236,7 +236,7 @@ static void obd_connect_data_seqprint(struct seq_file *m,
  *
  *  - ``-EINVAL``: @buffer is not a proper numerical string
  *  - ``-EOVERFLOW``: results does not fit into 64 bits.
- *  - ``-E2BIG ``: @buffer is not large (not a valid number)
+ *  - ``-E2BIG ``: @buffer is too large (not a valid number)
  */
 int string_to_size(u64 *size, const char *buffer, size_t count)
 {
@@ -1057,8 +1057,8 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
 	int rc;
 
 	with_imp_locked(obd, imp, rc) {
-		flags = obd->u.cli.cl_import->imp_connect_data.ocd_connect_flags;
-		flags2 = obd->u.cli.cl_import->imp_connect_data.ocd_connect_flags2;
+		flags = imp->imp_connect_data.ocd_connect_flags;
+		flags2 = imp->imp_connect_data.ocd_connect_flags2;
 		seq_printf(m, "flags=%#llx\n", flags);
 		seq_printf(m, "flags2=%#llx\n", flags2);
 		obd_connect_seq_flags2str(m, flags, flags2, "\n");
diff --git a/fs/lustre/osc/osc_cache.c b/fs/lustre/osc/osc_cache.c
index 4df4202..9e28ff6 100644
--- a/fs/lustre/osc/osc_cache.c
+++ b/fs/lustre/osc/osc_cache.c
@@ -1655,7 +1655,7 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli,
 	 * run out of grants. In both cases we should write dirty pages out.
 	 * Adding a cache waiter will trigger urgent write-out no matter what
 	 * RPC size will be.
-	 * The exiting condition (other then success) is no avail grants
+	 * The exiting condition (other than success) is no avail grants
 	 * and no dirty pages caching, that really means there is no space
 	 * on the OST.
 	 */
diff --git a/fs/lustre/osc/osc_request.c b/fs/lustre/osc/osc_request.c
index d499e26..4db249e 100644
--- a/fs/lustre/osc/osc_request.c
+++ b/fs/lustre/osc/osc_request.c
@@ -1295,7 +1295,6 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
 				struct obdo *oa, u32 page_count,
 				struct brw_page **pga,
 				struct ptlrpc_request **reqp,
-				int reserve,
 				int resend)
 {
 	struct ptlrpc_request *req;
@@ -1948,7 +1947,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request,
 				   OST_WRITE) ? OBD_BRW_WRITE : OBD_BRW_READ,
 				  aa->aa_cli, aa->aa_oa,
 				  aa->aa_page_count, aa->aa_ppga,
-				  &new_req, 0, 1);
+				  &new_req, 1);
 	if (rc)
 		return rc;
 
@@ -2298,7 +2297,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
 	}
 
 	sort_brw_pages(pga, page_count);
-	rc = osc_brw_prep_request(cmd, cli, oa, page_count, pga, &req, 1, 0);
+	rc = osc_brw_prep_request(cmd, cli, oa, page_count, pga, &req, 0);
 	if (rc != 0) {
 		CERROR("prep_req failed: %d\n", rc);
 		goto out;
diff --git a/fs/lustre/ptlrpc/import.c b/fs/lustre/ptlrpc/import.c
index 805be82..709b9fd 100644
--- a/fs/lustre/ptlrpc/import.c
+++ b/fs/lustre/ptlrpc/import.c
@@ -1879,7 +1879,7 @@ timeout_t at_measured(struct adaptive_timeout *at, timeout_t timeout)
 				       at_min);
 	if (at->at_current_timeout != old_timeout)
 		CDEBUG(D_OTHER,
-		       "AT %p change: old=%u new=%u delta=%d (val=%u) hist %u %u %u %u\n",
+		       "AT %p change: old=%u new=%u delta=%d (val=%d) hist %u %u %u %u\n",
 		       at, old_timeout, at->at_current_timeout,
 		       at->at_current_timeout - old_timeout, timeout,
 		       at->at_hist[0], at->at_hist[1], at->at_hist[2],
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 04/45] lnet: merge lnet_md_alloc into lnet_md_build.
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (2 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 03/45] lustre: cleanups and bug fixes James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 05/45] lnet: always put a page list into struct lnet_libmd James Simmons
                   ` (41 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

lnet_md_alloc is only called twice, each time immediately before a
call to lnet_md_build(), and these are the only calls to
lnet_md_build().

So simplify the code by merging lnet_md_alloc into lnet_md_build.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13004
Lustre-commit: c0598f15dd502 ("LU-13004 lnet: merge lnet_md_alloc into lnet_md_build.")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/37841
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 include/linux/lnet/lib-lnet.h | 39 ----------------------
 net/lnet/lnet/lib-md.c        | 75 +++++++++++++++++++++++++++++--------------
 2 files changed, 51 insertions(+), 63 deletions(-)

diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h
index d64c9bf..66e01a0 100644
--- a/include/linux/lnet/lib-lnet.h
+++ b/include/linux/lnet/lib-lnet.h
@@ -215,45 +215,6 @@ static inline int lnet_md_unlinkable(struct lnet_libmd *md)
 
 #define MAX_PORTALS		64
 
-static inline struct lnet_libmd *
-lnet_md_alloc(struct lnet_md *umd)
-{
-	struct lnet_libmd *md;
-	unsigned int size;
-	unsigned int niov;
-
-	if (umd->options & LNET_MD_KIOV) {
-		niov = umd->length;
-		size = offsetof(struct lnet_libmd, md_iov.kiov[niov]);
-	} else {
-		niov = 1;
-		size = offsetof(struct lnet_libmd, md_iov.iov[niov]);
-	}
-
-	if (size <= LNET_SMALL_MD_SIZE) {
-		md = kmem_cache_alloc(lnet_small_mds_cachep,
-				      GFP_NOFS | __GFP_ZERO);
-		if (md) {
-			CDEBUG(D_MALLOC,
-			       "slab-alloced 'md' of size %u@%p.\n",
-			       size, md);
-		} else {
-			CDEBUG(D_MALLOC, "failed to allocate 'md' of size %u\n",
-			       size);
-		}
-	} else {
-		md = kzalloc(size, GFP_NOFS);
-	}
-	if (md) {
-		/* Set here in case of early free */
-		md->md_options = umd->options;
-		md->md_niov = niov;
-		INIT_LIST_HEAD(&md->md_list);
-	}
-
-	return md;
-}
-
 struct lnet_libhandle *lnet_res_lh_lookup(struct lnet_res_container *rec,
 					  u64 cookie);
 void lnet_res_lh_initialize(struct lnet_res_container *rec,
diff --git a/net/lnet/lnet/lib-md.c b/net/lnet/lnet/lib-md.c
index d745b91..a9a83c3 100644
--- a/net/lnet/lnet/lib-md.c
+++ b/net/lnet/lnet/lib-md.c
@@ -164,12 +164,42 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 	return cpt;
 }
 
-static int
-lnet_md_build(struct lnet_libmd *lmd, struct lnet_md *umd, int unlink)
+static struct lnet_libmd *
+lnet_md_build(struct lnet_md *umd, int unlink)
 {
 	int i;
 	unsigned int niov;
 	int total_length = 0;
+	struct lnet_libmd *lmd;
+	unsigned int size;
+
+	if ((umd->options & LNET_MD_KIOV) != 0) {
+		niov = umd->length;
+		size = offsetof(struct lnet_libmd, md_iov.kiov[niov]);
+	} else {
+		niov = 1;
+		size = offsetof(struct lnet_libmd, md_iov.iov[niov]);
+	}
+
+	if (size <= LNET_SMALL_MD_SIZE) {
+		lmd = kmem_cache_zalloc(lnet_small_mds_cachep, GFP_NOFS);
+		if (lmd) {
+			CDEBUG(D_MALLOC,
+			       "slab-alloced 'md' of size %u@%p.\n",
+			       size, lmd);
+		} else {
+			CDEBUG(D_MALLOC, "failed to allocate 'md' of size %u\n",
+			       size);
+		}
+	} else {
+		lmd = kzalloc(size, GFP_NOFS);
+	}
+
+	if (!lmd)
+		return ERR_PTR(-ENOMEM);
+
+	lmd->md_niov = niov;
+	INIT_LIST_HEAD(&lmd->md_list);
 
 	lmd->md_me = NULL;
 	lmd->md_start = umd->start;
@@ -192,8 +222,10 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 		for (i = 0; i < (int)niov; i++) {
 			/* We take the page pointer on trust */
 			if (lmd->md_iov.kiov[i].bv_offset +
-			    lmd->md_iov.kiov[i].bv_len > PAGE_SIZE)
-				return -EINVAL; /* invalid length */
+			    lmd->md_iov.kiov[i].bv_len > PAGE_SIZE) {
+				lnet_md_free(lmd);
+				return ERR_PTR(-EINVAL); /* invalid length */
+			}
 
 			total_length += lmd->md_iov.kiov[i].bv_len;
 		}
@@ -202,8 +234,10 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 
 		if ((umd->options & LNET_MD_MAX_SIZE) && /* max size used */
 		    (umd->max_size < 0 ||
-		     umd->max_size > total_length)) /* illegal max_size */
-			return -EINVAL;
+		     umd->max_size > total_length)) { /* illegal max_size */
+			lnet_md_free(lmd);
+			return ERR_PTR(-EINVAL);
+		}
 	} else {   /* contiguous */
 		lmd->md_length = umd->length;
 		niov = 1;
@@ -213,11 +247,13 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 
 		if ((umd->options & LNET_MD_MAX_SIZE) && /* max size used */
 		    (umd->max_size < 0 ||
-		     umd->max_size > (int)umd->length)) /* illegal max_size */
-			return -EINVAL;
+		     umd->max_size > (int)umd->length)) { /* illegal max_size */
+			lnet_md_free(lmd);
+			return ERR_PTR(-EINVAL);
+		}
 	}
 
-	return 0;
+	return lmd;
 }
 
 /* must be called with resource lock held */
@@ -326,13 +362,9 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 		return -EINVAL;
 	}
 
-	md = lnet_md_alloc(&umd);
-	if (!md)
-		return -ENOMEM;
-
-	rc = lnet_md_build(md, &umd, unlink);
-	if (rc)
-		goto out_free;
+	md = lnet_md_build(&umd, unlink);
+	if (IS_ERR(md))
+		return PTR_ERR(md);
 
 	cpt = me->me_cpt;
 
@@ -363,7 +395,6 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 
 out_unlock:
 	lnet_res_unlock(cpt);
-out_free:
 	kfree(md);
 	return rc;
 }
@@ -403,13 +434,9 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 		return -EINVAL;
 	}
 
-	md = lnet_md_alloc(&umd);
-	if (!md)
-		return -ENOMEM;
-
-	rc = lnet_md_build(md, &umd, unlink);
-	if (rc)
-		goto out_free;
+	md = lnet_md_build(&umd, unlink);
+	if (IS_ERR(md))
+		return PTR_ERR(md);
 
 	if (md->md_length > LNET_MTU) {
 		CERROR("Invalid length: too big transfer size %u, %d max\n",
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 05/45] lnet: always put a page list into struct lnet_libmd
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (3 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 04/45] lnet: merge lnet_md_alloc into lnet_md_build James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 06/45] lnet: discard kvec option from lnet_libmd James Simmons
                   ` (40 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

'struct lnet_libmd' is only created in lnet_md_build().  It can be
given a list of pages or a virtual address.  In the latter case, the
memory will eventually be split into a list of pages.  It is cleaner
to split it into a list of pages early so that all lower levels only
need to handle one type: a page list.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13004
Lustre-commit: 857f11169fc8 ("LU-13004 lnet: always put a page list into struct lnet_libmd")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/37842
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/lnet/lib-md.c | 38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/net/lnet/lnet/lib-md.c b/net/lnet/lnet/lib-md.c
index a9a83c3..e1b8a06 100644
--- a/net/lnet/lnet/lib-md.c
+++ b/net/lnet/lnet/lib-md.c
@@ -173,13 +173,12 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 	struct lnet_libmd *lmd;
 	unsigned int size;
 
-	if ((umd->options & LNET_MD_KIOV) != 0) {
+	if (umd->options & LNET_MD_KIOV)
 		niov = umd->length;
-		size = offsetof(struct lnet_libmd, md_iov.kiov[niov]);
-	} else {
-		niov = 1;
-		size = offsetof(struct lnet_libmd, md_iov.iov[niov]);
-	}
+	else
+		niov = DIV_ROUND_UP(offset_in_page(umd->start) + umd->length,
+				    PAGE_SIZE);
+	size = offsetof(struct lnet_libmd, md_iov.kiov[niov]);
 
 	if (size <= LNET_SMALL_MD_SIZE) {
 		lmd = kmem_cache_zalloc(lnet_small_mds_cachep, GFP_NOFS);
@@ -200,7 +199,6 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 
 	lmd->md_niov = niov;
 	INIT_LIST_HEAD(&lmd->md_list);
-
 	lmd->md_me = NULL;
 	lmd->md_start = umd->start;
 	lmd->md_offset = 0;
@@ -238,19 +236,33 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 			lnet_md_free(lmd);
 			return ERR_PTR(-EINVAL);
 		}
-	} else {   /* contiguous */
-		lmd->md_length = umd->length;
-		niov = 1;
-		lmd->md_niov = 1;
-		lmd->md_iov.iov[0].iov_base = umd->start;
-		lmd->md_iov.iov[0].iov_len = umd->length;
+	} else {   /* contiguous - split into pages */
+		void *pa = umd->start;
+		int len = umd->length;
 
+		lmd->md_length = len;
+		i = 0;
+		while (len) {
+			int plen;
+
+			plen = min_t(int, len, PAGE_SIZE - offset_in_page(pa));
+
+			lmd->md_iov.kiov[i].bv_page =
+				lnet_kvaddr_to_page((unsigned long) pa);
+			lmd->md_iov.kiov[i].bv_offset = offset_in_page(pa);
+			lmd->md_iov.kiov[i].bv_len = plen;
+
+			len -= plen;
+			pa += plen;
+			i += 1;
+		}
 		if ((umd->options & LNET_MD_MAX_SIZE) && /* max size used */
 		    (umd->max_size < 0 ||
 		     umd->max_size > (int)umd->length)) { /* illegal max_size */
 			lnet_md_free(lmd);
 			return ERR_PTR(-EINVAL);
 		}
+		lmd->md_options |= LNET_MD_KIOV;
 	}
 
 	return lmd;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 06/45] lnet: discard kvec option from lnet_libmd.
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (4 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 05/45] lnet: always put a page list into struct lnet_libmd James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 07/45] lnet: remove msg_iov from lnet_msg James Simmons
                   ` (39 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

The 'struct kvec' field in 'struct lnet_libmd' is no longer set - the
memory is always presented as pages.  So remove that option and the
union that contained iov and kiov.

Rename md_iov.kiov to md_kiov.
Discard all code that made use of md_iov.iov.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13004
Lustre-commit: 4775d52439f4f ("LU-13004 lnet: discard kvec option from lnet_libmd.")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/37843
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 include/linux/lnet/lib-lnet.h       |  7 +---
 include/linux/lnet/lib-types.h      |  5 +--
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c | 14 ++-----
 net/lnet/lnet/lib-md.c              | 79 +++++++++----------------------------
 net/lnet/lnet/lib-move.c            |  5 +--
 5 files changed, 27 insertions(+), 83 deletions(-)

diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h
index 66e01a0..03ac3f9 100644
--- a/include/linux/lnet/lib-lnet.h
+++ b/include/linux/lnet/lib-lnet.h
@@ -89,7 +89,7 @@
 
 bool lnet_is_route_alive(struct lnet_route *route);
 
-#define LNET_SMALL_MD_SIZE	offsetof(struct lnet_libmd, md_iov.iov[1])
+#define LNET_SMALL_MD_SIZE	offsetof(struct lnet_libmd, md_kiov[1])
 extern struct kmem_cache *lnet_mes_cachep;	 /* MEs kmem_cache */
 extern struct kmem_cache *lnet_small_mds_cachep; /* <= LNET_SMALL_MD_SIZE bytes
 						  * MDs kmem_cache
@@ -165,10 +165,7 @@ static inline int lnet_md_unlinkable(struct lnet_libmd *md)
 
 	LASSERTF(md->md_rspt_ptr == NULL, "md %p rsp %p\n", md, md->md_rspt_ptr);
 
-	if ((md->md_options & LNET_MD_KIOV) != 0)
-		size = offsetof(struct lnet_libmd, md_iov.kiov[md->md_niov]);
-	else
-		size = offsetof(struct lnet_libmd, md_iov.iov[md->md_niov]);
+	size = offsetof(struct lnet_libmd, md_kiov[md->md_niov]);
 
 	if (size <= LNET_SMALL_MD_SIZE) {
 		CDEBUG(D_MALLOC, "slab-freed 'md'@%p.\n", md);
diff --git a/include/linux/lnet/lib-types.h b/include/linux/lnet/lib-types.h
index 0629f20..9a11aa5 100644
--- a/include/linux/lnet/lib-types.h
+++ b/include/linux/lnet/lib-types.h
@@ -208,10 +208,7 @@ struct lnet_libmd {
 	struct lnet_rsp_tracker	*md_rspt_ptr;
 	lnet_handler_t		 md_handler;
 	struct lnet_handle_md	 md_bulk_handle;
-	union {
-		struct kvec	iov[LNET_MAX_IOV];
-		struct bio_vec	kiov[LNET_MAX_IOV];
-	} md_iov;
+	struct bio_vec		 md_kiov[LNET_MAX_IOV];
 };
 
 #define LNET_MD_FLAG_ZOMBIE		BIT(0)
diff --git a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 087657c..7f782fb 100644
--- a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1626,16 +1626,10 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 
 		ibmsg = tx->tx_msg;
 		rd = &ibmsg->ibm_u.get.ibgm_rd;
-		if (!(lntmsg->msg_md->md_options & LNET_MD_KIOV))
-			rc = kiblnd_setup_rd_iov(ni, tx, rd,
-						 lntmsg->msg_md->md_niov,
-						 lntmsg->msg_md->md_iov.iov,
-						 0, lntmsg->msg_md->md_length);
-		else
-			rc = kiblnd_setup_rd_kiov(ni, tx, rd,
-						  lntmsg->msg_md->md_niov,
-						  lntmsg->msg_md->md_iov.kiov,
-						  0, lntmsg->msg_md->md_length);
+		rc = kiblnd_setup_rd_kiov(ni, tx, rd,
+					  lntmsg->msg_md->md_niov,
+					  lntmsg->msg_md->md_kiov,
+					  0, lntmsg->msg_md->md_length);
 		if (rc) {
 			CERROR("Can't setup GET sink for %s: %d\n",
 			       libcfs_nid2str(target.nid), rc);
diff --git a/net/lnet/lnet/lib-md.c b/net/lnet/lnet/lib-md.c
index e1b8a06..cfa285a 100644
--- a/net/lnet/lnet/lib-md.c
+++ b/net/lnet/lnet/lib-md.c
@@ -91,6 +91,7 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 {
 	int cpt = CFS_CPT_ANY;
 	unsigned int niov;
+	struct bio_vec *kiov;
 
 	/*
 	 * if the md_options has a bulk handle then we want to look at the
@@ -103,63 +104,21 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 	if (!md || md->md_niov == 0)
 		return CFS_CPT_ANY;
 
+	kiov = md->md_kiov;
 	niov = md->md_niov;
 
-	/*
-	 * There are three cases to handle:
-	 *  1. The MD is using lnet_kiov_t
-	 *  2. The MD is using struct kvec
-	 *  3. Contiguous buffer allocated via vmalloc
-	 *
-	 *  in case 2 we can use virt_to_page() macro to get the page
-	 *  address of the memory kvec describes.
-	 *
-	 *  in case 3 use is_vmalloc_addr() and vmalloc_to_page()
-	 *
-	 * The offset provided can be within the first iov/kiov entry or
-	 * it could go beyond it. In that case we need to make sure to
-	 * look at the page which actually contains the data that will be
-	 * DMAed.
-	 */
-	if ((md->md_options & LNET_MD_KIOV) != 0) {
-		struct bio_vec *kiov = md->md_iov.kiov;
-
-		while (offset >= kiov->bv_len) {
-			offset -= kiov->bv_len;
-			niov--;
-			kiov++;
-			if (niov == 0) {
-				CERROR("offset %d goes beyond kiov\n", offset);
-				goto out;
-			}
-		}
-
-		cpt = cfs_cpt_of_node(lnet_cpt_table(),
-				      page_to_nid(kiov->bv_page));
-	} else {
-		struct kvec *iov = md->md_iov.iov;
-		unsigned long vaddr;
-		struct page *page;
-
-		while (offset >= iov->iov_len) {
-			offset -= iov->iov_len;
-			niov--;
-			iov++;
-			if (niov == 0) {
-				CERROR("offset %d goes beyond iov\n", offset);
-				goto out;
-			}
-		}
-
-		vaddr = ((unsigned long)iov->iov_base) + offset;
-		page = lnet_kvaddr_to_page(vaddr);
-		if (!page) {
-			CERROR("Couldn't resolve vaddr 0x%lx to page\n", vaddr);
+	while (offset >= kiov->bv_len) {
+		offset -= kiov->bv_len;
+		niov--;
+		kiov++;
+		if (niov == 0) {
+			CERROR("offset %d goes beyond iov\n", offset);
 			goto out;
 		}
-		cpt = cfs_cpt_of_node(lnet_cpt_table(), page_to_nid(page));
 	}
 
+	cpt = cfs_cpt_of_node(lnet_cpt_table(),
+			      page_to_nid(kiov->bv_page));
 out:
 	return cpt;
 }
@@ -178,7 +137,7 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 	else
 		niov = DIV_ROUND_UP(offset_in_page(umd->start) + umd->length,
 				    PAGE_SIZE);
-	size = offsetof(struct lnet_libmd, md_iov.kiov[niov]);
+	size = offsetof(struct lnet_libmd, md_kiov[niov]);
 
 	if (size <= LNET_SMALL_MD_SIZE) {
 		lmd = kmem_cache_zalloc(lnet_small_mds_cachep, GFP_NOFS);
@@ -214,18 +173,18 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 	if (umd->options & LNET_MD_KIOV) {
 		niov = umd->length;
 		lmd->md_niov = umd->length;
-		memcpy(lmd->md_iov.kiov, umd->start,
-		       niov * sizeof(lmd->md_iov.kiov[0]));
+		memcpy(lmd->md_kiov, umd->start,
+		       niov * sizeof(lmd->md_kiov[0]));
 
 		for (i = 0; i < (int)niov; i++) {
 			/* We take the page pointer on trust */
-			if (lmd->md_iov.kiov[i].bv_offset +
-			    lmd->md_iov.kiov[i].bv_len > PAGE_SIZE) {
+			if (lmd->md_kiov[i].bv_offset +
+			    lmd->md_kiov[i].bv_len > PAGE_SIZE) {
 				lnet_md_free(lmd);
 				return ERR_PTR(-EINVAL); /* invalid length */
 			}
 
-			total_length += lmd->md_iov.kiov[i].bv_len;
+			total_length += lmd->md_kiov[i].bv_len;
 		}
 
 		lmd->md_length = total_length;
@@ -247,10 +206,10 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 
 			plen = min_t(int, len, PAGE_SIZE - offset_in_page(pa));
 
-			lmd->md_iov.kiov[i].bv_page =
+			lmd->md_kiov[i].bv_page =
 				lnet_kvaddr_to_page((unsigned long) pa);
-			lmd->md_iov.kiov[i].bv_offset = offset_in_page(pa);
-			lmd->md_iov.kiov[i].bv_len = plen;
+			lmd->md_kiov[i].bv_offset = offset_in_page(pa);
+			lmd->md_kiov[i].bv_len = plen;
 
 			len -= plen;
 			pa += plen;
diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c
index 9f815c1..dc49e60 100644
--- a/net/lnet/lnet/lib-move.c
+++ b/net/lnet/lnet/lib-move.c
@@ -538,10 +538,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 	LASSERT(!msg->msg_kiov);
 
 	msg->msg_niov = md->md_niov;
-	if (md->md_options & LNET_MD_KIOV)
-		msg->msg_kiov = md->md_iov.kiov;
-	else
-		msg->msg_iov = md->md_iov.iov;
+	msg->msg_kiov = md->md_kiov;
 }
 
 void
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 07/45] lnet: remove msg_iov from lnet_msg.
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (5 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 06/45] lnet: discard kvec option from lnet_libmd James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 08/45] lnet: o2iblnd: discard kiblnd_setup_rd_iov James Simmons
                   ` (38 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

This field is never set, so remove it and remove all uses of it.

Conversely, msg_kiov is always non-NULL, so remove code that depends
on it being NULL.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13004
Lustre-commit: 585e6df77ebf2 ("LU-13004 lnet: remove msg_iov from lnet_msg.")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/37844
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 include/linux/lnet/lib-types.h      |  1 -
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c | 34 ++++++++------------------------
 net/lnet/klnds/socklnd/socklnd_cb.c | 39 +++++++++++--------------------------
 net/lnet/lnet/lib-move.c            | 16 ++++-----------
 net/lnet/lnet/lo.c                  | 17 +++++-----------
 5 files changed, 28 insertions(+), 79 deletions(-)

diff --git a/include/linux/lnet/lib-types.h b/include/linux/lnet/lib-types.h
index 9a11aa5..1a71483 100644
--- a/include/linux/lnet/lib-types.h
+++ b/include/linux/lnet/lib-types.h
@@ -164,7 +164,6 @@ struct lnet_msg {
 	unsigned int		 msg_wanted;
 	unsigned int		 msg_offset;
 	unsigned int		 msg_niov;
-	struct kvec		*msg_iov;
 	struct bio_vec		*msg_kiov;
 
 	struct lnet_event	 msg_ev;
diff --git a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 7f782fb..18edb1e 100644
--- a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1564,7 +1564,6 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 	int target_is_router = lntmsg->msg_target_is_router;
 	int routing = lntmsg->msg_routing;
 	unsigned int payload_niov = lntmsg->msg_niov;
-	struct kvec *payload_iov = lntmsg->msg_iov;
 	struct bio_vec *payload_kiov = lntmsg->msg_kiov;
 	unsigned int payload_offset = lntmsg->msg_offset;
 	unsigned int payload_nob = lntmsg->msg_len;
@@ -1585,17 +1584,10 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 
 	/* Thread context */
 	LASSERT(!in_interrupt());
-	/* payload is either all vaddrs or all pages */
-	LASSERT(!(payload_kiov && payload_iov));
 
-	if (payload_kiov)
-		iov_iter_bvec(&from, WRITE,
-			      payload_kiov, payload_niov,
-			      payload_nob + payload_offset);
-	else
-		iov_iter_kvec(&from, WRITE,
-			      payload_iov, payload_niov,
-			      payload_nob + payload_offset);
+	iov_iter_bvec(&from, WRITE,
+		      payload_kiov, payload_niov,
+		      payload_nob + payload_offset);
 
 	iov_iter_advance(&from, payload_offset);
 
@@ -1627,9 +1619,8 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 		ibmsg = tx->tx_msg;
 		rd = &ibmsg->ibm_u.get.ibgm_rd;
 		rc = kiblnd_setup_rd_kiov(ni, tx, rd,
-					  lntmsg->msg_md->md_niov,
-					  lntmsg->msg_md->md_kiov,
-					  0, lntmsg->msg_md->md_length);
+					  payload_niov, payload_kiov,
+					  payload_offset, payload_nob);
 		if (rc) {
 			CERROR("Can't setup GET sink for %s: %d\n",
 			       libcfs_nid2str(target.nid), rc);
@@ -1672,14 +1663,9 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 			return -ENOMEM;
 		}
 
-		if (!payload_kiov)
-			rc = kiblnd_setup_rd_iov(ni, tx, tx->tx_rd,
-						 payload_niov, payload_iov,
-						 payload_offset, payload_nob);
-		else
-			rc = kiblnd_setup_rd_kiov(ni, tx, tx->tx_rd,
-						  payload_niov, payload_kiov,
-						  payload_offset, payload_nob);
+		rc = kiblnd_setup_rd_kiov(ni, tx, tx->tx_rd,
+					  payload_niov, payload_kiov,
+					  payload_offset, payload_nob);
 		if (rc) {
 			CERROR("Can't setup PUT src for %s: %d\n",
 			       libcfs_nid2str(target.nid), rc);
@@ -1733,7 +1719,6 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 {
 	struct lnet_process_id target = lntmsg->msg_target;
 	unsigned int niov = lntmsg->msg_niov;
-	struct kvec *iov = lntmsg->msg_iov;
 	struct bio_vec *kiov = lntmsg->msg_kiov;
 	unsigned int offset = lntmsg->msg_offset;
 	unsigned int nob = lntmsg->msg_len;
@@ -1749,9 +1734,6 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 
 	if (!nob)
 		rc = 0;
-	else if (!kiov)
-		rc = kiblnd_setup_rd_iov(ni, tx, tx->tx_rd,
-					 niov, iov, offset, nob);
 	else
 		rc = kiblnd_setup_rd_kiov(ni, tx, tx->tx_rd,
 					  niov, kiov, offset, nob);
diff --git a/net/lnet/klnds/socklnd/socklnd_cb.c b/net/lnet/klnds/socklnd/socklnd_cb.c
index 9d5e03b..83fcb28 100644
--- a/net/lnet/klnds/socklnd/socklnd_cb.c
+++ b/net/lnet/klnds/socklnd/socklnd_cb.c
@@ -914,7 +914,6 @@ struct ksock_route *
 	int type = lntmsg->msg_type;
 	struct lnet_process_id target = lntmsg->msg_target;
 	unsigned int payload_niov = lntmsg->msg_niov;
-	struct kvec *payload_iov = lntmsg->msg_iov;
 	struct bio_vec *payload_kiov = lntmsg->msg_kiov;
 	unsigned int payload_offset = lntmsg->msg_offset;
 	unsigned int payload_nob = lntmsg->msg_len;
@@ -931,16 +930,10 @@ struct ksock_route *
 
 	LASSERT(!payload_nob || payload_niov > 0);
 	LASSERT(payload_niov <= LNET_MAX_IOV);
-	/* payload is either all vaddrs or all pages */
-	LASSERT(!(payload_kiov && payload_iov));
 	LASSERT(!in_interrupt());
 
-	if (payload_iov)
-		desc_size = offsetof(struct ksock_tx,
-				     tx_frags.virt.iov[1 + payload_niov]);
-	else
-		desc_size = offsetof(struct ksock_tx,
-				     tx_frags.paged.kiov[payload_niov]);
+	desc_size = offsetof(struct ksock_tx,
+			     tx_frags.paged.kiov[payload_niov]);
 
 	if (lntmsg->msg_vmflush)
 		mpflag = memalloc_noreclaim_save();
@@ -956,25 +949,15 @@ struct ksock_route *
 	tx->tx_conn = NULL;		/* set when assigned a conn */
 	tx->tx_lnetmsg = lntmsg;
 
-	if (payload_iov) {
-		tx->tx_kiov = NULL;
-		tx->tx_nkiov = 0;
-		tx->tx_iov = tx->tx_frags.virt.iov;
-		tx->tx_niov = 1 +
-			      lnet_extract_iov(payload_niov, &tx->tx_iov[1],
-					       payload_niov, payload_iov,
-					       payload_offset, payload_nob);
-	} else {
-		tx->tx_niov = 1;
-		tx->tx_iov = &tx->tx_frags.paged.iov;
-		tx->tx_kiov = tx->tx_frags.paged.kiov;
-		tx->tx_nkiov = lnet_extract_kiov(payload_niov, tx->tx_kiov,
-						 payload_niov, payload_kiov,
-						 payload_offset, payload_nob);
-
-		if (payload_nob >= *ksocknal_tunables.ksnd_zc_min_payload)
-			tx->tx_zc_capable = 1;
-	}
+	tx->tx_niov = 1;
+	tx->tx_iov = &tx->tx_frags.paged.iov;
+	tx->tx_kiov = tx->tx_frags.paged.kiov;
+	tx->tx_nkiov = lnet_extract_kiov(payload_niov, tx->tx_kiov,
+					 payload_niov, payload_kiov,
+					 payload_offset, payload_nob);
+
+	if (payload_nob >= *ksocknal_tunables.ksnd_zc_min_payload)
+		tx->tx_zc_capable = 1;
 
 	tx->tx_msg.ksm_csum = 0;
 	tx->tx_msg.ksm_type = KSOCK_MSG_LNET;
diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c
index dc49e60..6ef9978 100644
--- a/net/lnet/lnet/lib-move.c
+++ b/net/lnet/lnet/lib-move.c
@@ -485,7 +485,6 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 	     unsigned int rlen)
 {
 	unsigned int niov = 0;
-	struct kvec *iov = NULL;
 	struct bio_vec *kiov = NULL;
 	struct iov_iter to;
 	int rc;
@@ -505,21 +504,16 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 
 		if (mlen) {
 			niov = msg->msg_niov;
-			iov = msg->msg_iov;
 			kiov = msg->msg_kiov;
 
 			LASSERT(niov > 0);
-			LASSERT(!iov != !kiov);
+			LASSERT(kiov);
 		}
 	}
 
-	if (iov) {
-		iov_iter_kvec(&to, READ, iov, niov, mlen + offset);
-		iov_iter_advance(&to, offset);
-	} else {
-		iov_iter_bvec(&to, READ, kiov, niov, mlen + offset);
-		iov_iter_advance(&to, offset);
-	}
+	iov_iter_bvec(&to, READ, kiov, niov, mlen + offset);
+	iov_iter_advance(&to, offset);
+
 	rc = ni->ni_net->net_lnd->lnd_recv(ni, private, msg, delayed, &to, rlen);
 	if (rc < 0)
 		lnet_finalize(msg, rc);
@@ -534,7 +528,6 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 	LASSERT(!msg->msg_routing);
 	LASSERT(md);
 	LASSERT(!msg->msg_niov);
-	LASSERT(!msg->msg_iov);
 	LASSERT(!msg->msg_kiov);
 
 	msg->msg_niov = md->md_niov;
@@ -809,7 +802,6 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 	struct lnet_rtrbufpool *rbp;
 	struct lnet_rtrbuf *rb;
 
-	LASSERT(!msg->msg_iov);
 	LASSERT(!msg->msg_kiov);
 	LASSERT(!msg->msg_niov);
 	LASSERT(msg->msg_routing);
diff --git a/net/lnet/lnet/lo.c b/net/lnet/lnet/lo.c
index c19a5b5..58b0ee9 100644
--- a/net/lnet/lnet/lo.c
+++ b/net/lnet/lnet/lo.c
@@ -51,18 +51,11 @@
 	struct lnet_msg *sendmsg = private;
 
 	if (lntmsg) {		/* not discarding */
-		if (sendmsg->msg_iov)
-			lnet_copy_iov2iter(to,
-					   sendmsg->msg_niov,
-					   sendmsg->msg_iov,
-					   sendmsg->msg_offset,
-					   iov_iter_count(to));
-		else
-			lnet_copy_kiov2iter(to,
-					    sendmsg->msg_niov,
-					    sendmsg->msg_kiov,
-					    sendmsg->msg_offset,
-					    iov_iter_count(to));
+		lnet_copy_kiov2iter(to,
+				    sendmsg->msg_niov,
+				    sendmsg->msg_kiov,
+				    sendmsg->msg_offset,
+				    iov_iter_count(to));
 
 		lnet_finalize(lntmsg, 0);
 	}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 08/45] lnet: o2iblnd: discard kiblnd_setup_rd_iov
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (6 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 07/45] lnet: remove msg_iov from lnet_msg James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 09/45] lustre: ptlrpc: return proper write count from ping_store James Simmons
                   ` (37 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

The 'to' passed to lnd_recv is *always* ITER_BVEC, so
we can discard kiblnd_setup_rd_iov().

WC-bug-id: https://jira.whamcloud.com/browse/LU-13004
Lustre-commit: e35b7751f49fb ("LU-13004 lnet: remove the 'struct kvec' arg from lnd_send")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/37845
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 include/linux/lnet/lib-types.h      |  6 +--
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c | 80 ++-----------------------------------
 2 files changed, 5 insertions(+), 81 deletions(-)

diff --git a/include/linux/lnet/lib-types.h b/include/linux/lnet/lib-types.h
index 1a71483..f78b372 100644
--- a/include/linux/lnet/lib-types.h
+++ b/include/linux/lnet/lib-types.h
@@ -239,11 +239,7 @@ struct lnet_lnd {
 
 	/*
 	 * In data movement APIs below, payload buffers are described as a set
-	 * of 'niov' fragments which are...
-	 * EITHER
-	 *    in virtual memory (struct iovec *iov != NULL)
-	 * OR
-	 *    in pages (kernel only: plt_kiov_t *kiov != NULL).
+	 * of 'niov' fragments which are in pages.
 	 * The LND may NOT overwrite these fragment descriptors.
 	 * An 'offset' and may specify a byte offset within the set of
 	 * fragments to start from
diff --git a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 18edb1e..f7c802f 100644
--- a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -675,71 +675,6 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 }
 
 static int
-kiblnd_setup_rd_iov(struct lnet_ni *ni, struct kib_tx *tx,
-		    struct kib_rdma_desc *rd, unsigned int niov,
-		    const struct kvec *iov, int offset, int nob)
-{
-	struct kib_net *net = ni->ni_data;
-	struct page *page;
-	struct scatterlist *sg;
-	unsigned long vaddr;
-	int fragnob;
-	int page_offset;
-
-	LASSERT(nob > 0);
-	LASSERT(niov > 0);
-	LASSERT(net);
-
-	while (offset >= iov->iov_len) {
-		offset -= iov->iov_len;
-		niov--;
-		iov++;
-		LASSERT(niov > 0);
-	}
-
-	sg = tx->tx_frags;
-	do {
-		LASSERT(niov > 0);
-
-		vaddr = ((unsigned long)iov->iov_base) + offset;
-		page_offset = vaddr & (PAGE_SIZE - 1);
-		page = lnet_kvaddr_to_page(vaddr);
-		if (!page) {
-			CERROR("Can't find page\n");
-			return -EFAULT;
-		}
-
-		fragnob = min((int)(iov->iov_len - offset), nob);
-		fragnob = min(fragnob, (int)PAGE_SIZE - page_offset);
-
-		if ((fragnob < (int)PAGE_SIZE - page_offset) && (niov > 1)) {
-			CDEBUG(D_NET,
-			       "fragnob %d < available page %d: with remaining %d iovs\n",
-			       fragnob, (int)PAGE_SIZE - page_offset, niov);
-			tx->tx_gaps = true;
-		}
-
-		sg_set_page(sg, page, fragnob, page_offset);
-		sg = sg_next(sg);
-		if (!sg) {
-			CERROR("lacking enough sg entries to map tx\n");
-			return -EFAULT;
-		}
-
-		if (offset + fragnob < iov->iov_len) {
-			offset += fragnob;
-		} else {
-			offset = 0;
-			iov++;
-			niov--;
-		}
-		nob -= fragnob;
-	} while (nob > 0);
-
-	return kiblnd_map_tx(ni, tx, rd, sg - tx->tx_frags);
-}
-
-static int
 kiblnd_setup_rd_kiov(struct lnet_ni *ni, struct kib_tx *tx,
 		     struct kib_rdma_desc *rd, int nkiov,
 		     const struct bio_vec *kiov, int offset, int nob)
@@ -1787,7 +1722,6 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 
 	LASSERT(iov_iter_count(to) <= rlen);
 	LASSERT(!in_interrupt());
-	/* Either all pages or all vaddrs */
 
 	switch (rxmsg->ibm_type) {
 	default:
@@ -1836,16 +1770,10 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 
 		txmsg = tx->tx_msg;
 		rd = &txmsg->ibm_u.putack.ibpam_rd;
-		if (!(to->type & ITER_BVEC))
-			rc = kiblnd_setup_rd_iov(ni, tx, rd,
-						 to->nr_segs, to->kvec,
-						 to->iov_offset,
-						 iov_iter_count(to));
-		else
-			rc = kiblnd_setup_rd_kiov(ni, tx, rd,
-						  to->nr_segs, to->bvec,
-						  to->iov_offset,
-						  iov_iter_count(to));
+		rc = kiblnd_setup_rd_kiov(ni, tx, rd,
+					  to->nr_segs, to->bvec,
+					  to->iov_offset,
+					  iov_iter_count(to));
 		if (rc) {
 			CERROR("Can't setup PUT sink for %s: %d\n",
 			       libcfs_nid2str(conn->ibc_peer->ibp_nid), rc);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 09/45] lustre: ptlrpc: return proper write count from ping_store
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (7 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 08/45] lnet: o2iblnd: discard kiblnd_setup_rd_iov James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 10/45] lustre: sec: check permissions for changelogs access James Simmons
                   ` (36 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Oleg Drokin <green@whamcloud.com>

If we return 0 as a measure of success, that is actually taken
by userspace as "we wrote 0 bytes, but there's no error, so
they want us to retry". So tell them we ate all their data
instead to make them happy.

Interesting that when you do shell-redirect it enters the
retry loop, but badarea_io does not.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13470
Lustre-commit: 16d62976d212d ("LU-13470 ptlrpc: return proper write count from ping_store")
Signed-off-by: Oleg Drokin <green@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38304
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/ptlrpc/lproc_ptlrpc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/ptlrpc/lproc_ptlrpc.c b/fs/lustre/ptlrpc/lproc_ptlrpc.c
index 5125ecd..86ec1f5 100644
--- a/fs/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/fs/lustre/ptlrpc/lproc_ptlrpc.c
@@ -1271,7 +1271,9 @@ ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
 ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
 		   const char *buffer, size_t count)
 {
-	return ping_show(kobj, attr, (char *)buffer);
+	int rc = ping_show(kobj, attr, (char *)buffer);
+
+	return (rc < 0) ? rc : count;
 }
 EXPORT_SYMBOL(ping_store);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 10/45] lustre: sec: check permissions for changelogs access
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (8 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 09/45] lustre: ptlrpc: return proper write count from ping_store James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 11/45] lustre: uapi: add OBD_CONNECT2_FIDMAP James Simmons
                   ` (35 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Sebastien Buisson <sbuisson@ddn.com>

root permissions should be checked when reading or clearing changelogs
from clients. In particular, if root is squashed via a nodemap entry,
it should not be allowed to access changelogs.
To achieve this send mdt body along with RQF_LLOG_ORIGIN_HANDLE_CREATE
and RQF_MDT_SET_INFO requests. And on server side, retrieve user
credentials and make sure they have root permission.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13064
Lustre-commit: 4e8fcee92d751 ("LU-13064 sec: check permissions for changelogs access")
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-on: https://review.whamcloud.com/36990
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Emoly Liu <emoly@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/lustre_req_layout.h |  1 +
 fs/lustre/ptlrpc/layout.c             | 15 ++++++++++++++-
 fs/lustre/ptlrpc/llog_client.c        |  4 ++++
 fs/lustre/ptlrpc/pack_generic.c       |  7 ++++++-
 fs/lustre/ptlrpc/ptlrpc_internal.h    | 19 +++++++++++++++++++
 5 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/fs/lustre/include/lustre_req_layout.h b/fs/lustre/include/lustre_req_layout.h
index ea6baef..f56dc8b 100644
--- a/fs/lustre/include/lustre_req_layout.h
+++ b/fs/lustre/include/lustre_req_layout.h
@@ -123,6 +123,7 @@ void req_capsule_shrink(struct req_capsule *pill,
 
 extern struct req_format RQF_OBD_PING;
 extern struct req_format RQF_OBD_SET_INFO;
+extern struct req_format RQF_MDT_SET_INFO;
 extern struct req_format RQF_SEC_CTX;
 /* MGS req_format */
 extern struct req_format RQF_MGS_TARGET_REG;
diff --git a/fs/lustre/ptlrpc/layout.c b/fs/lustre/ptlrpc/layout.c
index 6f849f0..fd8676d 100644
--- a/fs/lustre/ptlrpc/layout.c
+++ b/fs/lustre/ptlrpc/layout.c
@@ -348,6 +348,13 @@
 	&RMF_SETINFO_VAL
 };
 
+static const struct req_msg_field *mdt_set_info_client[] = {
+	&RMF_PTLRPC_BODY,
+	&RMF_SETINFO_KEY,
+	&RMF_SETINFO_VAL,
+	&RMF_MDT_BODY
+};
+
 static const struct req_msg_field *ost_grant_shrink_client[] = {
 	&RMF_PTLRPC_BODY,
 	&RMF_SETINFO_KEY,
@@ -549,7 +556,8 @@
 static const struct req_msg_field *llog_origin_handle_create_client[] = {
 	&RMF_PTLRPC_BODY,
 	&RMF_LLOGD_BODY,
-	&RMF_NAME
+	&RMF_NAME,
+	&RMF_MDT_BODY,
 };
 
 static const struct req_msg_field *llogd_body_only[] = {
@@ -698,6 +706,7 @@
 static struct req_format *req_formats[] = {
 	&RQF_OBD_PING,
 	&RQF_OBD_SET_INFO,
+	&RQF_MDT_SET_INFO,
 	&RQF_SEC_CTX,
 	&RQF_MGS_TARGET_REG,
 	&RQF_MGS_CONFIG_READ,
@@ -1238,6 +1247,10 @@ struct req_format RQF_OBD_SET_INFO =
 	DEFINE_REQ_FMT0("OBD_SET_INFO", obd_set_info_client, empty);
 EXPORT_SYMBOL(RQF_OBD_SET_INFO);
 
+struct req_format RQF_MDT_SET_INFO =
+	DEFINE_REQ_FMT0("MDT_SET_INFO", mdt_set_info_client, empty);
+EXPORT_SYMBOL(RQF_MDT_SET_INFO);
+
 struct req_format RQF_SEC_CTX =
 	DEFINE_REQ_FMT0("SEC_CTX", empty, empty);
 EXPORT_SYMBOL(RQF_SEC_CTX);
diff --git a/fs/lustre/ptlrpc/llog_client.c b/fs/lustre/ptlrpc/llog_client.c
index ff1ca36..aeefa8f 100644
--- a/fs/lustre/ptlrpc/llog_client.c
+++ b/fs/lustre/ptlrpc/llog_client.c
@@ -44,6 +44,8 @@
 #include <lustre_net.h>
 #include <linux/list.h>
 
+#include "ptlrpc_internal.h"
+
 #define LLOG_CLIENT_ENTRY(ctxt, imp) do {				\
 	mutex_lock(&ctxt->loc_mutex);					\
 	if (ctxt->loc_imp) {						\
@@ -120,6 +122,8 @@ static int llog_client_open(const struct lu_env *env,
 						   strlen(name) + 1);
 		LASSERT(tmp);
 		strcpy(tmp, name);
+
+		do_pack_body(req);
 	}
 
 	rc = ptlrpc_queue_wait(req);
diff --git a/fs/lustre/ptlrpc/pack_generic.c b/fs/lustre/ptlrpc/pack_generic.c
index dfde8cc..ec853d1 100644
--- a/fs/lustre/ptlrpc/pack_generic.c
+++ b/fs/lustre/ptlrpc/pack_generic.c
@@ -1506,7 +1506,9 @@ int do_set_info_async(struct obd_import *imp,
 	char *tmp;
 	int rc;
 
-	req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO);
+	req = ptlrpc_request_alloc(imp, KEY_IS(KEY_CHANGELOG_CLEAR) ?
+					&RQF_MDT_SET_INFO :
+					&RQF_OBD_SET_INFO);
 	if (!req)
 		return -ENOMEM;
 
@@ -1520,6 +1522,9 @@ int do_set_info_async(struct obd_import *imp,
 		return rc;
 	}
 
+	if (KEY_IS(KEY_CHANGELOG_CLEAR))
+		do_pack_body(req);
+
 	tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY);
 	memcpy(tmp, key, keylen);
 	tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL);
diff --git a/fs/lustre/ptlrpc/ptlrpc_internal.h b/fs/lustre/ptlrpc/ptlrpc_internal.h
index b340de7..83995cc 100644
--- a/fs/lustre/ptlrpc/ptlrpc_internal.h
+++ b/fs/lustre/ptlrpc/ptlrpc_internal.h
@@ -377,4 +377,23 @@ static inline bool ptlrpc_req_is_disconnect(struct ptlrpc_request *req)
 		return false;
 }
 
+static inline void do_pack_body(struct ptlrpc_request *req)
+{
+	struct mdt_body *b = req_capsule_client_get(&req->rq_pill,
+						    &RMF_MDT_BODY);
+
+	if (!b)
+		return;
+
+	b->mbo_valid = 0;
+	b->mbo_eadatasize = 0;
+	b->mbo_flags = 0;
+	b->mbo_suppgid = -1;
+	b->mbo_uid = from_kuid(&init_user_ns, current_uid());
+	b->mbo_gid = from_kgid(&init_user_ns, current_gid());
+	b->mbo_fsuid = from_kuid(&init_user_ns, current_fsuid());
+	b->mbo_fsgid = from_kgid(&init_user_ns, current_fsgid());
+	b->mbo_capability = current_cap().cap[0];
+}
+
 #endif /* PTLRPC_INTERNAL_H */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 11/45] lustre: uapi: add OBD_CONNECT2_FIDMAP
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (9 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 10/45] lustre: sec: check permissions for changelogs access James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 12/45] lustre: lov: lov_io_sub_init()) ASSERTION James Simmons
                   ` (34 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Lai Siyao <lai.siyao@whamcloud.com>

Add OBD_CONNECT2_FIDMAP connect flag, which indicates whether client
supports FID mapping.

WC-bug-id: https://jira.whamcloud.com/browse/LU-11025
Lustre-commit: c96fa612d5b0f ("LU-11025 uapi: add OBD_CONNECT2_FIDMAP")
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38232
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/ptlrpc/wiretest.c            | 2 ++
 include/uapi/linux/lustre/lustre_idl.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/fs/lustre/ptlrpc/wiretest.c b/fs/lustre/ptlrpc/wiretest.c
index fee4be2..81d0a99 100644
--- a/fs/lustre/ptlrpc/wiretest.c
+++ b/fs/lustre/ptlrpc/wiretest.c
@@ -1241,6 +1241,8 @@ void lustre_assert_wire_constants(void)
 		 OBD_CONNECT2_ASYNC_DISCARD);
 	LASSERTF(OBD_CONNECT2_ENCRYPT == 0x8000ULL, "found 0x%.16llxULL\n",
 		 OBD_CONNECT2_ENCRYPT);
+	LASSERTF(OBD_CONNECT2_FIDMAP== 0x10000ULL, "found 0x%.16llxULL\n",
+		 OBD_CONNECT2_FIDMAP);
 	LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n",
 		 (unsigned int)OBD_CKSUM_CRC32);
 	LASSERTF(OBD_CKSUM_ADLER == 0x00000002UL, "found 0x%.8xUL\n",
diff --git a/include/uapi/linux/lustre/lustre_idl.h b/include/uapi/linux/lustre/lustre_idl.h
index f6f2761..fd880f3 100644
--- a/include/uapi/linux/lustre/lustre_idl.h
+++ b/include/uapi/linux/lustre/lustre_idl.h
@@ -818,6 +818,7 @@ struct ptlrpc_body_v2 {
 						  * discard
 						  */
 #define OBD_CONNECT2_ENCRYPT	       0x8000ULL /* client-to-disk encrypt */
+#define OBD_CONNECT2_FIDMAP	      0x10000ULL /* FID map */
 /* XXX README XXX:
  * Please DO NOT add flag values here before first ensuring that this same
  * flag value is not in use on some other branch.  Please clear any such
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 12/45] lustre: lov: lov_io_sub_init()) ASSERTION
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (10 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 11/45] lustre: uapi: add OBD_CONNECT2_FIDMAP James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 13/45] lnet: Introduce constant for the lolnd NID James Simmons
                   ` (33 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Bobi Jam <bobijam@whamcloud.com>

The assertion is_index_within_mirror() in lov_io_sub_init() should
only be applied for a FLR file, since a plain file does not initialize
the relevant FLR fields of the layout structure.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13429
Lustre-commit: 53274fbd4bcf4 ("LU-13429 lov: lov_io_sub_init()) ASSERTION")
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38169
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/lov/lov_io.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/lov/lov_io.c b/fs/lustre/lov/lov_io.c
index d69e3a4..fefbf39 100644
--- a/fs/lustre/lov/lov_io.c
+++ b/fs/lustre/lov/lov_io.c
@@ -113,7 +113,9 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
 		     !lov_r0(lov, index)->lo_sub[stripe]))
 		return -EIO;
 
-	LASSERTF(is_index_within_mirror(lov, index, lio->lis_mirror_index),
+	LASSERTF(ergo(lov_is_flr(lov),
+		      is_index_within_mirror(lov, index,
+					     lio->lis_mirror_index)),
 		 DFID "iot = %d, index = %d, mirror = %d\n",
 		 PFID(lu_object_fid(lov2lu(lov))), io->ci_type, index,
 		 lio->lis_mirror_index);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 13/45] lnet: Introduce constant for the lolnd NID
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (11 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 12/45] lustre: lov: lov_io_sub_init()) ASSERTION James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 14/45] lustre: Remove inappropriate uses of BIT() macro James Simmons
                   ` (32 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Chris Horn <hornc@cray.com>

This patch adds a new constant, LNET_NID_LO_0, to represent the lolnd
NID 0 at lo.

HPE-bug-id: LUS-8457
WC-bug-id: https://jira.whamcloud.com/browse/LU-12222
Lustre-commit: 56203e4ba0a6 ("LU-12222 lnet: Introduce constant for the lolnd NID")
Signed-off-by: Chris Horn <hornc@cray.com>
Reviewed-on: https://review.whamcloud.com/38312
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/llite_lib.c          | 2 +-
 fs/lustre/lmv/lmv_obd.c              | 4 ++--
 fs/lustre/ptlrpc/events.c            | 2 +-
 include/uapi/linux/lnet/lnet-types.h | 3 +++
 net/lnet/lnet/api-ni.c               | 6 +++---
 net/lnet/lnet/config.c               | 3 +--
 net/lnet/lnet/lib-move.c             | 6 +++---
 net/lnet/lnet/lib-msg.c              | 5 ++---
 net/lnet/lnet/peer.c                 | 6 +++---
 net/lnet/lnet/router.c               | 2 +-
 10 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c
index 84ec734..83b95ce 100644
--- a/fs/lustre/llite/llite_lib.c
+++ b/fs/lustre/llite/llite_lib.c
@@ -2817,7 +2817,7 @@ void ll_compute_rootsquash_state(struct ll_sb_info *sbi)
 		i = 0;
 
 		while (LNetGetId(i++, &id) != -ENOENT) {
-			if (LNET_NETTYP(LNET_NIDNET(id.nid)) == LOLND)
+			if (id.nid == LNET_NID_LO_0)
 				continue;
 			if (cfs_match_nid(id.nid, &squash->rsi_nosquash_nids)) {
 				matched = true;
diff --git a/fs/lustre/lmv/lmv_obd.c b/fs/lustre/lmv/lmv_obd.c
index 83e38bf..f241269 100644
--- a/fs/lustre/lmv/lmv_obd.c
+++ b/fs/lustre/lmv/lmv_obd.c
@@ -1114,7 +1114,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 	 * can distribute subdirs evenly from the beginning.
 	 */
 	while (LNetGetId(i++, &lnet_id) != -ENOENT) {
-		if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) {
+		if (lnet_id.nid != LNET_NID_LO_0) {
 			lmv->lmv_qos_rr_index = (u32)lnet_id.nid;
 			break;
 		}
@@ -1208,7 +1208,7 @@ static int lmv_select_statfs_mdt(struct lmv_obd *lmv, u32 flags)
 		if (LNetGetId(i, &lnet_id) == -ENOENT)
 			break;
 
-		if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) {
+		if (lnet_id.nid != LNET_NID_LO_0) {
 			/* We dont need a full 64-bit modulus, just enough
 			 * to distribute the requests across MDTs evenly.
 			 */
diff --git a/fs/lustre/ptlrpc/events.c b/fs/lustre/ptlrpc/events.c
index bc2af35..5e3787c 100644
--- a/fs/lustre/ptlrpc/events.c
+++ b/fs/lustre/ptlrpc/events.c
@@ -478,7 +478,7 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
 			continue;
 
 		if (dist == 0) {		/* local! use loopback LND */
-			peer->nid = *self = LNET_MKNID(LNET_MKNET(LOLND, 0), 0);
+			peer->nid = *self = LNET_NID_LO_0;
 			rc = 0;
 			break;
 		}
diff --git a/include/uapi/linux/lnet/lnet-types.h b/include/uapi/linux/lnet/lnet-types.h
index 1ef1e98..947ed7f 100644
--- a/include/uapi/linux/lnet/lnet-types.h
+++ b/include/uapi/linux/lnet/lnet-types.h
@@ -109,6 +109,9 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num)
 	return (type << 16) | num;
 }
 
+/** The lolnd NID (i.e. myself) */
+#define LNET_NID_LO_0 LNET_MKNID(LNET_MKNET(LOLND, 0), 0)
+
 /* Packed version of lnet_process_id to transfer via network */
 struct lnet_process_id_packed {
 	/* node id / process id */
diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c
index b3e1fe9..b0f2a62 100644
--- a/net/lnet/lnet/api-ni.c
+++ b/net/lnet/lnet/api-ni.c
@@ -1567,7 +1567,7 @@ struct lnet_ping_buffer *
 	/* Loopback is guaranteed to be present */
 	if (pinfo->pi_nnis < 1 || pinfo->pi_nnis > lnet_interfaces_max)
 		return -ERANGE;
-	if (LNET_NETTYP(LNET_NIDNET(LNET_PING_INFO_LONI(pinfo))) != LOLND)
+	if (LNET_PING_INFO_LONI(pinfo) != LNET_NID_LO_0)
 		return -EPROTO;
 	return 0;
 }
@@ -2732,7 +2732,7 @@ void lnet_lib_exit(void)
 	}
 
 	cfg_ni->lic_nid = ni->ni_nid;
-	if (LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND)
+	if (ni->ni_nid == LNET_NID_LO_0)
 		cfg_ni->lic_status = LNET_NI_STATUS_UP;
 	else
 		cfg_ni->lic_status = ni->ni_status->ns_status;
@@ -2824,7 +2824,7 @@ void lnet_lib_exit(void)
 	config->cfg_config_u.cfg_net.net_peer_rtr_credits =
 		ni->ni_net->net_tunables.lct_peer_rtr_credits;
 
-	if (LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND)
+	if (ni->ni_nid == LNET_NID_LO_0)
 		net_config->ni_status = LNET_NI_STATUS_UP;
 	else
 		net_config->ni_status = ni->ni_status->ns_status;
diff --git a/net/lnet/lnet/config.c b/net/lnet/lnet/config.c
index 9d3813c..d120dab 100644
--- a/net/lnet/lnet/config.c
+++ b/net/lnet/lnet/config.c
@@ -1179,8 +1179,7 @@ struct lnet_ni *
 					goto token_error;
 
 				nid = libcfs_str2nid(ltb->ltb_text);
-				if (nid == LNET_NID_ANY ||
-				    LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
+				if (nid == LNET_NID_ANY || nid == LNET_NID_LO_0)
 					goto token_error;
 			}
 		}
diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c
index 6ef9978..4eaaa5f 100644
--- a/net/lnet/lnet/lib-move.c
+++ b/net/lnet/lnet/lib-move.c
@@ -563,7 +563,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 	int rc;
 
 	LASSERT(!in_interrupt());
-	LASSERT(LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND ||
+	LASSERT(ni->ni_nid == LNET_NID_LO_0 ||
 		(msg->msg_txcredit && msg->msg_peertxcredit));
 
 	rc = ni->ni_net->net_lnd->lnd_send(ni, priv, msg);
@@ -2407,7 +2407,7 @@ struct lnet_ni *
 	 */
 	send_data.sd_msg = msg;
 	send_data.sd_cpt = cpt;
-	if (LNET_NETTYP(LNET_NIDNET(dst_nid)) == LOLND) {
+	if (dst_nid == LNET_NID_LO_0) {
 		rc = lnet_handle_lo_send(&send_data);
 		lnet_net_unlock(cpt);
 		return rc;
@@ -4793,7 +4793,7 @@ struct lnet_msg *
 			if (srcnidp)
 				*srcnidp = dstnid;
 			if (orderp) {
-				if (LNET_NETTYP(LNET_NIDNET(dstnid)) == LOLND)
+				if (dstnid == LNET_NID_LO_0)
 					*orderp = 0;
 				else
 					*orderp = 1;
diff --git a/net/lnet/lnet/lib-msg.c b/net/lnet/lnet/lib-msg.c
index dbb218d..7ce9c47 100644
--- a/net/lnet/lnet/lib-msg.c
+++ b/net/lnet/lnet/lib-msg.c
@@ -784,11 +784,10 @@
 	/* if we're sending to the LOLND then the msg_txpeer will not be
 	 * set. So no need to sanity check it.
 	 */
-	if (msg->msg_tx_committed &&
-	    LNET_NETTYP(LNET_NIDNET(msg->msg_txni->ni_nid)) != LOLND)
+	if (msg->msg_tx_committed && msg->msg_txni->ni_nid != LNET_NID_LO_0)
 		LASSERT(msg->msg_txpeer);
 	else if (msg->msg_tx_committed &&
-		 LNET_NETTYP(LNET_NIDNET(msg->msg_txni->ni_nid)) == LOLND)
+		 msg->msg_txni->ni_nid == LNET_NID_LO_0)
 		lo = true;
 
 	if (hstatus != LNET_MSG_STATUS_OK &&
diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c
index 1605c24..1b9190b 100644
--- a/net/lnet/lnet/peer.c
+++ b/net/lnet/lnet/peer.c
@@ -233,7 +233,7 @@
 	 * to ever use a different interface when sending messages to
 	 * myself.
 	 */
-	if (LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
+	if (nid == LNET_NID_LO_0)
 		lp->lp_state = LNET_PEER_NO_DISCOVERY;
 	lp->lp_cpt = lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
 
@@ -2615,7 +2615,7 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
 	 * present in curnis[] then this peer is for this node.
 	 */
 	for (i = 0; i < ncurnis; i++) {
-		if (LNET_NETTYP(LNET_NIDNET(curnis[i])) == LOLND)
+		if (curnis[i] == LNET_NID_LO_0)
 			continue;
 		for (j = 1; j < pbuf->pb_info.pi_nnis; j++) {
 			if (curnis[i] == pbuf->pb_info.pi_ni[j].ns_nid) {
@@ -2838,7 +2838,7 @@ static int lnet_peer_data_present(struct lnet_peer *lp)
 	if (pbuf->pb_info.pi_nnis <= 1)
 		goto out;
 	nid = pbuf->pb_info.pi_ni[1].ns_nid;
-	if (LNET_NETTYP(LNET_NIDNET(lp->lp_primary_nid)) == LOLND) {
+	if (lp->lp_primary_nid == LNET_NID_LO_0) {
 		rc = lnet_peer_set_primary_nid(lp, nid, flags);
 		if (!rc)
 			rc = lnet_peer_merge_data(lp, pbuf);
diff --git a/net/lnet/lnet/router.c b/net/lnet/lnet/router.c
index ff0a665..af50e51 100644
--- a/net/lnet/lnet/router.c
+++ b/net/lnet/lnet/router.c
@@ -661,7 +661,7 @@ static void lnet_shuffle_seed(void)
 	       libcfs_net2str(net), hops, priority, libcfs_nid2str(gateway));
 
 	if (gateway == LNET_NID_ANY ||
-	    LNET_NETTYP(LNET_NIDNET(gateway)) == LOLND ||
+	    gateway == LNET_NID_LO_0 ||
 	    net == LNET_NIDNET(LNET_NID_ANY) ||
 	    LNET_NETTYP(net) == LOLND ||
 	    LNET_NIDNET(gateway) == net ||
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 14/45] lustre: Remove inappropriate uses of BIT() macro.
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (12 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 13/45] lnet: Introduce constant for the lolnd NID James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 15/45] lustre: mgc: protect from NULL exp in mgc_enqueue() James Simmons
                   ` (31 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

The BIT() macro exists for identifying a specific bit in a word when
it is being used as a bitmap (or mask for set of flags etc).
While it uses "1 << ...." it is not a general replacement for that
construct and should not be used to simply to raise '2' to some power.

Varous places in lustre and libcfs use BIT() when a size, rather than
a BIT, are required.  Convert these to explicitly use "1 << exponent".

WC-bug-id: https://jira.whamcloud.com/browse/LU-6142
Lustre-commit: 423ad81446973 ("LU-6142 lustre: Remove inappropriate uses of BIT() macro.")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/38373
Reviewed-by: Olaf Faaland-LLNL <faaland1@llnl.gov>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/ldlm/ldlm_resource.c |  4 ++--
 fs/lustre/llite/lproc_llite.c  |  4 ++--
 fs/lustre/obdclass/class_obd.c | 12 +++++++-----
 net/lnet/libcfs/module.c       | 17 ++++++++---------
 4 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/fs/lustre/ldlm/ldlm_resource.c b/fs/lustre/ldlm/ldlm_resource.c
index 9b24be7..0a3d861 100644
--- a/fs/lustre/ldlm/ldlm_resource.c
+++ b/fs/lustre/ldlm/ldlm_resource.c
@@ -613,8 +613,8 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
 	ns->ns_bucket_bits = ldlm_ns_hash_defs[ns_type].nsd_all_bits -
 			     ldlm_ns_hash_defs[ns_type].nsd_bkt_bits;
 
-	ns->ns_rs_buckets = kvmalloc(BIT(ns->ns_bucket_bits) *
-				     sizeof(ns->ns_rs_buckets[0]),
+	ns->ns_rs_buckets = kvzalloc((1 << ns->ns_bucket_bits) *
+				     sizeof(*ns->ns_rs_buckets),
 				     GFP_KERNEL);
 	if (!ns->ns_rs_buckets)
 		goto out_hash;
diff --git a/fs/lustre/llite/lproc_llite.c b/fs/lustre/llite/lproc_llite.c
index 5b10ed0..36cc8bc 100644
--- a/fs/lustre/llite/lproc_llite.c
+++ b/fs/lustre/llite/lproc_llite.c
@@ -1780,7 +1780,7 @@ static void ll_display_extents_info(struct ll_rw_extents_info *io_extents,
 		w = pp_info->pp_w_hist.oh_buckets[i];
 		read_cum += r;
 		write_cum += w;
-		end = BIT(i + LL_HIST_START - units);
+		end = 1 << (i + LL_HIST_START - units);
 		seq_printf(seq,
 			   "%4lu%c - %4lu%c%c: %14lu %4u %4u  | %14lu %4u %4u\n",
 			   start, *unitp, end, *unitp,
@@ -1958,7 +1958,7 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
 		lprocfs_oh_clear(&io_extents->pp_extents[cur].pp_w_hist);
 	}
 
-	for (i = 0; (count >= BIT(LL_HIST_START + i)) &&
+	for (i = 0; (count >= 1 << (LL_HIST_START + i)) &&
 	     (i < (LL_HIST_MAX - 1)); i++)
 		;
 	if (rw == 0) {
diff --git a/fs/lustre/obdclass/class_obd.c b/fs/lustre/obdclass/class_obd.c
index 038ee62..76664bf 100644
--- a/fs/lustre/obdclass/class_obd.c
+++ b/fs/lustre/obdclass/class_obd.c
@@ -113,27 +113,29 @@ static int class_resolve_dev_name(u32 len, const char *name)
 
 static int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
 {
-	if (data->ioc_len > BIT(30)) {
+	const int maxlen = 1 << 30;
+
+	if (data->ioc_len > maxlen) {
 		CERROR("OBD ioctl: ioc_len larger than 1<<30\n");
 		return 1;
 	}
 
-	if (data->ioc_inllen1 > BIT(30)) {
+	if (data->ioc_inllen1 > maxlen) {
 		CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n");
 		return 1;
 	}
 
-	if (data->ioc_inllen2 > BIT(30)) {
+	if (data->ioc_inllen2 > maxlen) {
 		CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n");
 		return 1;
 	}
 
-	if (data->ioc_inllen3 > BIT(30)) {
+	if (data->ioc_inllen3 > maxlen) {
 		CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n");
 		return 1;
 	}
 
-	if (data->ioc_inllen4 > BIT(30)) {
+	if (data->ioc_inllen4 > maxlen) {
 		CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n");
 		return 1;
 	}
diff --git a/net/lnet/libcfs/module.c b/net/lnet/libcfs/module.c
index fc5bc25..ad6935c 100644
--- a/net/lnet/libcfs/module.c
+++ b/net/lnet/libcfs/module.c
@@ -80,18 +80,17 @@ static inline size_t libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
 
 static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
 {
-	if (data->ioc_hdr.ioc_len > BIT(30)) {
-		CERROR("LIBCFS ioctl: ioc_len larger than 1<<30\n");
+	const int maxlen = 1 << 30;
+
+	if (data->ioc_hdr.ioc_len > maxlen)
 		return true;
-	}
-	if (data->ioc_inllen1 > BIT(30)) {
-		CERROR("LIBCFS ioctl: ioc_inllen1 larger than 1<<30\n");
+
+	if (data->ioc_inllen1 > maxlen)
 		return true;
-	}
-	if (data->ioc_inllen2 > BIT(30)) {
-		CERROR("LIBCFS ioctl: ioc_inllen2 larger than 1<<30\n");
+
+	if (data->ioc_inllen2 > maxlen)
 		return true;
-	}
+
 	if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
 		CERROR("LIBCFS ioctl: inlbuf1 pointer but 0 length\n");
 		return true;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 15/45] lustre: mgc: protect from NULL exp in mgc_enqueue()
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (13 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 14/45] lustre: Remove inappropriate uses of BIT() macro James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 16/45] lustre: llite: do not flush COW pages from mapping James Simmons
                   ` (30 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Sebastien Buisson <sbuisson@ddn.com>

Return an error in mgc_enqueue() is exp parameter is NULL.
Otherwise, it might crash in class_exp2cliimp().

WC-bug-id: https://jira.whamcloud.com/browse/LU-13466
Lustre-commit: 83906f97c1d3b ("LU-13466 mgc: protect from NULL exp in mgc_enqueue()")
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-on: https://review.whamcloud.com/38280
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/mgc/mgc_request.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/lustre/mgc/mgc_request.c b/fs/lustre/mgc/mgc_request.c
index 81f3873..cc3c82e 100644
--- a/fs/lustre/mgc/mgc_request.c
+++ b/fs/lustre/mgc/mgc_request.c
@@ -875,6 +875,9 @@ static int mgc_enqueue(struct obd_export *exp, u32 type,
 	int short_limit = cld_is_sptlrpc(cld);
 	int rc;
 
+	if (!exp)
+		return -EBADR;
+
 	CDEBUG(D_MGC, "Enqueue for %s (res %#llx)\n", cld->cld_logname,
 	       cld->cld_resid.name[0]);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 16/45] lustre: llite: do not flush COW pages from mapping
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (14 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 15/45] lustre: mgc: protect from NULL exp in mgc_enqueue() James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 17/45] lustre: quota: quota pools for OSTs James Simmons
                   ` (29 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Bobi Jam <bobijam@whamcloud.com>

Do not flush COW pages from an executable mapping, as this will cause
running binaries to segfault when mapped pages disappear under them.

This was modified to allow non-blocking PCC caching, but triggers
immediate segfaults for binaries when the DLM locks are revoked, even
when PCC is not in use.

The added test case failed 100% without this patch.

This patch is only a partial fix to avoid the segfaults.  There still
needs to be something done to re-introduce the PCC functionality, but
should be conditional on PCC enabled, and not for running binaries.

There is a problem for PCC when multiple clients read/write on a
shared mmapped file. We exclude mmap_sanity tst6 in test_4 from
PCC testing temporarily.

Fixes: 38a1a6ad3f79 ("lustre: pcc: Non-blocking PCC caching")
WC-bug-id: https://jira.whamcloud.com/browse/LU-13137
Lustre-commit: 13a0066afb8d8 ("LU-13137 llite: do not flush COW pages from mapping")
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/37278
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Yingjin Qian <qian@ddn.com>
Reviewed-by: Stephan Thiell <sthiell@stanford.edu>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/llite_mmap.c | 2 +-
 fs/lustre/llite/vvp_object.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/lustre/llite/llite_mmap.c b/fs/lustre/llite/llite_mmap.c
index ee1bff1..f77b8f9 100644
--- a/fs/lustre/llite/llite_mmap.c
+++ b/fs/lustre/llite/llite_mmap.c
@@ -519,7 +519,7 @@ int ll_teardown_mmaps(struct address_space *mapping, u64 first, u64 last)
 	if (mapping_mapped(mapping)) {
 		rc = 0;
 		unmap_mapping_range(mapping, first + PAGE_SIZE - 1,
-				    last - first + 1, 1);
+				    last - first + 1, 0);
 	}
 
 	return rc;
diff --git a/fs/lustre/llite/vvp_object.c b/fs/lustre/llite/vvp_object.c
index 50a1a0b..0c40814 100644
--- a/fs/lustre/llite/vvp_object.c
+++ b/fs/lustre/llite/vvp_object.c
@@ -146,7 +146,7 @@ static int vvp_conf_set(const struct lu_env *env, struct cl_object *obj,
 		 * a price themselves.
 		 */
 		unmap_mapping_range(conf->coc_inode->i_mapping,
-				    0, OBD_OBJECT_EOF, 1);
+				    0, OBD_OBJECT_EOF, 0);
 		pcc_layout_invalidate(conf->coc_inode);
 	}
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 17/45] lustre: quota: quota pools for OSTs
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (15 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 16/45] lustre: llite: do not flush COW pages from mapping James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 18/45] lnet: libcfs: use BIT() macro where appropriate James Simmons
                   ` (28 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Sergey Cheremencev <c17829@cray.com>

Patch allows to apply quota settings
not only for the whole system, but also
for different OST pools. Since this patch
each "LOD" pool is duplicated by QMT.
Thus quota pools(QP) could be tuned by
standard lctl pool_new/add/remove/erase
commands. All QPs are subset of a global pool
that includes all data devices in a system,
including DOM. However DOM is not supported.
I don't see a lot of work to add DOM support
in future - just need to decide how MDTs
could be combined in a pool.

The main idea of QP is to find all pools
for requested ID(usr/grp/prj) and apply
minimum limit. The patch doesn't affect
qsd side, so slaves know nothing about
pools and different limits. Qunit and edquot
are calculated for each slave on master.

To apply quota on QP, the patch adds key "-o"
to lfs setquota. To get quotas for QP, it
provides long option "--pool" in lfs quota.
See examples of using in sanity-quota_1b/c/d.

Now QPs work properly only on a clean system.
Support of recalculation granted space in case
of adding/removing OSTs in a pool will be added
in the next patch together with accounting
already granted space by each ID in a POOl.

WC-bug-id: https://jira.whamcloud.com/browse/LU-11023
Lustre-commit: 09f9fb3211cd9 ("LU-11023 quota: quota pools for OSTs")
Signed-off-by: Sergey Cheremencev <c17829@cray.com>
Reviewed-on: https://review.whamcloud.com/35615
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/lu_object.h           | 11 +------
 fs/lustre/include/lustre_req_layout.h   |  1 +
 fs/lustre/include/lustre_swab.h         |  2 +-
 fs/lustre/include/obd_target.h          | 54 +++++++++++++++++++++++++++++++++
 fs/lustre/llite/dir.c                   | 30 +++++++++++++++---
 fs/lustre/mdc/mdc_request.c             | 40 ++++++++++++++++--------
 fs/lustre/ptlrpc/layout.c               |  6 ++--
 fs/lustre/ptlrpc/pack_generic.c         |  7 ++++-
 include/uapi/linux/lustre/lustre_idl.h  | 21 ++++++++-----
 include/uapi/linux/lustre/lustre_user.h | 11 +++++++
 10 files changed, 143 insertions(+), 40 deletions(-)
 create mode 100644 fs/lustre/include/obd_target.h

diff --git a/fs/lustre/include/lu_object.h b/fs/lustre/include/lu_object.h
index 57c2573..d0a59ff 100644
--- a/fs/lustre/include/lu_object.h
+++ b/fs/lustre/include/lu_object.h
@@ -38,6 +38,7 @@
 #include <linux/percpu_counter.h>
 #include <linux/libcfs/libcfs.h>
 #include <linux/ctype.h>
+#include <obd_target.h>
 #include <uapi/linux/lustre/lustre_idl.h>
 #include <lu_ref.h>
 
@@ -1399,16 +1400,6 @@ struct lu_kmem_descr {
 extern u32 lu_context_tags_default;
 extern u32 lu_session_tags_default;
 
-/* Generic subset of tgts */
-struct lu_tgt_pool {
-	u32		   *op_array;	/* array of index of
-					 * lov_obd->lov_tgts
-					 */
-	unsigned int	    op_count;	/* number of tgts in the array */
-	unsigned int	    op_size;	/* allocated size of op_array */
-	struct rw_semaphore op_rw_sem;	/* to protect lu_tgt_pool use */
-};
-
 /* round-robin QoS data for LOD/LMV */
 struct lu_qos_rr {
 	spinlock_t		 lqr_alloc;	/* protect allocation index */
diff --git a/fs/lustre/include/lustre_req_layout.h b/fs/lustre/include/lustre_req_layout.h
index f56dc8b..8efdf7f 100644
--- a/fs/lustre/include/lustre_req_layout.h
+++ b/fs/lustre/include/lustre_req_layout.h
@@ -266,6 +266,7 @@ void req_capsule_shrink(struct req_capsule *pill,
 extern struct req_msg_field RMF_CAPA2;
 extern struct req_msg_field RMF_OBD_QUOTACHECK;
 extern struct req_msg_field RMF_OBD_QUOTACTL;
+extern struct req_msg_field RMF_OBD_QUOTACTL_POOL;
 extern struct req_msg_field RMF_STRING;
 extern struct req_msg_field RMF_SWAP_LAYOUTS;
 extern struct req_msg_field RMF_MDS_HSM_PROGRESS;
diff --git a/fs/lustre/include/lustre_swab.h b/fs/lustre/include/lustre_swab.h
index a4db957..bac3636 100644
--- a/fs/lustre/include/lustre_swab.h
+++ b/fs/lustre/include/lustre_swab.h
@@ -60,7 +60,7 @@
 void lustre_swab_niobuf_remote(struct niobuf_remote *nbr);
 void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb);
 void lustre_swab_ost_lvb(struct ost_lvb *lvb);
-void lustre_swab_obd_quotactl(struct obd_quotactl *q);
+int lustre_swab_obd_quotactl(struct obd_quotactl *q, u32 len);
 void lustre_swab_lquota_lvb(struct lquota_lvb *lvb);
 void lustre_swab_generic_32s(u32 *val);
 void lustre_swab_mdt_body(struct mdt_body *b);
diff --git a/fs/lustre/include/obd_target.h b/fs/lustre/include/obd_target.h
new file mode 100644
index 0000000..466dd3c
--- /dev/null
+++ b/fs/lustre/include/obd_target.h
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0
+/* GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.gnu.org/licenses/gpl-2.0.html
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2014, Intel Corporation.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ */
+
+#ifndef __OBD_TARGET_H
+#define __OBD_TARGET_H
+#include <lprocfs_status.h>
+
+/* Generic subset of tgts */
+struct lu_tgt_pool {
+	__u32		   *op_array;	/* array of index of
+					 * lov_obd->lov_tgts
+					 */
+	unsigned int	    op_count;	/* number of tgts in the array */
+	unsigned int	    op_size;	/* allocated size of op_array */
+	struct rw_semaphore op_rw_sem;	/* to protect lu_tgt_pool use */
+};
+
+int tgt_pool_init(struct lu_tgt_pool *op, unsigned int count);
+int tgt_pool_add(struct lu_tgt_pool *op, __u32 idx, unsigned int min_count);
+int tgt_pool_remove(struct lu_tgt_pool *op, __u32 idx);
+int tgt_pool_free(struct lu_tgt_pool *op);
+int tgt_check_index(int idx, struct lu_tgt_pool *osts);
+int tgt_pool_extend(struct lu_tgt_pool *op, unsigned int min_count);
+
+#endif /* __OBD_TARGET_H */
diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c
index 47803a1..41e399b 100644
--- a/fs/lustre/llite/dir.c
+++ b/fs/lustre/llite/dir.c
@@ -1083,15 +1083,19 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
 	case Q_SETQUOTA:
 	case Q_SETINFO:
 	case LUSTRE_Q_SETDEFAULT:
+	case LUSTRE_Q_SETQUOTAPOOL:
+	case LUSTRE_Q_SETINFOPOOL:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 		break;
 	case Q_GETQUOTA:
 	case LUSTRE_Q_GETDEFAULT:
+	case LUSTRE_Q_GETQUOTAPOOL:
 		if (check_owner(type, id) && !capable(CAP_SYS_ADMIN))
 			return -EPERM;
 		break;
 	case Q_GETINFO:
+	case LUSTRE_Q_GETINFOPOOL:
 		break;
 	default:
 		CERROR("unsupported quotactl op: %#x\n", cmd);
@@ -1101,7 +1105,8 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
 	if (valid != QC_GENERAL) {
 		if (cmd == Q_GETINFO)
 			qctl->qc_cmd = Q_GETOINFO;
-		else if (cmd == Q_GETQUOTA)
+		else if (cmd == Q_GETQUOTA ||
+			 cmd == LUSTRE_Q_GETQUOTAPOOL)
 			qctl->qc_cmd = Q_GETOQUOTA;
 		else
 			return -EINVAL;
@@ -1134,8 +1139,12 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
 		qctl->qc_cmd = cmd;
 	} else {
 		struct obd_quotactl *oqctl;
+		int oqctl_len = sizeof(*oqctl);
 
-		oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
+		if (LUSTRE_Q_CMD_IS_POOL(cmd))
+			oqctl_len += LOV_MAXPOOLNAME + 1;
+
+		oqctl = kzalloc(oqctl_len, GFP_NOFS);
 		if (!oqctl)
 			return -ENOMEM;
 
@@ -1148,7 +1157,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
 		/* If QIF_SPACE is not set, client should collect the
 		 * space usage from OSSs by itself
 		 */
-		if (cmd == Q_GETQUOTA &&
+		if ((cmd == Q_GETQUOTA || cmd == LUSTRE_Q_GETQUOTAPOOL) &&
 		    !(oqctl->qc_dqblk.dqb_valid & QIF_SPACE) &&
 		    !oqctl->qc_dqblk.dqb_curspace) {
 			struct obd_quotactl *oqctl_tmp;
@@ -1807,8 +1816,9 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	}
 	case OBD_IOC_QUOTACTL: {
 		struct if_quotactl *qctl;
+		int qctl_len = sizeof(*qctl) + LOV_MAXPOOLNAME + 1;
 
-		qctl = kzalloc(sizeof(*qctl), GFP_NOFS);
+		qctl = kzalloc(qctl_len, GFP_NOFS);
 		if (!qctl)
 			return -ENOMEM;
 
@@ -1817,8 +1827,18 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 			goto out_quotactl;
 		}
 
-		rc = quotactl_ioctl(sbi, qctl);
+		if (LUSTRE_Q_CMD_IS_POOL(qctl->qc_cmd)) {
+			char __user *from = (char __user *)arg +
+					    offsetof(typeof(*qctl), qc_poolname);
 
+			if (copy_from_user(qctl->qc_poolname, from,
+					   LOV_MAXPOOLNAME + 1)) {
+				rc = -EFAULT;
+				goto out_quotactl;
+			}
+		}
+
+		rc = quotactl_ioctl(sbi, qctl);
 		if (rc == 0 && copy_to_user((void __user *)arg, qctl,
 					    sizeof(*qctl)))
 			rc = -EFAULT;
diff --git a/fs/lustre/mdc/mdc_request.c b/fs/lustre/mdc/mdc_request.c
index c71b642..0cbab8b 100644
--- a/fs/lustre/mdc/mdc_request.c
+++ b/fs/lustre/mdc/mdc_request.c
@@ -2073,34 +2073,50 @@ static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp,
 	struct obd_quotactl *oqc;
 	int rc;
 
-	req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
-					&RQF_MDS_QUOTACTL, LUSTRE_MDS_VERSION,
-					MDS_QUOTACTL);
+	req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_QUOTACTL);
 	if (!req)
 		return -ENOMEM;
 
+	if (LUSTRE_Q_CMD_IS_POOL(oqctl->qc_cmd))
+		req_capsule_set_size(&req->rq_pill,
+				     &RMF_OBD_QUOTACTL,
+				     RCL_CLIENT,
+				     sizeof(*oqc) + LOV_MAXPOOLNAME + 1);
+
+	rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION,
+				 MDS_QUOTACTL);
+	if (rc) {
+		ptlrpc_request_free(req);
+		return rc;
+	}
+
 	oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
-	*oqc = *oqctl;
+	QCTL_COPY(oqc, oqctl);
 
 	ptlrpc_request_set_replen(req);
 	ptlrpc_at_set_req_timeout(req);
 
 	rc = ptlrpc_queue_wait(req);
-	if (rc)
-		CERROR("ptlrpc_queue_wait failed, rc: %d\n", rc);
+	if (rc) {
+		CERROR("%s: ptlrpc_queue_wait failed: rc = %d\n",
+		       exp->exp_obd->obd_name, rc);
+		goto out;
+	}
 
 	if (req->rq_repmsg) {
 		oqc = req_capsule_server_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
 		if (oqc) {
-			*oqctl = *oqc;
-		} else if (!rc) {
-			CERROR("Can't unpack obd_quotactl\n");
-			rc = -EPROTO;
+			QCTL_COPY(oqctl, oqc);
+			goto out;
 		}
-	} else if (!rc) {
-		CERROR("Can't unpack obd_quotactl\n");
+	}
+
+	if (!rc) {
 		rc = -EPROTO;
+		CERROR("%s: cannot unpack obd_quotactl: rc = %d\n",
+		       exp->exp_obd->obd_name, rc);
 	}
+out:
 	ptlrpc_req_finished(req);
 
 	return rc;
diff --git a/fs/lustre/ptlrpc/layout.c b/fs/lustre/ptlrpc/layout.c
index fd8676d..832c896 100644
--- a/fs/lustre/ptlrpc/layout.c
+++ b/fs/lustre/ptlrpc/layout.c
@@ -923,9 +923,9 @@ struct req_msg_field RMF_MDT_BODY =
 EXPORT_SYMBOL(RMF_MDT_BODY);
 
 struct req_msg_field RMF_OBD_QUOTACTL =
-	DEFINE_MSGF("obd_quotactl", 0,
-		    sizeof(struct obd_quotactl),
-		    lustre_swab_obd_quotactl, NULL);
+	DEFINE_MSGFL("obd_quotactl", 0,
+		     sizeof(struct obd_quotactl),
+		     lustre_swab_obd_quotactl, NULL);
 EXPORT_SYMBOL(RMF_OBD_QUOTACTL);
 
 struct req_msg_field RMF_MDT_EPOCH =
diff --git a/fs/lustre/ptlrpc/pack_generic.c b/fs/lustre/ptlrpc/pack_generic.c
index ec853d1..82e6c46 100644
--- a/fs/lustre/ptlrpc/pack_generic.c
+++ b/fs/lustre/ptlrpc/pack_generic.c
@@ -1893,14 +1893,19 @@ static void lustre_swab_obd_dqblk(struct obd_dqblk *b)
 	BUILD_BUG_ON(offsetof(typeof(*b), dqb_padding) == 0);
 }
 
-void lustre_swab_obd_quotactl(struct obd_quotactl *q)
+int lustre_swab_obd_quotactl(struct obd_quotactl *q, u32 len)
 {
+	if (unlikely(len <= sizeof(struct obd_quotactl)))
+		return -EOVERFLOW;
+
 	__swab32s(&q->qc_cmd);
 	__swab32s(&q->qc_type);
 	__swab32s(&q->qc_id);
 	__swab32s(&q->qc_stat);
 	lustre_swab_obd_dqinfo(&q->qc_dqinfo);
 	lustre_swab_obd_dqblk(&q->qc_dqblk);
+
+	return len;
 }
 
 void lustre_swab_fid2path(struct getinfo_fid2path *gf)
diff --git a/include/uapi/linux/lustre/lustre_idl.h b/include/uapi/linux/lustre/lustre_idl.h
index fd880f3..743af77 100644
--- a/include/uapi/linux/lustre/lustre_idl.h
+++ b/include/uapi/linux/lustre/lustre_idl.h
@@ -1363,18 +1363,23 @@ struct obd_quotactl {
 	__u32			qc_stat;
 	struct obd_dqinfo	qc_dqinfo;
 	struct obd_dqblk	qc_dqblk;
+	char			qc_poolname[0];
 };
 
 #define Q_COPY(out, in, member) (out)->member = (in)->member
 
-#define QCTL_COPY(out, in)		\
-do {					\
-	Q_COPY(out, in, qc_cmd);	\
-	Q_COPY(out, in, qc_type);	\
-	Q_COPY(out, in, qc_id);		\
-	Q_COPY(out, in, qc_stat);	\
-	Q_COPY(out, in, qc_dqinfo);	\
-	Q_COPY(out, in, qc_dqblk);	\
+#define QCTL_COPY(out, in)			\
+do {						\
+	Q_COPY(out, in, qc_cmd);		\
+	Q_COPY(out, in, qc_type);		\
+	Q_COPY(out, in, qc_id);			\
+	Q_COPY(out, in, qc_stat);		\
+	Q_COPY(out, in, qc_dqinfo);		\
+	Q_COPY(out, in, qc_dqblk);		\
+	if (LUSTRE_Q_CMD_IS_POOL(in->qc_cmd))	\
+		memcpy(out->qc_poolname,	\
+		       in->qc_poolname,		\
+		       LOV_MAXPOOLNAME + 1);	\
 } while (0)
 
 /* Data structures associated with the quota locks */
diff --git a/include/uapi/linux/lustre/lustre_user.h b/include/uapi/linux/lustre/lustre_user.h
index 9196357..6644b99 100644
--- a/include/uapi/linux/lustre/lustre_user.h
+++ b/include/uapi/linux/lustre/lustre_user.h
@@ -890,6 +890,10 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen)
 #define LUSTRE_Q_FINVALIDATE	0x80000c	/* deprecated as of 2.4 */
 #define LUSTRE_Q_GETDEFAULT	0x80000d	/* get default quota */
 #define LUSTRE_Q_SETDEFAULT	0x80000e	/* set default quota */
+#define LUSTRE_Q_GETQUOTAPOOL	0x80000f	/* get user pool quota */
+#define LUSTRE_Q_SETQUOTAPOOL	0x800010	/* set user pool quota */
+#define LUSTRE_Q_GETINFOPOOL	0x800011	/* get pool quota info */
+#define LUSTRE_Q_SETINFOPOOL	0x800012	/* set pool quota info */
 
 /* In the current Lustre implementation, the grace time is either the time
  * or the timestamp to be used after some quota ID exceeds the soft limt,
@@ -911,6 +915,12 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen)
  */
 #define LQUOTA_FLAG_DEFAULT	0x0001
 
+#define LUSTRE_Q_CMD_IS_POOL(cmd)		\
+	(cmd == LUSTRE_Q_GETQUOTAPOOL ||	\
+	 cmd == LUSTRE_Q_SETQUOTAPOOL ||	\
+	 cmd == LUSTRE_Q_SETINFOPOOL ||		\
+	 cmd == LUSTRE_Q_GETINFOPOOL)
+
 #define ALLQUOTA 255	/* set all quota */
 
 static inline const char *qtype_name(int qtype)
@@ -1009,6 +1019,7 @@ struct if_quotactl {
 	struct obd_dqblk  qc_dqblk;
 	char		  obd_type[16];
 	struct obd_uuid	  obd_uuid;
+	char		  qc_poolname[0];
 };
 
 /* swap layout flags */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 18/45] lnet: libcfs: use BIT() macro where appropriate
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (16 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 17/45] lustre: quota: quota pools for OSTs James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 19/45] lustre: llite: clean up pcc_layout_wait() James Simmons
                   ` (27 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

When accessing a bit in a bitmap/mask/flags-word it can be more
readable to use BIT(num) rather than "1 << num".

This patch makes that change to various places in libcfs.

WC-bug-id: https://jira.whamcloud.com/browse/LU-6142
Lustre-commit: 5bb99e46bc904 ("LU-6142 libcfs: use BIT() macro where appropriate")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/38374
Reviewed-by: Olaf Faaland-LLNL <faaland1@llnl.gov>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/libcfs/debug.c         | 2 +-
 net/lnet/libcfs/libcfs_string.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/lnet/libcfs/debug.c b/net/lnet/libcfs/debug.c
index c0ec184..41a0a5e 100644
--- a/net/lnet/libcfs/debug.c
+++ b/net/lnet/libcfs/debug.c
@@ -273,7 +273,7 @@ static const char *libcfs_debug_dbg2str(int debug)
 		len = 1;
 	} else {				/* space-separated tokens */
 		for (i = 0; i < 32; i++) {
-			if (!(mask & (1 << i)))
+			if ((mask & BIT(i)) == 0)
 				continue;
 
 			token = fn(i);
diff --git a/net/lnet/libcfs/libcfs_string.c b/net/lnet/libcfs/libcfs_string.c
index cefe6fee..b042de5 100644
--- a/net/lnet/libcfs/libcfs_string.c
+++ b/net/lnet/libcfs/libcfs_string.c
@@ -88,9 +88,9 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
 			if (debugstr && strlen(debugstr) == len &&
 			    !strncasecmp(str, debugstr, len)) {
 				if (op == '-')
-					newmask &= ~(1 << i);
+					newmask &= ~BIT(i);
 				else
-					newmask |= (1 << i);
+					newmask |= BIT(i);
 				found = 1;
 				break;
 			}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 19/45] lustre: llite: clean up pcc_layout_wait()
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (17 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 18/45] lnet: libcfs: use BIT() macro where appropriate James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 20/45] lustre: misc: declare static chars as const where possible James Simmons
                   ` (26 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

pcc_layout_wait() contains a pointless while loop (and an unnecessary
blank line) and is a trivial function that is only called once.

So move the code into __pcc_layout_invalidate(), remove the while
loop, and generally tidy up.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10467
Lustre-commit: c5a311781fc60 ("LU-10467 llite: clean up pcc_layout_wait()")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/38403
Reviewed-by: Yingjin Qian <qian@ddn.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/pcc.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/fs/lustre/llite/pcc.c b/fs/lustre/llite/pcc.c
index e0628b9..391733e 100644
--- a/fs/lustre/llite/pcc.c
+++ b/fs/lustre/llite/pcc.c
@@ -1968,20 +1968,17 @@ int pcc_fault(struct vm_area_struct *vma, struct vm_fault *vmf,
 	return rc;
 }
 
-static void pcc_layout_wait(struct pcc_inode *pcci)
-{
-	if (atomic_read(&pcci->pcci_active_ios) > 0)
-		CDEBUG(D_CACHE, "Waiting for IO completion: %d\n",
-		       atomic_read(&pcci->pcci_active_ios));
-	wait_event_idle(pcci->pcci_waitq,
-			atomic_read(&pcci->pcci_active_ios) == 0);
-}
-
 static void __pcc_layout_invalidate(struct pcc_inode *pcci)
 {
 	pcci->pcci_type = LU_PCC_NONE;
 	pcc_layout_gen_set(pcci, CL_LAYOUT_GEN_NONE);
-	pcc_layout_wait(pcci);
+	if (atomic_read(&pcci->pcci_active_ios) == 0)
+		return;
+
+	CDEBUG(D_CACHE, "Waiting for IO completion: %d\n",
+	       atomic_read(&pcci->pcci_active_ios));
+	wait_event_idle(pcci->pcci_waitq,
+			atomic_read(&pcci->pcci_active_ios) == 0);
 }
 
 void pcc_layout_invalidate(struct inode *inode)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 20/45] lustre: misc: declare static chars as const where possible.
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (18 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 19/45] lustre: llite: clean up pcc_layout_wait() James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 21/45] lustre: llite: fix to make jobstats work for async ra James Simmons
                   ` (25 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

When a char * is statically initialized to a literal string, it is
best if the char is declared 'const' to ensure that literal string can
never be changed, and to allow it to be stored in read-only memory.

Unfortunately this is not possible for strings used as module
parameters.  Similarly osd_0copy_tag in osd-zfs cannot be made const,
so that is change to a simple array (no pointer).

But in many other places it is possible, and it requires all ultimate
users of the string to declare that they are working with const chars.

This patch changes a collection of static char*s to const, and in many
cases arrays of char * to "const char * const", and then propagates
the 'const' annotion as needed.

WC-bug-id: https://jira.whamcloud.com/browse/LU-6142
Lustre-commit: 257c0debc71ed ("LU-6142 misc: declare static chars as const where possible.")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/38421
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/lustre_import.h   |  4 ++--
 fs/lustre/obdclass/lprocfs_status.c |  2 +-
 include/linux/lnet/lib-lnet.h       |  6 +++---
 net/lnet/lnet/api-ni.c              | 10 +++++-----
 net/lnet/lnet/config.c              | 13 +++++++------
 5 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/fs/lustre/include/lustre_import.h b/fs/lustre/include/lustre_import.h
index 8db51e8..4e9a228 100644
--- a/fs/lustre/include/lustre_import.h
+++ b/fs/lustre/include/lustre_import.h
@@ -112,9 +112,9 @@ enum lustre_imp_state {
 };
 
 /** Returns test string representation of numeric import state @state */
-static inline char *ptlrpc_import_state_name(enum lustre_imp_state state)
+static inline const char *ptlrpc_import_state_name(enum lustre_imp_state state)
 {
-	static char *import_state_names[] = {
+	static const char * const import_state_names[] = {
 		"<UNKNOWN>", "CLOSED",  "NEW", "DISCONN",
 		"CONNECTING", "REPLAY", "REPLAY_LOCKS", "REPLAY_WAIT",
 		"RECOVER", "FULL", "EVICTED", "IDLE",
diff --git a/fs/lustre/obdclass/lprocfs_status.c b/fs/lustre/obdclass/lprocfs_status.c
index 5f94669..aba04d5 100644
--- a/fs/lustre/obdclass/lprocfs_status.c
+++ b/fs/lustre/obdclass/lprocfs_status.c
@@ -597,7 +597,7 @@ int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
 {
 	struct obd_device *obd = data;
 	struct obd_import *imp;
-	char *imp_state_name = NULL;
+	const char *imp_state_name = NULL;
 	int rc;
 
 	LASSERT(obd);
diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h
index 03ac3f9..01e8489 100644
--- a/include/linux/lnet/lib-lnet.h
+++ b/include/linux/lnet/lib-lnet.h
@@ -718,9 +718,9 @@ int lnet_push_target_post(struct lnet_ping_buffer *pbuf,
 			  struct lnet_handle_md *mdh);
 void lnet_peer_push_event(struct lnet_event *ev);
 
-int lnet_parse_ip2nets(char **networksp, char *ip2nets);
-int lnet_parse_routes(char *route_str, int *im_a_router);
-int lnet_parse_networks(struct list_head *nilist, char *networks,
+int lnet_parse_ip2nets(const char **networksp, const char *ip2nets);
+int lnet_parse_routes(const char *route_str, int *im_a_router);
+int lnet_parse_networks(struct list_head *nilist, const char *networks,
 			bool use_tcp_bonding);
 bool lnet_net_unique(u32 net_id, struct list_head *nilist,
 		     struct lnet_net **net);
diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c
index b0f2a62..e2c364b 100644
--- a/net/lnet/lnet/api-ni.c
+++ b/net/lnet/lnet/api-ni.c
@@ -472,16 +472,16 @@ static int lnet_discover(struct lnet_process_id id, u32 force,
 	return 0;
 }
 
-static char *
+static const char *
 lnet_get_routes(void)
 {
 	return routes;
 }
 
-static char *
+static const char *
 lnet_get_networks(void)
 {
-	char *nets;
+	const char *nets;
 	int rc;
 
 	if (*networks && *ip2nets) {
@@ -3101,7 +3101,7 @@ static int lnet_handle_legacy_ip2nets(char *ip2nets,
 				      struct lnet_ioctl_config_lnd_tunables *tun)
 {
 	struct lnet_net *net;
-	char *nets;
+	const char *nets;
 	int rc;
 	LIST_HEAD(net_head);
 
@@ -3286,7 +3286,7 @@ int lnet_dyn_del_ni(struct lnet_ioctl_config_ni *conf)
 	LIST_HEAD(net_head);
 	int rc;
 	struct lnet_ioctl_config_lnd_tunables tun;
-	char *nets = conf->cfg_config_u.cfg_net.net_intf;
+	const char *nets = conf->cfg_config_u.cfg_net.net_intf;
 
 	/* Create a net/ni structures for the network string */
 	rc = lnet_parse_networks(&net_head, nets, use_tcp_bonding);
diff --git a/net/lnet/lnet/config.c b/net/lnet/lnet/config.c
index d120dab..3fc0298 100644
--- a/net/lnet/lnet/config.c
+++ b/net/lnet/lnet/config.c
@@ -568,7 +568,7 @@ struct lnet_ni *
  * nilist.
  */
 int
-lnet_parse_networks(struct list_head *netlist, char *networks,
+lnet_parse_networks(struct list_head *netlist, const char *networks,
 		    bool use_tcp_bonding)
 {
 	struct cfs_expr_list *net_el = NULL;
@@ -887,10 +887,10 @@ struct lnet_ni *
 }
 
 static int
-lnet_str2tbs_sep(struct list_head *tbs, char *str)
+lnet_str2tbs_sep(struct list_head *tbs, const char *str)
 {
 	LIST_HEAD(pending);
-	char *sep;
+	const char *sep;
 	int nob;
 	int i;
 	struct lnet_text_buf *ltb;
@@ -1250,7 +1250,7 @@ struct lnet_ni *
 }
 
 int
-lnet_parse_routes(char *routes, int *im_a_router)
+lnet_parse_routes(const char *routes, int *im_a_router)
 {
 	LIST_HEAD(tbs);
 	int rc = 0;
@@ -1439,7 +1439,8 @@ struct lnet_ni *
 }
 
 static int
-lnet_match_networks(char **networksp, char *ip2nets, u32 *ipaddrs, int nip)
+lnet_match_networks(const char **networksp, const char *ip2nets,
+		    u32 *ipaddrs, int nip)
 {
 	static char networks[LNET_SINGLE_TEXTBUF_NOB];
 	static char source[LNET_SINGLE_TEXTBUF_NOB];
@@ -1620,7 +1621,7 @@ int lnet_inet_enumerate(struct lnet_inetdev **dev_list, struct net *ns)
 EXPORT_SYMBOL(lnet_inet_enumerate);
 
 int
-lnet_parse_ip2nets(char **networksp, char *ip2nets)
+lnet_parse_ip2nets(const char **networksp, const char *ip2nets)
 {
 	struct lnet_inetdev *ifaces = NULL;
 	u32 *ipaddrs = NULL;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 21/45] lustre: llite: fix to make jobstats work for async ra
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (19 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 20/45] lustre: misc: declare static chars as const where possible James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:07 ` [lustre-devel] [PATCH 22/45] lustre: llite: verify truncated xattr is handled James Simmons
                   ` (24 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Wang Shilong <wshilong@ddn.com>

We use workqueue to triger async readahead, this will make
the problem that read jobstats are not accounted by real
IO, we could fix this by overwritting jobid which inited in
vvp_io_init().

WC-bug-id: https://jira.whamcloud.com/browse/LU-13490
Lustre-commit: da8972322134a ("LU-13490 lustre: fix to make jobstats work for async ra")
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/38426
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Ben Evans <beevans@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/llite_internal.h | 1 +
 fs/lustre/llite/rw.c             | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h
index c3f60bb..76715818 100644
--- a/fs/lustre/llite/llite_internal.h
+++ b/fs/lustre/llite/llite_internal.h
@@ -780,6 +780,7 @@ struct ll_readahead_work {
 
 	/* async worker to handler read */
 	struct work_struct		 lrw_readahead_work;
+	char				 lrw_jobid[LUSTRE_JOBID_SIZE];
 };
 
 extern struct kmem_cache *ll_file_data_slab;
diff --git a/fs/lustre/llite/rw.c b/fs/lustre/llite/rw.c
index 7018c7c..9e004f4 100644
--- a/fs/lustre/llite/rw.c
+++ b/fs/lustre/llite/rw.c
@@ -629,6 +629,12 @@ static void ll_readahead_handle_work(struct work_struct *wq)
 	if (rc)
 		goto out_put_env;
 
+	/* overwrite jobid inited in vvp_io_init() */
+	if (strncmp(ll_i2info(inode)->lli_jobid, work->lrw_jobid,
+		    sizeof(work->lrw_jobid)))
+		memcpy(ll_i2info(inode)->lli_jobid, work->lrw_jobid,
+		       sizeof(work->lrw_jobid));
+
 	vvp_env_io(env)->vui_fd = fd;
 	io->ci_state = CIS_LOCKED;
 	io->ci_async_readahead = true;
@@ -1582,6 +1588,8 @@ static int kickoff_async_readahead(struct file *file, unsigned long pages)
 		ras->ras_next_readahead_idx = end_idx + 1;
 		ras->ras_async_last_readpage_idx = start_idx;
 		spin_unlock(&ras->ras_lock);
+		memcpy(lrw->lrw_jobid, ll_i2info(inode)->lli_jobid,
+		       sizeof(lrw->lrw_jobid));
 		ll_readahead_work_add(inode, lrw);
 	} else {
 		return -ENOMEM;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 22/45] lustre: llite: verify truncated xattr is handled
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (20 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 21/45] lustre: llite: fix to make jobstats work for async ra James Simmons
@ 2020-05-25 22:07 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 23/45] lustre: obd: fix printing of client connection UUID James Simmons
                   ` (23 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:07 UTC (permalink / raw)
  To: lustre-devel

From: Andreas Dilger <adilger@whamcloud.com>

Verify that a truncated trusted.lov xattr is handled properly,
for both plain and PFL layouts.

Add a test case that verifies this is fixed for both layout types.

Fixes: 814b53f76d ("lustre: llite: Don't access lov_md fields before size check")
WC-bug-id: https://jira.whamcloud.com/browse/LU-13168
Lustre-commit: cb74546354201 ("LU-13168 tests: verify truncated xattr is handled")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38434
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Emoly Liu <emoly@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/xattr.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/lustre/llite/xattr.c b/fs/lustre/llite/xattr.c
index 9e7ba21..119fb26 100644
--- a/fs/lustre/llite/xattr.c
+++ b/fs/lustre/llite/xattr.c
@@ -190,7 +190,8 @@ static int get_hsm_state(struct inode *inode, u32 *hus_states)
 	return rc;
 }
 
-static int ll_adjust_lum(struct inode *inode, struct lov_user_md *lump)
+static int ll_adjust_lum(struct inode *inode, struct lov_user_md *lump,
+			 size_t size)
 {
 	struct lov_comp_md_v1 *comp_v1 = (struct lov_comp_md_v1 *)lump;
 	struct lov_user_md *v1 = lump;
@@ -205,7 +206,12 @@ static int ll_adjust_lum(struct inode *inode, struct lov_user_md *lump)
 		return 0;
 
 	if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
+		if (size < sizeof(*comp_v1))
+			return -ERANGE;
+
 		entry_count = comp_v1->lcm_entry_count;
+		if (size < offsetof(typeof(*comp_v1), lcm_entries[entry_count]))
+			return -ERANGE;
 		is_composite = true;
 	}
 
@@ -213,6 +219,10 @@ static int ll_adjust_lum(struct inode *inode, struct lov_user_md *lump)
 		if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
 			void *ptr = comp_v1;
 
+			if (comp_v1->lcm_entries[i].lcme_offset + sizeof(*v1) >
+			    size)
+				return -ERANGE;
+
 			ptr += comp_v1->lcm_entries[i].lcme_offset;
 			v1 = (struct lov_user_md *)ptr;
 		}
@@ -265,7 +275,7 @@ static int ll_setstripe_ea(struct dentry *dentry, struct lov_user_md *lump,
 		return -ERANGE;
 	}
 
-	rc = ll_adjust_lum(inode, lump);
+	rc = ll_adjust_lum(inode, lump, size);
 	if (rc)
 		return rc;
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 23/45] lustre: obd: fix printing of client connection UUID
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (21 preceding siblings ...)
  2020-05-25 22:07 ` [lustre-devel] [PATCH 22/45] lustre: llite: verify truncated xattr is handled James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 24/45] lnet: Add MD options for response tracking James Simmons
                   ` (22 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Andreas Dilger <adilger@whamcloud.com>

The client connection UUID sent to the servers (ASCII format) was
being truncated to only 16 bytes in size, like '595f3c6a-20ae-4'
instead of a full UUID like '18ae0f9a-4b09-4599-8ced-0f2126eab425'.

This was caused by using UUID_SIZE to limit the size of the "%pU"
string printed to avoid overflowing the target buffer, but in fact
UUID_SIZE is the size of the binary uuid_t (16 bytes) instead of
the size of struct obd_uuid (40 bytes) where the ASCII version of
the UUID is stored.

Fix this to use sizeof(target) rather than an external constant,
which is exactly why sizeof(target) should always be used.  The
usage in osd_scrub.c is not actually broken, but it is still
better to use sizeof(target) to avoid future inconsistencies.

Fixes: e991811757a4f ("lustre: obd: replace class_uuid with linux kernel version")
WC-bug-id: https://jira.whamcloud.com/browse/LU-13499
Lustre-commit: 9abdf96e56e23 ("LU-13499 obd: fix printing of client connection UUID")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38443
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Arshad Hussain <arshad.super@gmail.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/llite_lib.c    | 2 +-
 fs/lustre/obdclass/obd_mount.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c
index 83b95ce..da7604f 100644
--- a/fs/lustre/llite/llite_lib.c
+++ b/fs/lustre/llite/llite_lib.c
@@ -1046,7 +1046,7 @@ int ll_fill_super(struct super_block *sb)
 
 	/* UUID handling */
 	generate_random_uuid(uuid.b);
-	snprintf(sbi->ll_sb_uuid.uuid, UUID_SIZE, "%pU", uuid.b);
+	snprintf(sbi->ll_sb_uuid.uuid, sizeof(sbi->ll_sb_uuid), "%pU", uuid.b);
 
 	CDEBUG(D_CONFIG, "llite sb uuid: %s\n", sbi->ll_sb_uuid.uuid);
 
diff --git a/fs/lustre/obdclass/obd_mount.c b/fs/lustre/obdclass/obd_mount.c
index 84ce93b..13e6521 100644
--- a/fs/lustre/obdclass/obd_mount.c
+++ b/fs/lustre/obdclass/obd_mount.c
@@ -339,7 +339,7 @@ int lustre_start_mgc(struct super_block *sb)
 	}
 
 	generate_random_uuid(uuidc.b);
-	snprintf(uuid->uuid, UUID_SIZE, "%pU", uuidc.b);
+	snprintf(uuid->uuid, sizeof(*uuid), "%pU", uuidc.b);
 
 	/* Start the MGC */
 	rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME,
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 24/45] lnet: Add MD options for response tracking
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (22 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 23/45] lustre: obd: fix printing of client connection UUID James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 25/45] lustre: Send file creation time to clients James Simmons
                   ` (21 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Chris Horn <hornc@cray.com>

These MD options will allow response tracking on a particular MD to
override the behavior specified by the lnet_response_tracking
parameter.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13502
Lustre-commit: 448834b8e575f ("LU-13502 lnet: Add MD options for response tracking")
Signed-off-by: Chris Horn <hornc@cray.com>
Reviewed-on: https://review.whamcloud.com/38450
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 include/uapi/linux/lnet/lnet-types.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/uapi/linux/lnet/lnet-types.h b/include/uapi/linux/lnet/lnet-types.h
index 947ed7f..70fab42 100644
--- a/include/uapi/linux/lnet/lnet-types.h
+++ b/include/uapi/linux/lnet/lnet-types.h
@@ -483,6 +483,10 @@ struct lnet_md {
 	 *   struct bio_vec.
 	 * - LNET_MD_MAX_SIZE: The max_size field is valid.
 	 * - LNET_MD_BULK_HANDLE: The bulk_handle field is valid.
+	 * - LNET_MD_TRACK_RESPONSE: Enable response tracking on this MD
+	 *   regardless of the value of the lnet_response_tracking param.
+	 * - LNET_MD_NO_TRACK_RESPONSE: Disable response tracking on this MD
+	 *   regardless of the value of the lnet_response_tracking param.
 	 *
 	 * Note:
 	 * - LNET_MD_KIOV allows for a scatter/gather capability for memory
@@ -545,6 +549,10 @@ struct lnet_md {
 #define LNET_MD_KIOV		(1 << 8)
 /** See lnet_md::options. */
 #define LNET_MD_BULK_HANDLE	(1 << 9)
+/** See struct lnet_md::options. */
+#define LNET_MD_TRACK_RESPONSE		(1 << 10)
+/** See struct lnet_md::options. */
+#define LNET_MD_NO_TRACK_RESPONSE	(1 << 11)
 
 /* For compatibility with Cray Portals */
 #define LNET_MD_PHYS		0
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 25/45] lustre: Send file creation time to clients
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (23 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 24/45] lnet: Add MD options for response tracking James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 26/45] lnet: stop using struct timeval James Simmons
                   ` (20 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Qian Yingjin <qian@ddn.com>

Both ext4 and ZFS allow storing the file creation time in the
on-disk inode, and the new statx() API allows returning it to
userspace, but as yet we do not have any mechanism to send it
from the servers to the client.

Add fields into struct mdt_body and an OBD_MD_FLBTIME flag to
allow it to be requested and returned directly from MDTs. It
does not need to get it from the OSTs or in the LVB since those
objects are precreated and their creation time (birth time) is
not accurate.

WC-bug-id: https://jira.whamcloud.com/browse/LU-11971
Lustre-commit: 186b97e68abbc ("LU-11971 utils: Send file creation time to clients")
Signed-off-by: Qian Yingjin <qian@ddn.com>
Reviewed-on: https://review.whamcloud.com/36507
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/lu_object.h           | 2 ++
 fs/lustre/llite/dir.c                   | 3 ++-
 fs/lustre/ptlrpc/pack_generic.c         | 2 +-
 fs/lustre/ptlrpc/wiretest.c             | 8 ++++----
 include/uapi/linux/lustre/lustre_idl.h  | 6 ++++--
 include/uapi/linux/lustre/lustre_user.h | 1 +
 6 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/fs/lustre/include/lu_object.h b/fs/lustre/include/lu_object.h
index d0a59ff..718fdb8 100644
--- a/fs/lustre/include/lu_object.h
+++ b/fs/lustre/include/lu_object.h
@@ -399,6 +399,8 @@ struct lu_attr {
 	s64	  la_atime;
 	/** change time in seconds since Epoch */
 	s64	  la_ctime;
+	/** create time in seconds since Epoch */
+	s64	la_btime;
 	/** 512-byte blocks allocated to object */
 	u64	  la_blocks;
 	/** permission bits and file type */
diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c
index 41e399b..7fd52fe 100644
--- a/fs/lustre/llite/dir.c
+++ b/fs/lustre/llite/dir.c
@@ -1758,11 +1758,12 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 			stx.stx_atime.tv_sec = body->mbo_atime;
 			stx.stx_ctime.tv_sec = body->mbo_ctime;
 			stx.stx_mtime.tv_sec = body->mbo_mtime;
+			stx.stx_btime.tv_sec = body->mbo_btime;
 			stx.stx_rdev_major = MAJOR(body->mbo_rdev);
 			stx.stx_rdev_minor = MINOR(body->mbo_rdev);
 			stx.stx_dev_major = MAJOR(inode->i_sb->s_dev);
 			stx.stx_dev_minor = MINOR(inode->i_sb->s_dev);
-			stx.stx_mask |= STATX_BASIC_STATS;
+			stx.stx_mask |= STATX_BASIC_STATS | STATX_BTIME;
 
 			/*
 			 * For a striped directory, the size and blocks returned
diff --git a/fs/lustre/ptlrpc/pack_generic.c b/fs/lustre/ptlrpc/pack_generic.c
index 82e6c46..55d9814 100644
--- a/fs/lustre/ptlrpc/pack_generic.c
+++ b/fs/lustre/ptlrpc/pack_generic.c
@@ -1805,7 +1805,7 @@ void lustre_swab_mdt_body(struct mdt_body *b)
 	__swab32s(&b->mbo_projid);
 	__swab64s(&b->mbo_dom_size);
 	__swab64s(&b->mbo_dom_blocks);
-	BUILD_BUG_ON(offsetof(typeof(*b), mbo_padding_8) == 0);
+	__swab64s(&b->mbo_btime);
 	BUILD_BUG_ON(offsetof(typeof(*b), mbo_padding_9) == 0);
 	BUILD_BUG_ON(offsetof(typeof(*b), mbo_padding_10) == 0);
 }
diff --git a/fs/lustre/ptlrpc/wiretest.c b/fs/lustre/ptlrpc/wiretest.c
index 81d0a99..8f824ee 100644
--- a/fs/lustre/ptlrpc/wiretest.c
+++ b/fs/lustre/ptlrpc/wiretest.c
@@ -2218,10 +2218,10 @@ void lustre_assert_wire_constants(void)
 		 (long long)(int)offsetof(struct mdt_body, mbo_dom_blocks));
 	LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_dom_blocks) == 8, "found %lld\n",
 		 (long long)(int)sizeof(((struct mdt_body *)0)->mbo_dom_blocks));
-	LASSERTF((int)offsetof(struct mdt_body, mbo_padding_8) == 192, "found %lld\n",
-		 (long long)(int)offsetof(struct mdt_body, mbo_padding_8));
-	LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_padding_8) == 8, "found %lld\n",
-		 (long long)(int)sizeof(((struct mdt_body *)0)->mbo_padding_8));
+	LASSERTF((int)offsetof(struct mdt_body, mbo_btime) == 192, "found %lld\n",
+		 (long long)(int)offsetof(struct mdt_body, mbo_btime));
+	LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_btime) == 8, "found %lld\n",
+		 (long long)(int)sizeof(((struct mdt_body *)0)->mbo_btime));
 	LASSERTF((int)offsetof(struct mdt_body, mbo_padding_9) == 200, "found %lld\n",
 		 (long long)(int)offsetof(struct mdt_body, mbo_padding_9));
 	LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_padding_9) == 8, "found %lld\n",
diff --git a/include/uapi/linux/lustre/lustre_idl.h b/include/uapi/linux/lustre/lustre_idl.h
index 743af77..bb3f5f1 100644
--- a/include/uapi/linux/lustre/lustre_idl.h
+++ b/include/uapi/linux/lustre/lustre_idl.h
@@ -1213,6 +1213,8 @@ static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic)
 #define OBD_MD_FLLAZYSIZE    (0x0400000000000000ULL) /* Lazy size */
 #define OBD_MD_FLLAZYBLOCKS  (0x0800000000000000ULL) /* Lazy blocks */
 
+#define OBD_MD_FLBTIME		(0x1000000000000000ULL) /* birth time */
+
 #define OBD_MD_FLALLQUOTA (OBD_MD_FLUSRQUOTA | \
 			   OBD_MD_FLGRPQUOTA | \
 			   OBD_MD_FLPRJQUOTA)
@@ -1222,7 +1224,7 @@ static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic)
 			  OBD_MD_FLMODE  | OBD_MD_FLTYPE  | OBD_MD_FLUID   | \
 			  OBD_MD_FLGID   | OBD_MD_FLFLAGS | OBD_MD_FLNLINK | \
 			  OBD_MD_FLPARENT | OBD_MD_FLRDEV  | OBD_MD_FLGROUP | \
-			  OBD_MD_FLPROJID)
+			  OBD_MD_FLPROJID | OBD_MD_FLBTIME)
 
 #define OBD_MD_FLXATTRALL (OBD_MD_FLXATTR | OBD_MD_FLXATTRLS)
 
@@ -1589,7 +1591,7 @@ struct mdt_body {
 	__u32	mbo_projid;	/* also fix lustre_swab_mdt_body */
 	__u64	mbo_dom_size;	/* size of DOM component */
 	__u64	mbo_dom_blocks; /* blocks consumed by DOM component */
-	__u64	mbo_padding_8; /* also fix lustre_swab_mdt_body */
+	__u64	mbo_btime;
 	__u64	mbo_padding_9;
 	__u64	mbo_padding_10;
 }; /* 216 */
diff --git a/include/uapi/linux/lustre/lustre_user.h b/include/uapi/linux/lustre/lustre_user.h
index 6644b99..80e5c24 100644
--- a/include/uapi/linux/lustre/lustre_user.h
+++ b/include/uapi/linux/lustre/lustre_user.h
@@ -1064,6 +1064,7 @@ enum la_valid {
 	LA_LAYOUT_VERSION = 1 << 16,
 	LA_LSIZE	= 1 << 17,
 	LA_LBLOCKS	= 1 << 18,
+	LA_BTIME	= 1 << 19,	/* 0x8000 */
 	/**
 	 * Attributes must be transmitted to OST objects
 	 */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 26/45] lnet: stop using struct timeval
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (24 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 25/45] lustre: Send file creation time to clients James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 27/45] lustre: ptlrpc: connect to MDT stucks James Simmons
                   ` (19 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

The struct timeval is not 2038 safe so the Linux kernel is moving
away from its use. The use of rpe_stamp hasn't been used since
Lustre 2.2 so remove the userland use of this field. This frees
use to change rpe_stamp to an equivalent struct timespec64 for
future use. Greatly simplify lnet_sock_[read|write] by using
jiffies values of sk_sndtimeo, sk_rcvtimeo cached in struct sock.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13344
Lustre-commit: 5e4c658c4fea4 ("LU-13344 lnet: stop using struct timeval")
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/38105
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
---
 include/uapi/linux/lnet/lnetst.h        |  8 +++++++-
 include/uapi/linux/lustre/lustre_user.h |  2 +-
 net/lnet/lnet/lib-socket.c              | 34 ++++++++++-----------------------
 net/lnet/selftest/conctl.c              |  1 -
 net/lnet/selftest/conrpc.c              |  6 +++---
 net/lnet/selftest/conrpc.h              |  1 -
 net/lnet/selftest/console.h             |  1 -
 7 files changed, 21 insertions(+), 32 deletions(-)

diff --git a/include/uapi/linux/lnet/lnetst.h b/include/uapi/linux/lnet/lnetst.h
index 9e61c16..dd38a90 100644
--- a/include/uapi/linux/lnet/lnetst.h
+++ b/include/uapi/linux/lnet/lnetst.h
@@ -149,7 +149,13 @@ struct list_head {
 struct lstcon_rpc_ent {
 	struct list_head	rpe_link;	/* link chain */
 	struct lnet_process_id	rpe_peer;	/* peer's id */
-	struct timeval		rpe_stamp;	/* time stamp of RPC */
+	/* This has not been used since Lustre 2.2 so its safe to use.
+	 * Update to allow future use of timespec64
+	 */
+	struct {
+		__s64		tv_sec;
+		__s64		tv_nsec;
+	} rpe_stamp;				/* time stamp of RPC */
 	int			rpe_state;	/* peer's state */
 	int			rpe_rpc_errno;	/* RPC errno */
 
diff --git a/include/uapi/linux/lustre/lustre_user.h b/include/uapi/linux/lustre/lustre_user.h
index 80e5c24..4b7c89b 100644
--- a/include/uapi/linux/lustre/lustre_user.h
+++ b/include/uapi/linux/lustre/lustre_user.h
@@ -961,7 +961,7 @@ struct identity_downcall_data {
 
 struct sepol_downcall_data {
 	__u32		sdd_magic;
-	__kernel_time_t	sdd_sepol_mtime;
+	__s64		sdd_sepol_mtime;
 	__u16		sdd_sepol_len;
 	char		sdd_sepol[0];
 };
diff --git a/net/lnet/lnet/lib-socket.c b/net/lnet/lnet/lib-socket.c
index 72e45ca..a4db830 100644
--- a/net/lnet/lnet/lib-socket.c
+++ b/net/lnet/lnet/lib-socket.c
@@ -50,8 +50,6 @@
 	int rc;
 	long jiffies_left = timeout * HZ;
 	unsigned long then;
-	struct timeval tv;
-	struct __kernel_sock_timeval ktv;
 	struct kvec iov = {
 		.iov_base = buffer,
 		.iov_len = nob
@@ -67,17 +65,12 @@
 	for (;;) {
 		msg.msg_flags = !timeout ? MSG_DONTWAIT : 0;
 		if (timeout) {
+			struct sock *sk = sock->sk;
+
 			/* Set send timeout to remaining time */
-			jiffies_to_timeval(jiffies_left, &tv);
-			ktv.tv_sec = tv.tv_sec;
-			ktv.tv_usec = tv.tv_usec;
-			rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_NEW,
-					       (char *)&ktv, sizeof(ktv));
-			if (rc) {
-				CERROR("Can't set socket send timeout %ld.%06d: %d\n",
-				       (long)tv.tv_sec, (int)tv.tv_usec, rc);
-				return rc;
-			}
+			lock_sock(sk);
+			sk->sk_sndtimeo = jiffies_left;
+			release_sock(sk);
 		}
 
 		then = jiffies;
@@ -108,8 +101,6 @@
 	int rc;
 	long jiffies_left = timeout * HZ;
 	unsigned long then;
-	struct timeval tv;
-	struct __kernel_sock_timeval ktv;
 	struct kvec iov = {
 		.iov_base = buffer,
 		.iov_len = nob
@@ -124,17 +115,12 @@
 	iov_iter_kvec(&msg.msg_iter, READ, &iov, 1, nob);
 
 	for (;;) {
+		struct sock *sk = sock->sk;
+
 		/* Set receive timeout to remaining time */
-		jiffies_to_timeval(jiffies_left, &tv);
-		ktv.tv_sec = tv.tv_sec;
-		ktv.tv_usec = tv.tv_usec;
-		rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO_NEW,
-				       (char *)&ktv, sizeof(ktv));
-		if (rc) {
-			CERROR("Can't set socket recv timeout %ld.%06d: %d\n",
-			       (long)tv.tv_sec, (int)tv.tv_usec, rc);
-			return rc;
-		}
+		lock_sock(sk);
+		sk->sk_rcvtimeo = jiffies_left;
+		release_sock(sk);
 
 		then = jiffies;
 		rc = sock_recvmsg(sock, &msg, 0);
diff --git a/net/lnet/selftest/conctl.c b/net/lnet/selftest/conctl.c
index ed9eab9..7e82304 100644
--- a/net/lnet/selftest/conctl.c
+++ b/net/lnet/selftest/conctl.c
@@ -38,7 +38,6 @@
  */
 
 #include <linux/lnet/lib-lnet.h>
-#include <uapi/linux/lnet/lnetst.h>
 #include "console.h"
 
 static int
diff --git a/net/lnet/selftest/conrpc.c b/net/lnet/selftest/conrpc.c
index 8baaac8..6a55b23 100644
--- a/net/lnet/selftest/conrpc.c
+++ b/net/lnet/selftest/conrpc.c
@@ -474,7 +474,7 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,
 	struct lstcon_rpc *crpc;
 	struct srpc_msg *msg;
 	struct lstcon_node *nd;
-	struct timeval tv;
+	struct timespec64 ts;
 	int error;
 	s64 dur;
 
@@ -501,11 +501,11 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,
 
 		dur = crpc->crp_stamp_ns -
 		      console_session.ses_id.ses_stamp * NSEC_PER_MSEC;
-		tv = ns_to_timeval(dur);
+		ts = ns_to_timespec64(dur);
 
 		if (copy_to_user(&ent->rpe_peer, &nd->nd_id,
 				 sizeof(struct lnet_process_id)) ||
-		    copy_to_user(&ent->rpe_stamp, &tv, sizeof(tv)) ||
+		    copy_to_user(&ent->rpe_stamp, &ts, sizeof(ts)) ||
 		    copy_to_user(&ent->rpe_state, &nd->nd_state,
 				 sizeof(nd->nd_state)) ||
 		    copy_to_user(&ent->rpe_rpc_errno, &error,
diff --git a/net/lnet/selftest/conrpc.h b/net/lnet/selftest/conrpc.h
index fd75c50..180fa02 100644
--- a/net/lnet/selftest/conrpc.h
+++ b/net/lnet/selftest/conrpc.h
@@ -41,7 +41,6 @@
 #define __LST_CONRPC_H__
 
 #include <linux/lnet/lib-types.h>
-#include <uapi/linux/lnet/lnetst.h>
 #include "rpc.h"
 #include "selftest.h"
 
diff --git a/net/lnet/selftest/console.h b/net/lnet/selftest/console.h
index a463276..cd132e1 100644
--- a/net/lnet/selftest/console.h
+++ b/net/lnet/selftest/console.h
@@ -41,7 +41,6 @@
 #define __LST_CONSOLE_H__
 
 #include <linux/lnet/lib-types.h>
-#include <uapi/linux/lnet/lnetst.h>
 #include "selftest.h"
 #include "conrpc.h"
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 27/45] lustre: ptlrpc: connect to MDT stucks
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (25 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 26/45] lnet: stop using struct timeval James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 28/45] lnet: restrict gateway selection James Simmons
                   ` (18 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Andriy Skulysh <c17819@cray.com>

mdc_ioc_hsm_ct_register() is executed on
IMP_EVENT_ACTIVE event.
If HSM_CT_REGISTER request expires import becomes
disconnected but reconnect can't start because
previous connect waits for completion of
HSM_CT_REGISTER request.

Mark HSM_CT_REGISTER request as no_resend.

Cray-bug-id: LUS-8409
WC-bug-id: https://jira.whamcloud.com/browse/LU-13455
Lustre-commit: 3d58403e62b7b ("LU-13455 ptlrpc: connect to MDT stucks")
Signed-off-by: Andriy Skulysh <c17819@cray.com>
Reviewed-on: https://review.whamcloud.com/38243
Reviewed-by: Alexander Boyko <c17825@cray.com>
Reviewed-by: Ben Evans <jevans@cray.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Ben Evans <beevans@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/mdc/mdc_request.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/lustre/mdc/mdc_request.c b/fs/lustre/mdc/mdc_request.c
index 0cbab8b..369114b 100644
--- a/fs/lustre/mdc/mdc_request.c
+++ b/fs/lustre/mdc/mdc_request.c
@@ -1845,6 +1845,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, u32 archive_count,
 		*archive_array = archive_count;
 
 	ptlrpc_request_set_replen(req);
+	req->rq_no_resend = 1;
 
 	rc = mdc_queue_wait(req);
 out:
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 28/45] lnet: restrict gateway selection
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (26 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 27/45] lustre: ptlrpc: connect to MDT stucks James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 29/45] lustre: llite: restore ll_dcompare() James Simmons
                   ` (17 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Amir Shehata <ashehata@whamcloud.com>

This patch fixes a conflict between
LU-13026 lnet: MR selection of gateway ni
and
LU-12919 lnet: Fix source specified route selection

LU-12919 patch relied on lnet_find_best_lpni_on_net() to restrict
lpni selection on a specific network. However, it is necessary
to allow lpni selection on any network if the src net is not
specified. LU-13026 removed the restriction imposed by
lnet_find_best_lpni_on_net(), which broke the restriction
on the source net selection in some configuration setups.

This patch renames lnet_find_best_lpni_on_net() to
lnet_find_best_lpni(). If passed a peer_net it will find the
best lpni on the peer_net or return NULL if none is available.
If passed 'any' net, then it'll find the best reachable lpni
on any available net.

Fixes: 66aa587df71 ("lnet: MR selection of gateway ni")
Fixes: c3efd008790 ("lnet: Fix source specified route selection")
WC-bug-id: https://jira.whamcloud.com/browse/LU-13461
Lustre-commit: ceb92c5512bad ("LU-13461 lnet: restrict gateway selection")
Signed-off-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38298
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/lnet/lib-move.c | 91 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 64 insertions(+), 27 deletions(-)

diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c
index 4eaaa5f..cf134b5 100644
--- a/net/lnet/lnet/lib-move.c
+++ b/net/lnet/lnet/lib-move.c
@@ -1143,6 +1143,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 static struct lnet_peer_ni *
 lnet_select_peer_ni(struct lnet_ni *best_ni, lnet_nid_t dst_nid,
 		    struct lnet_peer *peer,
+		    struct lnet_peer_ni *best_lpni,
 		    struct lnet_peer_net *peer_net)
 {
 	/* Look at the peer NIs for the destination peer that connect
@@ -1153,11 +1154,12 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 	 * credits are equal, we round-robin over the peer_ni.
 	 */
 	struct lnet_peer_ni *lpni = NULL;
-	struct lnet_peer_ni *best_lpni = NULL;
-	int best_lpni_credits = INT_MIN;
+	int best_lpni_credits =  (best_lpni) ? best_lpni->lpni_txcredits :
+					       INT_MIN;
+	int best_lpni_healthv = (best_lpni) ?
+				atomic_read(&best_lpni->lpni_healthv) : 0;
 	bool preferred = false;
 	bool ni_is_pref;
-	int best_lpni_healthv = 0;
 	int lpni_healthv;
 
 	while ((lpni = lnet_get_next_peer_ni_locked(peer, peer_net, lpni))) {
@@ -1231,19 +1233,43 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 	return best_lpni;
 }
 
-/* Prerequisite: the best_ni should already be set in the sd */
+/* Prerequisite: the best_ni should already be set in the sd
+ * Find the best lpni.
+ * If the net id is provided then restrict lpni selection on
+ * that particular net.
+ * Otherwise find any reachable lpni. When dealing with an MR
+ * gateway and it has multiple lpnis which we can use
+ * we want to select the best one from the list of reachable
+ * ones.
+ */
 static inline struct lnet_peer_ni *
-lnet_find_best_lpni_on_net(struct lnet_ni *lni, lnet_nid_t dst_nid,
-			   struct lnet_peer *peer, u32 net_id)
+lnet_find_best_lpni(struct lnet_ni *lni, lnet_nid_t dst_nid,
+		    struct lnet_peer *peer, u32 net_id)
 {
 	struct lnet_peer_net *peer_net;
+	u32 any_net = LNET_NIDNET(LNET_NID_ANY);
 
-	/* The gateway is Multi-Rail capable so now we must select the
-	 * proper peer_ni
-	 */
+	/* find the best_lpni on any local network */
+	if (net_id == any_net) {
+		struct lnet_peer_ni *best_lpni = NULL;
+		struct lnet_peer_net *lpn;
+
+		list_for_each_entry(lpn, &peer->lp_peer_nets, lpn_peer_nets) {
+			/* no net specified find any reachable peer ni */
+			if (!lnet_islocalnet_locked(lpn->lpn_net_id))
+				continue;
+			best_lpni = lnet_select_peer_ni(lni, dst_nid, peer,
+							best_lpni, lpn);
+		}
+
+		return best_lpni;
+	}
+	/* restrict on the specified net */
 	peer_net = lnet_peer_get_net_locked(peer, net_id);
+	if (peer_net)
+		return lnet_select_peer_ni(lni, dst_nid, peer, NULL, peer_net);
 
-	return lnet_select_peer_ni(lni, dst_nid, peer, peer_net);
+	return NULL;
 }
 
 /* Compare route priorities and hop counts */
@@ -1279,6 +1305,9 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 	struct lnet_route *route;
 	int rc;
 
+	CDEBUG(D_NET, "Looking up a route to %s, from %s\n",
+	       libcfs_net2str(rnet->lrn_net), libcfs_net2str(src_net));
+
 	best_route = NULL;
 	last_route = NULL;
 	list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
@@ -1290,15 +1319,16 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 		 * the best interface available.
 		 */
 		if (!best_route) {
-			lpni = lnet_find_best_lpni_on_net(NULL, LNET_NID_ANY,
-							  route->lr_gateway,
-							  src_net);
+			lpni = lnet_find_best_lpni(NULL, LNET_NID_ANY,
+						   route->lr_gateway,
+						   src_net);
 			if (lpni) {
 				best_route = route;
 				last_route = route;
 				best_gw_ni = lpni;
 			} else {
-				CERROR("Gateway %s does not have a peer NI on net %s\n",
+				CDEBUG(D_NET,
+				       "Gateway %s does not have a peer NI on net %s\n",
 				       libcfs_nid2str(route->lr_gateway->lp_primary_nid),
 				       libcfs_net2str(src_net));
 			}
@@ -1313,11 +1343,13 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 		if (rc == -1)
 			continue;
 
-		lpni = lnet_find_best_lpni_on_net(NULL, LNET_NID_ANY,
-						  route->lr_gateway,
-						  src_net);
+		lpni = lnet_find_best_lpni(NULL, LNET_NID_ANY,
+					   route->lr_gateway,
+					   src_net);
+		/* restrict the lpni on the src_net if specified */
 		if (!lpni) {
-			CERROR("Gateway %s does not have a peer NI on net %s\n",
+			CDEBUG(D_NET,
+			       "Gateway %s does not have a peer NI on net %s\n",
 			       libcfs_nid2str(route->lr_gateway->lp_primary_nid),
 			       libcfs_net2str(src_net));
 			continue;
@@ -1794,7 +1826,12 @@ struct lnet_ni *
 	struct lnet_route *last_route = NULL;
 	struct lnet_peer_ni *lpni = NULL;
 	struct lnet_peer_ni *gwni = NULL;
-	lnet_nid_t src_nid = sd->sd_src_nid;
+	lnet_nid_t src_nid = (sd->sd_src_nid != LNET_NID_ANY) ? sd->sd_src_nid :
+			      sd->sd_best_ni ? sd->sd_best_ni->ni_nid :
+			      LNET_NID_ANY;
+
+	CDEBUG(D_NET, "using src nid %s for route restriction\n",
+	       libcfs_nid2str(src_nid));
 
 	/* If a router nid was specified then we are replying to a GET or
 	 * sending an ACK. In this case we use the gateway associated with the
@@ -1842,12 +1879,12 @@ struct lnet_ni *
 			return -EHOSTUNREACH;
 		}
 
-		sd->sd_best_lpni = lnet_find_best_lpni_on_net(sd->sd_best_ni,
-							      sd->sd_dst_nid,
-							      lp,
-							      best_lpn->lpn_net_id);
+		sd->sd_best_lpni = lnet_find_best_lpni(sd->sd_best_ni,
+						       sd->sd_dst_nid,
+						       lp,
+						       best_lpn->lpn_net_id);
 		if (!sd->sd_best_lpni) {
-			CERROR("peer %s down\n",
+			CERROR("peer %s is unreachable\n",
 			       libcfs_nid2str(sd->sd_dst_nid));
 			return -EHOSTUNREACH;
 		}
@@ -2176,9 +2213,9 @@ struct lnet_ni *
 					lnet_msg_discovery(sd->sd_msg));
 	if (sd->sd_best_ni) {
 		sd->sd_best_lpni =
-		  lnet_find_best_lpni_on_net(sd->sd_best_ni, sd->sd_dst_nid,
-					     sd->sd_peer,
-					     sd->sd_best_ni->ni_net->net_id);
+		  lnet_find_best_lpni(sd->sd_best_ni, sd->sd_dst_nid,
+				      sd->sd_peer,
+				      sd->sd_best_ni->ni_net->net_id);
 
 		/* if we're successful in selecting a peer_ni on the local
 		 * network, then send to it. Otherwise fall through and
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 29/45] lustre: llite: restore ll_dcompare()
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (27 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 28/45] lnet: restrict gateway selection James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 30/45] lustre: fallocate: Implement fallocate preallocate operation James Simmons
                   ` (16 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Andreas Dilger <adilger@whamcloud.com>

Revert "LU-9868 llite: Get rid of ll_dcompare" as it is causing
failures in conf-sanity test_32* due to errors with sub-mounted
ext2 filesystem dentries being invalidated.

This reverts commit 8f0a4c7b907a27e77ea0dd80198478747c87bfba.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13486
Lustre-commit: 00fa5e8ef4559 ("LU-13486 llite: restore ll_dcompare()")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38498
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/dcache.c | 53 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 43 insertions(+), 10 deletions(-)

diff --git a/fs/lustre/llite/dcache.c b/fs/lustre/llite/dcache.c
index 5fab108..edcc1a7 100644
--- a/fs/lustre/llite/dcache.c
+++ b/fs/lustre/llite/dcache.c
@@ -61,6 +61,48 @@ static void ll_release(struct dentry *de)
 	call_rcu(&lld->lld_rcu_head, free_dentry_data);
 }
 
+/* Compare if two dentries are the same.  Don't match if the existing dentry
+ * is marked invalid.  Returns 1 if different, 0 if the same.
+ *
+ * This avoids a race where ll_lookup_it() instantiates a dentry, but we get
+ * an AST before calling d_revalidate_it().  The dentry still exists (marked
+ * INVALID) so d_lookup() matches it, but we have no lock on it (so
+ * lock_match() fails) and we spin around real_lookup().
+ *
+ * This race doesn't apply to lookups in d_alloc_parallel(), and for
+ * those we want to ensure that only one dentry with a given name is
+ * in ll_lookup_nd() at a time.  So allow invalid dentries to match
+ * while d_in_lookup().  We will be called again when the lookup
+ * completes, and can give a different answer then.
+ */
+static int ll_dcompare(const struct dentry *dentry,
+		       unsigned int len, const char *str,
+		       const struct qstr *name)
+{
+	if (len != name->len)
+		return 1;
+
+	if (memcmp(str, name->name, len))
+		return 1;
+
+	CDEBUG(D_DENTRY, "found name %.*s(%p) flags %#x refc %d\n",
+	       name->len, name->name, dentry, dentry->d_flags,
+	       d_count(dentry));
+
+	/* mountpoint is always valid */
+	if (d_mountpoint(dentry))
+		return 0;
+
+	/* ensure exclusion against parallel lookup of the same name */
+	if (d_in_lookup((struct dentry *)dentry))
+		return 0;
+
+	if (d_lustre_invalid(dentry))
+		return 1;
+
+	return 0;
+}
+
 /**
  * Called when last reference to a dentry is dropped and dcache wants to know
  * whether or not it should cache it:
@@ -202,16 +244,6 @@ static int ll_revalidate_dentry(struct dentry *dentry,
 {
 	struct inode *dir = d_inode(dentry->d_parent);
 
-	CDEBUG(D_VFSTRACE, "VFS Op:name=%s, flags=%u\n",
-	       dentry->d_name.name, lookup_flags);
-
-	/* mountpoint is always valid */
-	if (d_mountpoint(dentry))
-		return 1;
-
-	if (d_lustre_invalid(dentry))
-		return 0;
-
 	/* If this is intermediate component path lookup and we were able to get
 	 * to this dentry, then its lock has not been revoked and the
 	 * path component is valid.
@@ -258,4 +290,5 @@ static int ll_revalidate_nd(struct dentry *dentry, unsigned int flags)
 	.d_revalidate = ll_revalidate_nd,
 	.d_release = ll_release,
 	.d_delete  = ll_ddelete,
+	.d_compare = ll_dcompare,
 };
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 30/45] lustre: fallocate: Implement fallocate preallocate operation
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (28 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 29/45] lustre: llite: restore ll_dcompare() James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 31/45] lustre: llite: fix possible divide zero in ll_use_fast_io() James Simmons
                   ` (15 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Swapnil Pimpale <spimpale@ddn.com>

This patch adds fallocate(2) preallocate operation support
for Lustre. fallocate(2) method of the inode_operations or
file_operations is implemented and transported to the OSTs
to interface with the underlying OSD's fallocate(2) code.

In a saperate patch, a new RPC, OST_FALLOCATE has been
added and reserved for space preallocation. The fallocate
functionality (prealloc) in CLIO has been multiplexed
with CIT_SETATTR. (https://review.whamcloud.com/37277)

Lustre fsx(File system exerciser) is updated in a saperate
patch to handle fallocate calls. (https://review.whamcloud.com/37277)

Only fallocate preallocate operation is supported by this
patch for now. Other operations like, FALLOC_FL_PUNCH
(deallocate), FALLOC_FL_ZERO_RANGE, FALLOC_FL_COLLAPSE_RANGE
and FALLOC_FL_INSPECT_RANGE is not supported by this patch
and will be addressed by a separate patch.

ZFS operation is not supported by this patch. ZFS fallocate(2)
will be addressed by patch (https://review.whamcloud.com/36506/)

New test case under sanity is added to verify fallocate
call.

WC-bug-id: https://jira.whamcloud.com/browse/LU-3606
Lustre-commit: 48457868a02ae ("LU-3606 fallocate: Implement fallocate preallocate operation")
Signed-off-by: Swapnil Pimpale <spimpale@ddn.com>
Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Abrarahmed Momin <abrar.momin@gmail.com>
Signed-off-by: Arshad Hussain <arshad.super@gmail.com>
Reviewed-on: https://review.whamcloud.com/9275
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/cl_object.h         | 44 +++++++++++++++++-
 fs/lustre/include/lustre_req_layout.h |  1 +
 fs/lustre/include/obd_support.h       |  5 ++-
 fs/lustre/llite/file.c                | 84 +++++++++++++++++++++++++++++++++--
 fs/lustre/llite/lcommon_cl.c          |  2 +
 fs/lustre/llite/llite_internal.h      |  1 +
 fs/lustre/llite/lproc_llite.c         |  1 +
 fs/lustre/llite/vvp_io.c              | 17 ++++---
 fs/lustre/lov/lov_io.c                | 27 ++++++++---
 fs/lustre/osc/osc_internal.h          |  3 ++
 fs/lustre/osc/osc_io.c                | 56 +++++++++++++++++++----
 fs/lustre/osc/osc_request.c           | 65 ++++++++++++++++++++++++++-
 fs/lustre/ptlrpc/layout.c             |  5 +++
 13 files changed, 286 insertions(+), 25 deletions(-)

diff --git a/fs/lustre/include/cl_object.h b/fs/lustre/include/cl_object.h
index 91d3172..cde89f67 100644
--- a/fs/lustre/include/cl_object.h
+++ b/fs/lustre/include/cl_object.h
@@ -89,6 +89,7 @@
 /*
  * super-class definitions.
  */
+#include <linux/uio.h>
 #include <lu_object.h>
 #include <linux/atomic.h>
 #include <linux/mutex.h>
@@ -1765,6 +1766,32 @@ struct cl_io_rw_common {
 	int			crw_nonblock;
 };
 
+enum cl_setattr_subtype {
+	/** regular setattr **/
+	CL_SETATTR_REG	= 1,
+	/** truncate(2) **/
+	CL_SETATTR_TRUNC,
+	/** fallocate(2) - mode preallocate **/
+	CL_SETATTR_FALLOCATE
+};
+
+struct cl_io_range {
+	loff_t		cir_pos;
+	size_t		cir_count;
+};
+
+struct cl_io_pt {
+	struct cl_io_pt	*cip_next;
+	struct kiocb	cip_iocb;
+	struct iov_iter	cip_iter;
+	struct file	*cip_file;
+	enum cl_io_type	cip_iot;
+	unsigned int	cip_need_restart:1;
+	loff_t		cip_pos;
+	size_t		cip_count;
+	ssize_t		cip_result;
+};
+
 /**
  * State for io.
  *
@@ -1812,6 +1839,14 @@ struct cl_io {
 			int			sa_stripe_index;
 			struct ost_layout	sa_layout;
 			const struct lu_fid	*sa_parent_fid;
+			/* SETATTR interface is used for regular setattr, */
+			/* truncate(2) and fallocate(2) subtypes */
+			enum cl_setattr_subtype	sa_subtype;
+			/* The following are used for fallocate(2) */
+			int			sa_falloc_mode;
+			loff_t			sa_falloc_offset;
+			loff_t			sa_falloc_len;
+			loff_t			sa_falloc_end;
 		} ci_setattr;
 		struct cl_data_version_io {
 			u64			dv_data_version;
@@ -2399,7 +2434,14 @@ static inline int cl_io_is_mkwrite(const struct cl_io *io)
 static inline int cl_io_is_trunc(const struct cl_io *io)
 {
 	return io->ci_type == CIT_SETATTR &&
-		(io->u.ci_setattr.sa_avalid & ATTR_SIZE);
+		(io->u.ci_setattr.sa_avalid & ATTR_SIZE) &&
+		(io->u.ci_setattr.sa_subtype != CL_SETATTR_FALLOCATE);
+}
+
+static inline int cl_io_is_fallocate(const struct cl_io *io)
+{
+	return (io->ci_type == CIT_SETATTR) &&
+	       (io->u.ci_setattr.sa_subtype == CL_SETATTR_FALLOCATE);
 }
 
 struct cl_io *cl_io_top(struct cl_io *io);
diff --git a/fs/lustre/include/lustre_req_layout.h b/fs/lustre/include/lustre_req_layout.h
index 8efdf7f..72d9df0 100644
--- a/fs/lustre/include/lustre_req_layout.h
+++ b/fs/lustre/include/lustre_req_layout.h
@@ -186,6 +186,7 @@ void req_capsule_shrink(struct req_capsule *pill,
 extern struct req_format RQF_OST_SETATTR;
 extern struct req_format RQF_OST_CREATE;
 extern struct req_format RQF_OST_PUNCH;
+extern struct req_format RQF_OST_FALLOCATE;
 extern struct req_format RQF_OST_SYNC;
 extern struct req_format RQF_OST_DESTROY;
 extern struct req_format RQF_OST_BRW_READ;
diff --git a/fs/lustre/include/obd_support.h b/fs/lustre/include/obd_support.h
index 1f69530..ce0aa8c 100644
--- a/fs/lustre/include/obd_support.h
+++ b/fs/lustre/include/obd_support.h
@@ -264,8 +264,9 @@
 #define OBD_FAIL_OST_DQACQ_NET				0x230
 #define OBD_FAIL_OST_STATFS_EINPROGRESS			0x231
 #define OBD_FAIL_OST_SET_INFO_NET			0x232
-#define OBD_FAIL_OST_DISCONNECT_DELAY	 0x245
-#define OBD_FAIL_OST_PREPARE_DELAY	 0x247
+#define OBD_FAIL_OST_DISCONNECT_DELAY			0x245
+#define OBD_FAIL_OST_PREPARE_DELAY			0x247
+#define OBD_FAIL_OST_FALLOCATE_NET			0x249
 
 #define OBD_FAIL_LDLM					0x300
 #define OBD_FAIL_LDLM_NAMESPACE_NEW			0x301
diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c
index be20b74..871fa59 100644
--- a/fs/lustre/llite/file.c
+++ b/fs/lustre/llite/file.c
@@ -43,6 +43,8 @@
 #include <linux/file.h>
 #include <linux/sched.h>
 #include <linux/mount.h>
+#include <linux/falloc.h>
+
 #include <uapi/linux/lustre/lustre_fiemap.h>
 #include <uapi/linux/lustre/lustre_ioctl.h>
 #include <lustre_swab.h>
@@ -4635,6 +4637,79 @@ int ll_getattr(const struct path *path, struct kstat *stat,
 	return 0;
 }
 
+int cl_falloc(struct inode *inode, int mode, loff_t offset, loff_t len)
+{
+	struct lu_env *env;
+	struct cl_io *io;
+	u16 refcheck;
+	int rc; loff_t sa_falloc_end;
+	loff_t size = i_size_read(inode);
+
+	env = cl_env_get(&refcheck);
+	if (IS_ERR(env))
+		return PTR_ERR(env);
+
+	io = vvp_env_thread_io(env);
+	io->ci_obj = ll_i2info(inode)->lli_clob;
+	io->ci_verify_layout = 1;
+	io->u.ci_setattr.sa_parent_fid = lu_object_fid(&io->ci_obj->co_lu);
+	io->u.ci_setattr.sa_falloc_mode = mode;
+	io->u.ci_setattr.sa_falloc_offset = offset;
+	io->u.ci_setattr.sa_falloc_len = len;
+	io->u.ci_setattr.sa_falloc_end = io->u.ci_setattr.sa_falloc_offset +
+					 io->u.ci_setattr.sa_falloc_len;
+	io->u.ci_setattr.sa_subtype = CL_SETATTR_FALLOCATE;
+	sa_falloc_end = io->u.ci_setattr.sa_falloc_end;
+	if (sa_falloc_end > size) {
+		/* Check new size against VFS/VM file size limit and rlimit */
+		rc = inode_newsize_ok(inode, sa_falloc_end);
+		if (rc)
+			goto out;
+		if (sa_falloc_end > ll_file_maxbytes(inode)) {
+			CDEBUG(D_INODE, "file size too large %llu > %llu\n",
+			       (unsigned long long)(sa_falloc_end),
+			       ll_file_maxbytes(inode));
+			rc = -EFBIG;
+			goto out;
+		}
+		io->u.ci_setattr.sa_attr.lvb_size = sa_falloc_end;
+		if (!(mode & FALLOC_FL_KEEP_SIZE))
+			io->u.ci_setattr.sa_avalid |= ATTR_SIZE;
+	} else {
+		io->u.ci_setattr.sa_attr.lvb_size = size;
+	}
+
+again:
+	if (cl_io_init(env, io, CIT_SETATTR, io->ci_obj) == 0)
+		rc = cl_io_loop(env, io);
+	else
+		rc = io->ci_result;
+
+	cl_io_fini(env, io);
+	if (unlikely(io->ci_need_restart))
+		goto again;
+
+out:
+	cl_env_put(env, &refcheck);
+	return rc;
+}
+
+long ll_fallocate(struct file *filp, int mode, loff_t offset, loff_t len)
+{
+	struct inode *inode = filp->f_path.dentry->d_inode;
+
+	/*
+	 * Only mode == 0 (which is standard prealloc) is supported now.
+	 * Punch is not supported yet.
+	 */
+	if (mode & ~FALLOC_FL_KEEP_SIZE)
+		return -EOPNOTSUPP;
+
+	ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_FALLOCATE, 1);
+
+	return cl_falloc(inode, mode, offset, len);
+}
+
 static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		     u64 start, u64 len)
 {
@@ -4759,7 +4834,8 @@ int ll_inode_permission(struct inode *inode, int mask)
 	.llseek			= ll_file_seek,
 	.splice_read		= generic_file_splice_read,
 	.fsync			= ll_fsync,
-	.flush			= ll_flush
+	.flush			= ll_flush,
+	.fallocate		= ll_fallocate,
 };
 
 const struct file_operations ll_file_operations_flock = {
@@ -4774,7 +4850,8 @@ int ll_inode_permission(struct inode *inode, int mask)
 	.fsync			= ll_fsync,
 	.flush			= ll_flush,
 	.flock			= ll_file_flock,
-	.lock			= ll_file_flock
+	.lock			= ll_file_flock,
+	.fallocate		= ll_fallocate,
 };
 
 /* These are for -o noflock - to return ENOSYS on flock calls */
@@ -4790,7 +4867,8 @@ int ll_inode_permission(struct inode *inode, int mask)
 	.fsync			= ll_fsync,
 	.flush			= ll_flush,
 	.flock			= ll_file_noflock,
-	.lock			= ll_file_noflock
+	.lock			= ll_file_noflock,
+	.fallocate		= ll_fallocate,
 };
 
 const struct inode_operations ll_file_inode_operations = {
diff --git a/fs/lustre/llite/lcommon_cl.c b/fs/lustre/llite/lcommon_cl.c
index 8cfcfe5..c945351 100644
--- a/fs/lustre/llite/lcommon_cl.c
+++ b/fs/lustre/llite/lcommon_cl.c
@@ -102,6 +102,8 @@ int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr,
 	io->u.ci_setattr.sa_xvalid = xvalid;
 	io->u.ci_setattr.sa_parent_fid = lu_object_fid(&obj->co_lu);
 
+	if (attr->ia_valid & ATTR_SIZE)
+		io->u.ci_setattr.sa_subtype = CL_SETATTR_TRUNC;
 again:
 	if (attr->ia_valid & ATTR_FILE)
 		ll_io_set_mirror(io, attr->ia_file);
diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h
index 76715818..2544a40 100644
--- a/fs/lustre/llite/llite_internal.h
+++ b/fs/lustre/llite/llite_internal.h
@@ -916,6 +916,7 @@ enum {
 	LPROC_LL_LISTXATTR,
 	LPROC_LL_REMOVEXATTR,
 	LPROC_LL_INODE_PERM,
+	LPROC_LL_FALLOCATE,
 	LPROC_LL_FILE_OPCODES
 };
 
diff --git a/fs/lustre/llite/lproc_llite.c b/fs/lustre/llite/lproc_llite.c
index 36cc8bc..4bce3a6 100644
--- a/fs/lustre/llite/lproc_llite.c
+++ b/fs/lustre/llite/lproc_llite.c
@@ -1580,6 +1580,7 @@ static void sbi_kobj_release(struct kobject *kobj)
 	{ LPROC_LL_TRUNC,	LPROCFS_TYPE_LATENCY,	"truncate" },
 	{ LPROC_LL_FLOCK,	LPROCFS_TYPE_LATENCY,	"flock" },
 	{ LPROC_LL_GETATTR,	LPROCFS_TYPE_LATENCY,	"getattr" },
+	{ LPROC_LL_FALLOCATE,	 LPROCFS_TYPE_LATENCY,	"fallocate" },
 	/* dir inode operation */
 	{ LPROC_LL_CREATE,	LPROCFS_TYPE_LATENCY,	"create" },
 	{ LPROC_LL_LINK,	LPROCFS_TYPE_LATENCY,	"link" },
diff --git a/fs/lustre/llite/vvp_io.c b/fs/lustre/llite/vvp_io.c
index 5a488de..d755551 100644
--- a/fs/lustre/llite/vvp_io.c
+++ b/fs/lustre/llite/vvp_io.c
@@ -615,13 +615,16 @@ static int vvp_io_setattr_lock(const struct lu_env *env,
 			       const struct cl_io_slice *ios)
 {
 	struct cl_io *io = ios->cis_io;
-	u64 new_size;
+	u64 lock_start = 0;
+	u64 lock_end = OBD_OBJECT_EOF;
 	u32 enqflags = 0;
 
 	if (cl_io_is_trunc(io)) {
-		new_size = io->u.ci_setattr.sa_attr.lvb_size;
-		if (new_size == 0)
+		if (io->u.ci_setattr.sa_attr.lvb_size == 0)
 			enqflags = CEF_DISCARD_DATA;
+	} else if (cl_io_is_fallocate(io)) {
+		lock_start = io->u.ci_setattr.sa_falloc_offset;
+		lock_end = lock_start + io->u.ci_setattr.sa_attr.lvb_size;
 	} else {
 		unsigned int valid = io->u.ci_setattr.sa_avalid;
 
@@ -635,11 +638,10 @@ static int vvp_io_setattr_lock(const struct lu_env *env,
 		     io->u.ci_setattr.sa_attr.lvb_atime >=
 		     io->u.ci_setattr.sa_attr.lvb_ctime))
 			return 0;
-		new_size = 0;
 	}
 
 	return vvp_io_one_lock(env, io, enqflags, CLM_WRITE,
-			       new_size, OBD_OBJECT_EOF);
+			       lock_start, lock_end);
 }
 
 static int vvp_do_vmtruncate(struct inode *inode, size_t size)
@@ -695,6 +697,9 @@ static int vvp_io_setattr_start(const struct lu_env *env,
 		trunc_sem_down_write(&lli->lli_trunc_sem);
 		inode_lock(inode);
 		inode_dio_wait(inode);
+	} else if (cl_io_is_fallocate(io)) {
+		inode_lock(inode);
+		inode_dio_wait(inode);
 	} else {
 		inode_lock(inode);
 	}
@@ -719,6 +724,8 @@ static void vvp_io_setattr_end(const struct lu_env *env,
 		vvp_do_vmtruncate(inode, io->u.ci_setattr.sa_attr.lvb_size);
 		inode_unlock(inode);
 		trunc_sem_up_write(&lli->lli_trunc_sem);
+	} else if (cl_io_is_fallocate(io)) {
+		inode_unlock(inode);
 	} else {
 		inode_unlock(inode);
 	}
diff --git a/fs/lustre/lov/lov_io.c b/fs/lustre/lov/lov_io.c
index fefbf39..615db73 100644
--- a/fs/lustre/lov/lov_io.c
+++ b/fs/lustre/lov/lov_io.c
@@ -486,11 +486,16 @@ static int lov_io_slice_init(struct lov_io *lio, struct lov_object *obj,
 		break;
 
 	case CIT_SETATTR:
-		if (cl_io_is_trunc(io))
+		if (cl_io_is_fallocate(io)) {
+			lio->lis_pos = io->u.ci_setattr.sa_falloc_offset;
+			lio->lis_endpos = io->u.ci_setattr.sa_falloc_end;
+		} else if (cl_io_is_trunc(io)) {
 			lio->lis_pos = io->u.ci_setattr.sa_attr.lvb_size;
-		else
+			lio->lis_endpos = OBD_OBJECT_EOF;
+		} else {
 			lio->lis_pos = 0;
-		lio->lis_endpos = OBD_OBJECT_EOF;
+			lio->lis_endpos = OBD_OBJECT_EOF;
+		}
 		break;
 
 	case CIT_DATA_VERSION:
@@ -639,15 +644,24 @@ static void lov_io_sub_inherit(struct lov_io_sub *sub, struct lov_io *lio,
 			parent->u.ci_setattr.sa_attr_flags;
 		io->u.ci_setattr.sa_avalid = parent->u.ci_setattr.sa_avalid;
 		io->u.ci_setattr.sa_xvalid = parent->u.ci_setattr.sa_xvalid;
+		io->u.ci_setattr.sa_falloc_mode =
+			parent->u.ci_setattr.sa_falloc_mode;
 		io->u.ci_setattr.sa_stripe_index = stripe;
 		io->u.ci_setattr.sa_parent_fid =
 			parent->u.ci_setattr.sa_parent_fid;
+		/* For SETATTR(fallocate) pass the subtype to lower IO */
+		io->u.ci_setattr.sa_subtype = parent->u.ci_setattr.sa_subtype;
 		if (cl_io_is_trunc(io)) {
 			loff_t new_size = parent->u.ci_setattr.sa_attr.lvb_size;
 
 			new_size = lov_size_to_stripe(lsm, index, new_size,
 						      stripe);
 			io->u.ci_setattr.sa_attr.lvb_size = new_size;
+		} else if (cl_io_is_fallocate(io)) {
+			io->u.ci_setattr.sa_falloc_offset = start;
+			io->u.ci_setattr.sa_falloc_end = end;
+			io->u.ci_setattr.sa_attr.lvb_size =
+				parent->u.ci_setattr.sa_attr.lvb_size;
 		}
 		lov_lsm2layout(lsm, lsm->lsm_entries[index],
 			       &io->u.ci_setattr.sa_layout);
@@ -1488,8 +1502,11 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj,
 		 * - in open, for open O_TRUNC
 		 * - in setattr, for truncate
 		 */
-		/* the truncate is for size > 0 so triggers a restore */
-		if (cl_io_is_trunc(io)) {
+		/*
+		 * the truncate is for size > 0 so triggers a restore,
+		 * also trigger a restore for prealloc/punch
+		 */
+		if (cl_io_is_trunc(io) || cl_io_is_fallocate(io)) {
 			io->ci_restore_needed = 1;
 			result = -ENODATA;
 		} else {
diff --git a/fs/lustre/osc/osc_internal.h b/fs/lustre/osc/osc_internal.h
index 47bb5f2..d05595a 100644
--- a/fs/lustre/osc/osc_internal.h
+++ b/fs/lustre/osc/osc_internal.h
@@ -73,6 +73,9 @@ int osc_match_base(const struct lu_env *env, struct obd_export *exp,
 int osc_setattr_async(struct obd_export *exp, struct obdo *oa,
 		      obd_enqueue_update_f upcall, void *cookie,
 		      struct ptlrpc_request_set *rqset);
+int osc_fallocate_base(struct obd_export *exp, struct obdo *oa,
+		       obd_enqueue_update_f upcall, void *cookie,
+		       int mode);
 int osc_sync_base(struct osc_object *exp, struct obdo *oa,
 		  obd_enqueue_update_f upcall, void *cookie,
 		  struct ptlrpc_request_set *rqset);
diff --git a/fs/lustre/osc/osc_io.c b/fs/lustre/osc/osc_io.c
index 7976a91..7ec059a 100644
--- a/fs/lustre/osc/osc_io.c
+++ b/fs/lustre/osc/osc_io.c
@@ -41,6 +41,7 @@
 #include <lustre_obdo.h>
 #include <lustre_osc.h>
 #include <linux/pagevec.h>
+#include <linux/falloc.h>
 
 #include "osc_internal.h"
 
@@ -543,15 +544,22 @@ static int osc_io_setattr_start(const struct lu_env *env,
 	struct cl_attr *attr = &osc_env_info(env)->oti_attr;
 	struct obdo *oa = &oio->oi_oa;
 	struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
-	u64 size = io->u.ci_setattr.sa_attr.lvb_size;
 	unsigned int ia_avalid = io->u.ci_setattr.sa_avalid;
 	enum op_xvalid ia_xvalid = io->u.ci_setattr.sa_xvalid;
+	u64 size = io->u.ci_setattr.sa_attr.lvb_size;
+	u64 end = OBD_OBJECT_EOF;
+	bool io_is_falloc = false;
 	int result = 0;
 
 	/* truncate cache dirty pages first */
-	if (cl_io_is_trunc(io))
+	if (cl_io_is_trunc(io)) {
 		result = osc_cache_truncate_start(env, cl2osc(obj), size,
 						  &oio->oi_trunc);
+	} else if (cl_io_is_fallocate(io)) {
+		io_is_falloc = true;
+		size = io->u.ci_setattr.sa_falloc_offset;
+		end = io->u.ci_setattr.sa_falloc_end;
+	}
 
 	if (result == 0 && oio->oi_lockless == 0) {
 		cl_object_attr_lock(obj);
@@ -603,9 +611,15 @@ static int osc_io_setattr_start(const struct lu_env *env,
 			oa->o_mtime = attr->cat_mtime;
 		}
 		if (ia_avalid & ATTR_SIZE) {
-			oa->o_size = size;
-			oa->o_blocks = OBD_OBJECT_EOF;
-			oa->o_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
+			if (io_is_falloc) {
+				oa->o_size = size;
+				oa->o_blocks = end;
+				oa->o_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
+			} else {
+				oa->o_size = size;
+				oa->o_blocks = OBD_OBJECT_EOF;
+				oa->o_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
+			}
 
 			if (oio->oi_lockless) {
 				oa->o_flags = OBD_FL_SRVLOCK;
@@ -627,13 +641,20 @@ static int osc_io_setattr_start(const struct lu_env *env,
 
 		init_completion(&cbargs->opc_sync);
 
-		if (ia_avalid & ATTR_SIZE)
+		if (io_is_falloc) {
+			int falloc_mode = io->u.ci_setattr.sa_falloc_mode;
+
+			result = osc_fallocate_base(osc_export(cl2osc(obj)),
+						    oa, osc_async_upcall,
+						    cbargs, falloc_mode);
+		} else if (ia_avalid & ATTR_SIZE) {
 			result = osc_punch_send(osc_export(cl2osc(obj)),
 						oa, osc_async_upcall, cbargs);
-		else
+		} else {
 			result = osc_setattr_async(osc_export(cl2osc(obj)),
 						   oa, osc_async_upcall,
 						   cbargs, PTLRPCD_SET);
+		}
 		cbargs->opc_rpc_sent = result == 0;
 	}
 	return result;
@@ -661,7 +682,7 @@ void osc_io_setattr_end(const struct lu_env *env,
 			/* lockless truncate */
 			struct osc_device *osd = lu2osc_dev(obj->co_lu.lo_dev);
 
-			LASSERT(cl_io_is_trunc(io));
+			LASSERT(cl_io_is_trunc(io) || cl_io_is_fallocate(io));
 			/* XXX: Need a lock. */
 			osd->od_stats.os_lockless_truncates++;
 		}
@@ -682,6 +703,25 @@ void osc_io_setattr_end(const struct lu_env *env,
 		osc_cache_truncate_end(env, oio->oi_trunc);
 		oio->oi_trunc = NULL;
 	}
+
+	if (cl_io_is_fallocate(io)) {
+		cl_object_attr_lock(obj);
+
+		/* update blocks */
+		if (oa->o_valid & OBD_MD_FLBLOCKS) {
+			attr->cat_blocks = oa->o_blocks;
+			cl_valid |= CAT_BLOCKS;
+		}
+
+		/* update size */
+		if (oa->o_valid & OBD_MD_FLSIZE) {
+			attr->cat_size = oa->o_size;
+			cl_valid |= CAT_SIZE;
+		}
+
+		cl_object_attr_update(env, obj, attr, cl_valid);
+		cl_object_attr_unlock(obj);
+	}
 }
 EXPORT_SYMBOL(osc_io_setattr_end);
 
diff --git a/fs/lustre/osc/osc_request.c b/fs/lustre/osc/osc_request.c
index 4db249e..b1bf8c6 100644
--- a/fs/lustre/osc/osc_request.c
+++ b/fs/lustre/osc/osc_request.c
@@ -34,8 +34,8 @@
 #define DEBUG_SUBSYSTEM S_OSC
 
 #include <linux/workqueue.h>
+#include <linux/falloc.h>
 #include <linux/highmem.h>
-#include <linux/libcfs/libcfs_hash.h>
 #include <linux/sched/mm.h>
 
 #include <lustre_dlm.h>
@@ -427,6 +427,69 @@ int osc_punch_send(struct obd_export *exp, struct obdo *oa,
 }
 EXPORT_SYMBOL(osc_punch_send);
 
+/**
+ * osc_fallocate_base() - Handles fallocate request.
+ *
+ * @exp:	Export structure
+ * @oa:		Attributes passed to OSS from client (obdo structure)
+ * @upcall:	Primary & supplementary group information
+ * @cookie:	Exclusive identifier
+ * @rqset:	Request list.
+ * @mode:	Operation done on given range.
+ *
+ * osc_fallocate_base() - Handles fallocate requests only. Only block
+ * allocation or standard preallocate operation is supported currently.
+ * Other mode flags is not supported yet. ftruncate(2) or truncate(2)
+ * is supported via SETATTR request.
+ *
+ * Return: Non-zero on failure and O on success.
+ */
+int osc_fallocate_base(struct obd_export *exp, struct obdo *oa,
+		       obd_enqueue_update_f upcall, void *cookie, int mode)
+{
+	struct ptlrpc_request *req;
+	struct osc_setattr_args *sa;
+	struct ost_body *body;
+	struct obd_import *imp = class_exp2cliimp(exp);
+	int rc;
+
+	/*
+	 * Only mode == 0 (which is standard prealloc) is supported now.
+	 * Punch is not supported yet.
+	 */
+	if (mode & ~FALLOC_FL_KEEP_SIZE)
+		return -EOPNOTSUPP;
+	oa->o_falloc_mode = mode;
+
+	req = ptlrpc_request_alloc(class_exp2cliimp(exp),
+				   &RQF_OST_FALLOCATE);
+	if (!req)
+		return -ENOMEM;
+
+	rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_FALLOCATE);
+	if (rc != 0) {
+		ptlrpc_request_free(req);
+		return rc;
+	}
+
+	body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
+	LASSERT(body);
+
+	lustre_set_wire_obdo(&imp->imp_connect_data, &body->oa, oa);
+
+	ptlrpc_request_set_replen(req);
+
+	req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret;
+	BUILD_BUG_ON(sizeof(*sa) > sizeof(req->rq_async_args));
+	sa = ptlrpc_req_async_args(sa, req);
+	sa->sa_oa = oa;
+	sa->sa_upcall = upcall;
+	sa->sa_cookie = cookie;
+
+	ptlrpcd_add_req(req);
+	return 0;
+}
+
 static int osc_sync_interpret(const struct lu_env *env,
 			      struct ptlrpc_request *req,
 			      void *arg, int rc)
diff --git a/fs/lustre/ptlrpc/layout.c b/fs/lustre/ptlrpc/layout.c
index 832c896..754c87d 100644
--- a/fs/lustre/ptlrpc/layout.c
+++ b/fs/lustre/ptlrpc/layout.c
@@ -757,6 +757,7 @@
 	&RQF_OST_SETATTR,
 	&RQF_OST_CREATE,
 	&RQF_OST_PUNCH,
+	&RQF_OST_FALLOCATE,
 	&RQF_OST_SYNC,
 	&RQF_OST_DESTROY,
 	&RQF_OST_BRW_READ,
@@ -1595,6 +1596,10 @@ struct req_format RQF_OST_PUNCH =
 	DEFINE_REQ_FMT0("OST_PUNCH", ost_body_capa, ost_body_only);
 EXPORT_SYMBOL(RQF_OST_PUNCH);
 
+struct req_format RQF_OST_FALLOCATE =
+	DEFINE_REQ_FMT0("OST_FALLOCATE", ost_body_capa, ost_body_only);
+EXPORT_SYMBOL(RQF_OST_FALLOCATE);
+
 struct req_format RQF_OST_SYNC =
 	DEFINE_REQ_FMT0("OST_SYNC", ost_body_capa, ost_body_only);
 EXPORT_SYMBOL(RQF_OST_SYNC);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 31/45] lustre: llite: fix possible divide zero in ll_use_fast_io()
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (29 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 30/45] lustre: fallocate: Implement fallocate preallocate operation James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 32/45] lustre: llog: allow delete of zero size llog James Simmons
                   ` (14 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Wang Shilong <wshilong@ddn.com>

ll_use_fast_io() is used to check wheather we could use fast IO.
Since it is called in fast path, we don't hold ras_lock to protect
access, there might have the race @ras_stride_bytes is reset after
stride_io_mode() check.

Fixes: 52fa1b524a84 ("lustre: llite: try fast io for stride io correctly")
WC-bug-id: https://jira.whamcloud.com/browse/LU-13541
Lustre-commit: 7cd0afe58321 ("LU-13541 llite: fix possible divide zero in ll_use_fast_io()")
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/38545
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: James Nunez <jnunez@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/rw.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/lustre/llite/rw.c b/fs/lustre/llite/rw.c
index 9e004f4..fd0bed6 100644
--- a/fs/lustre/llite/rw.c
+++ b/fs/lustre/llite/rw.c
@@ -1609,10 +1609,11 @@ static bool ll_use_fast_io(struct file *file,
 	unsigned long fast_read_pages =
 		max(RA_REMAIN_WINDOW_MIN, ras->ras_rpc_pages);
 	loff_t skip_pages;
+	loff_t stride_bytes = ras->ras_stride_bytes;
 
-	if (stride_io_mode(ras)) {
+	if (stride_io_mode(ras) && stride_bytes) {
 		skip_pages = (ras->ras_stride_length +
-			ras->ras_stride_bytes - 1) / ras->ras_stride_bytes;
+			ras->ras_stride_bytes - 1) / stride_bytes;
 		skip_pages *= fast_read_pages;
 	} else {
 		skip_pages = fast_read_pages;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 32/45] lustre: llog: allow delete of zero size llog
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (30 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 31/45] lustre: llite: fix possible divide zero in ll_use_fast_io() James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 33/45] lustre: ldlm: use proper units for timeouts James Simmons
                   ` (13 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Alexander Boyko <c17825@cray.com>

1) all plain logs belonging to catalog should have flag
LLOG_F_ZAP_WHEN_EMPTY base on llog_cat_new_log(). When
llog_cat_process_common processing plain log with zero file size,
this flag is not set during llog_cat_id2handle LLOG_EMPTY, so these
plain llogs are not canceled/destroyed. They appeared during cross
MDT updates. Fix adds flag LLOG_F_ZAP_WHEN_EMPTY for any plain llog
at catalog.

Cray-bug-id: LUS-8634
WC-bug-id: https://jira.whamcloud.com/browse/LU-13411
Lustre-commit: bc7f8cfe0fc6a ("LU-13411 llog: allow delete of zero size llog")
Signed-off-by: Alexander Boyko <c17825@cray.com>
Reviewed-on: https://review.whamcloud.com/38131
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Alexander Zarochentsev <alexander.zarochentsev@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/obdclass/llog.c     | 9 +++++----
 fs/lustre/obdclass/llog_cat.c | 3 ++-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/lustre/obdclass/llog.c b/fs/lustre/obdclass/llog.c
index 28a79bb..b2667d9 100644
--- a/fs/lustre/obdclass/llog.c
+++ b/fs/lustre/obdclass/llog.c
@@ -472,6 +472,7 @@ int llog_process_or_fork(const struct lu_env *env,
 	struct llog_process_info *lpi;
 	struct llog_process_data *d = data;
 	struct llog_process_cat_data *cd = catdata;
+	u32 flags = loghandle->lgh_hdr->llh_flags;
 	int rc;
 
 	lpi = kzalloc(sizeof(*lpi), GFP_KERNEL);
@@ -484,10 +485,10 @@ int llog_process_or_fork(const struct lu_env *env,
 
 	CDEBUG(D_OTHER,
 	       "Processing " DFID " flags 0x%03x startcat %d startidx %d first_idx %d last_idx %d\n",
-	       PFID(&loghandle->lgh_id.lgl_oi.oi_fid),
-	       loghandle->lgh_hdr->llh_flags, d ? d->lpd_startcat : -1,
-	       d ? d->lpd_startidx : -1, cd ? cd->lpcd_first_idx : -1,
-	       cd ? cd->lpcd_last_idx : -1);
+	       PFID(&loghandle->lgh_id.lgl_oi.oi_fid), flags,
+	       (flags & LLOG_F_IS_CAT) && d ? d->lpd_startcat : -1,
+	       (flags & LLOG_F_IS_CAT) && d ? d->lpd_startidx : -1,
+	       cd ? cd->lpcd_first_idx : -1, cd ? cd->lpcd_last_idx : -1);
 
 	if (fork) {
 		struct task_struct *task;
diff --git a/fs/lustre/obdclass/llog_cat.c b/fs/lustre/obdclass/llog_cat.c
index 46636f8..9298808 100644
--- a/fs/lustre/obdclass/llog_cat.c
+++ b/fs/lustre/obdclass/llog_cat.c
@@ -108,7 +108,8 @@ static int llog_cat_id2handle(const struct lu_env *env,
 		return rc;
 	}
 
-	rc = llog_init_handle(env, loghandle, fmt | LLOG_F_IS_PLAIN, NULL);
+	rc = llog_init_handle(env, loghandle, LLOG_F_IS_PLAIN |
+			      LLOG_F_ZAP_WHEN_EMPTY | fmt, NULL);
 	if (rc < 0) {
 		llog_close(env, loghandle);
 		*res = NULL;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 33/45] lustre: ldlm: use proper units for timeouts
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (31 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 32/45] lustre: llog: allow delete of zero size llog James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 34/45] lustre: dne: support directory restripe James Simmons
                   ` (12 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Andreas Dilger <adilger@whamcloud.com>

Use ktime_t for ns_dirty_age_limit internally, even though the user
interface is in seconds, since this is frequenty used together with
other ktime_t values in the kernel.

Fixes: fdeeed2fb547 ("lustre: ldlm: migrate the rest of the code to 64 bit time")
WC-bug-id: https://jira.whamcloud.com/browse/LU-12931
Lustre-commit: 3108bbb0b8485 ("LU-12931 ldlm: use proper units for timeouts")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38365
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/lustre_dlm.h | 15 +++++++++------
 fs/lustre/ldlm/ldlm_lockd.c    |  3 +--
 fs/lustre/ldlm/ldlm_resource.c |  7 ++++---
 fs/lustre/llite/namei.c        |  3 +--
 4 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/fs/lustre/include/lustre_dlm.h b/fs/lustre/include/lustre_dlm.h
index dda59d7..f67b612 100644
--- a/fs/lustre/include/lustre_dlm.h
+++ b/fs/lustre/include/lustre_dlm.h
@@ -415,15 +415,18 @@ struct ldlm_namespace {
 	 */
 	unsigned int		ns_max_unused;
 
-	/** Maximum allowed age (last used time) for locks in the LRU */
+	/** Maximum allowed age (last used time) for locks in the LRU. Set in
+	 * seconds from userspace, but stored in ns to avoid repeat conversions.
+	 */
 	ktime_t			ns_max_age;
 	/**
-	 * Number of seconds since the lock was last used. The client may
-	 * cancel the lock limited by this age and flush related data if
-	 * any other client shows interest in it doing glimpse request.
-	 * This allows to cache stat data locally for such files early.
+	 * Number of (nano)seconds since the lock was last used. The client
+	 * may cancel the lock older than this age and flush related data if
+	 * another client shows interest in this lock by doing glimpse request.
+	 * This allows to cache stat data locally for such files early. Set in
+	 * seconds from userspace, but stored in ns to avoid repeat conversions.
 	 */
-	time64_t		ns_dirty_age_limit;
+	ktime_t			ns_dirty_age_limit;
 	/**
 	 * Used to rate-limit ldlm_namespace_dump calls.
 	 * \see ldlm_namespace_dump. Increased by 10 seconds every time
diff --git a/fs/lustre/ldlm/ldlm_lockd.c b/fs/lustre/ldlm/ldlm_lockd.c
index bd5331d..7df7af2 100644
--- a/fs/lustre/ldlm/ldlm_lockd.c
+++ b/fs/lustre/ldlm/ldlm_lockd.c
@@ -378,8 +378,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
 	if (lock->l_granted_mode == LCK_PW &&
 	    !lock->l_readers && !lock->l_writers &&
 	    ktime_after(ktime_get(),
-			ktime_add(lock->l_last_used,
-				  ktime_set(ns->ns_dirty_age_limit, 0)))) {
+			ktime_add(lock->l_last_used, ns->ns_dirty_age_limit))) {
 		unlock_res_and_lock(lock);
 
 		/* For MDS glimpse it is always DOM lock, set corresponding
diff --git a/fs/lustre/ldlm/ldlm_resource.c b/fs/lustre/ldlm/ldlm_resource.c
index 0a3d861..a6572af 100644
--- a/fs/lustre/ldlm/ldlm_resource.c
+++ b/fs/lustre/ldlm/ldlm_resource.c
@@ -332,7 +332,8 @@ static ssize_t dirty_age_limit_show(struct kobject *kobj,
 	struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
 						 ns_kobj);
 
-	return sprintf(buf, "%llu\n", ns->ns_dirty_age_limit);
+	return scnprintf(buf, PAGE_SIZE, "%llu\n",
+			 ktime_divns(ns->ns_dirty_age_limit, NSEC_PER_SEC));
 }
 
 static ssize_t dirty_age_limit_store(struct kobject *kobj,
@@ -346,7 +347,7 @@ static ssize_t dirty_age_limit_store(struct kobject *kobj,
 	if (kstrtoull(buffer, 10, &tmp))
 		return -EINVAL;
 
-	ns->ns_dirty_age_limit = tmp;
+	ns->ns_dirty_age_limit = ktime_set(tmp, 0);
 
 	return count;
 }
@@ -646,7 +647,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
 	ns->ns_max_age = ktime_set(LDLM_DEFAULT_MAX_ALIVE, 0);
 	ns->ns_orig_connect_flags = 0;
 	ns->ns_connect_flags = 0;
-	ns->ns_dirty_age_limit = LDLM_DIRTY_AGE_LIMIT;
+	ns->ns_dirty_age_limit = ktime_set(LDLM_DIRTY_AGE_LIMIT, 0);
 	ns->ns_stopping = 0;
 	ns->ns_last_pos = &ns->ns_unused_list;
 
diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c
index 2ca6bd2..16c3bc5 100644
--- a/fs/lustre/llite/namei.c
+++ b/fs/lustre/llite/namei.c
@@ -418,8 +418,7 @@ int ll_md_need_convert(struct ldlm_lock *lock)
 	/* is lock is too old to be converted? */
 	lock_res_and_lock(lock);
 	if (ktime_after(ktime_get(),
-			ktime_add(lock->l_last_used,
-				  ktime_set(ns->ns_dirty_age_limit, 0)))) {
+			ktime_add(lock->l_last_used, ns->ns_dirty_age_limit))) {
 		unlock_res_and_lock(lock);
 		return 0;
 	}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 34/45] lustre: dne: support directory restripe
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (32 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 33/45] lustre: ldlm: use proper units for timeouts James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 35/45] lustre: osc: Do not wait for grants for too long James Simmons
                   ` (11 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Lai Siyao <lai.siyao@whamcloud.com>

This patch adds directory restripe support:
* 'lfs setdirstripe -m -1 -c <stripe_count>' on an existed directory
  will change this directory layout, if 'stripe_count' is larger than
  current count, new stripes are allocated after current stripes,
  otherwise merge stripes of this directory, NB, if stripe count is
  unchanged, but hash type changed, it's treated as merging, but
  rehashing actually.
* mdt_restripe() ia added to restripe directory.
* mdd_dir_declare_layout_split() is added to split directory, which
  handles both plain and striped directory split.
* lod_dir_declare_layout_split() will handle the internal of directory
  split.
* directory merge is simple compared to split, which just records
  target stripe count in LMV, and update it.

NB. this patch only restripe directory, but doesn't add the code to
migrate sub files, which will be implemented in the following patch.

WC-bug-id: https://jira.whamcloud.com/browse/LU-11025
Lustre-commit: 2e2b16c28bcf4 ("LU-11025 dne: support directory restripe")
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36898
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: Yingjin Qian <qian@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/lustre_lmv.h          | 90 ++++++++++++++++++++++++++++++---
 fs/lustre/lmv/lmv_obd.c                 | 57 ++++++++++++++-------
 fs/lustre/ptlrpc/wiretest.c             |  6 +++
 include/uapi/linux/lustre/lustre_user.h | 37 +++++++++++++-
 4 files changed, 166 insertions(+), 24 deletions(-)

diff --git a/fs/lustre/include/lustre_lmv.h b/fs/lustre/include/lustre_lmv.h
index 645eee3..0175816 100644
--- a/fs/lustre/include/lustre_lmv.h
+++ b/fs/lustre/include/lustre_lmv.h
@@ -68,7 +68,7 @@ static inline bool lmv_dir_foreign(const struct lmv_stripe_md *lsm)
 static inline bool lmv_dir_layout_changing(const struct lmv_stripe_md *lsm)
 {
 	return lmv_dir_striped(lsm) &&
-	       (lsm->lsm_md_hash_type & LMV_HASH_FLAG_LAYOUT_CHANGE);
+	       lmv_hash_is_layout_changing(lsm->lsm_md_hash_type);
 }
 
 static inline bool lmv_dir_bad_hash(const struct lmv_stripe_md *lsm)
@@ -275,6 +275,15 @@ static inline u32 crush_hash(u32 a, u32 b)
 	return idx;
 }
 
+/* directory layout may change in three ways:
+ * 1. directory migration, in its LMV source stripes are appended after
+ *    target stripes, @migrate_hash is source hash type, @migrate_offset is
+ *    target stripe count,
+ * 2. directory split, @migrate_hash is hash type before split,
+ *    @migrate_offset is stripe count before split.
+ * 3. directory merge, @migrate_hash is hash type after merge,
+ *    @migrate_offset is stripe count after merge.
+ */
 static inline int
 __lmv_name_to_stripe_index(u32 hash_type, u32 stripe_count,
 			   u32 migrate_hash, u32 migrate_offset,
@@ -287,7 +296,17 @@ static inline u32 crush_hash(u32 a, u32 b)
 	LASSERT(namelen > 0);
 	LASSERT(stripe_count > 0);
 
-	if (hash_type & LMV_HASH_FLAG_MIGRATION) {
+	if (lmv_hash_is_splitting(hash_type)) {
+		if (!new_layout) {
+			hash_type = migrate_hash;
+			stripe_count = migrate_offset;
+		}
+	} else if (lmv_hash_is_merging(hash_type)) {
+		if (new_layout) {
+			hash_type = migrate_hash;
+			stripe_count = migrate_offset;
+		}
+	} else if (lmv_hash_is_migrating(hash_type)) {
 		if (new_layout) {
 			stripe_count = migrate_offset;
 		} else {
@@ -317,12 +336,12 @@ static inline u32 crush_hash(u32 a, u32 b)
 
 	LASSERT(stripe_index < stripe_count);
 
-	if ((saved_hash & LMV_HASH_FLAG_MIGRATION) && !new_layout)
+	if (!new_layout && lmv_hash_is_migrating(saved_hash))
 		stripe_index += migrate_offset;
 
 	LASSERT(stripe_index < saved_count);
 
-	CDEBUG(D_INFO, "name %.*s hash %#x/%#x idx %d/%u/%u under %s layout\n",
+	CDEBUG(D_INFO, "name %.*s hash=%#x/%#x idx=%d/%u/%u under %s layout\n",
 	       namelen, name, saved_hash, migrate_hash, stripe_index,
 	       saved_count, migrate_offset, new_layout ? "new" : "old");
 
@@ -382,21 +401,25 @@ static inline bool lmv_user_magic_supported(u32 lum_magic)
 
 #define LMV_DEBUG(mask, lmv, msg)					\
 	CDEBUG(mask,							\
-	       "%s LMV: magic %#x count %u index %u hash %#x version %u migrate offset %u migrate hash %u.\n",\
+	       "%s LMV: magic=%#x count=%u index=%u hash=%#x version=%u migrate offset=%u migrate hash=%u.\n",\
 	       msg, (lmv)->lmv_magic, (lmv)->lmv_stripe_count,          \
 	       (lmv)->lmv_master_mdt_index, (lmv)->lmv_hash_type,       \
 	       (lmv)->lmv_layout_version, (lmv)->lmv_migrate_offset,    \
 	       (lmv)->lmv_migrate_hash)
 
+/* master LMV is sane */
 static inline bool lmv_is_sane(const struct lmv_mds_md_v1 *lmv)
 {
+	if (!lmv)
+		return false;
+
 	if (le32_to_cpu(lmv->lmv_magic) != LMV_MAGIC_V1)
 		goto insane;
 
 	if (le32_to_cpu(lmv->lmv_stripe_count) == 0)
 		goto insane;
 
-	if (!lmv_is_known_hash_type(lmv->lmv_hash_type))
+	if (!lmv_is_known_hash_type(le32_to_cpu(lmv->lmv_hash_type)))
 		goto insane;
 
 	return true;
@@ -405,4 +428,59 @@ static inline bool lmv_is_sane(const struct lmv_mds_md_v1 *lmv)
 	return false;
 }
 
+/* LMV can be either master or stripe LMV */
+static inline bool lmv_is_sane2(const struct lmv_mds_md_v1 *lmv)
+{
+	if (!lmv)
+		return false;
+
+	if (le32_to_cpu(lmv->lmv_magic) != LMV_MAGIC_V1 &&
+	    le32_to_cpu(lmv->lmv_magic) != LMV_MAGIC_STRIPE)
+		goto insane;
+
+	if (le32_to_cpu(lmv->lmv_stripe_count) == 0)
+		goto insane;
+
+	if (!lmv_is_known_hash_type(le32_to_cpu(lmv->lmv_hash_type)))
+		goto insane;
+
+	return true;
+insane:
+	LMV_DEBUG(D_ERROR, lmv, "insane");
+	return false;
+}
+
+static inline bool lmv_is_splitting(const struct lmv_mds_md_v1 *lmv)
+{
+	LASSERT(lmv_is_sane2(lmv));
+	return lmv_hash_is_splitting(cpu_to_le32(lmv->lmv_hash_type));
+}
+
+static inline bool lmv_is_merging(const struct lmv_mds_md_v1 *lmv)
+{
+	LASSERT(lmv_is_sane2(lmv));
+	return lmv_hash_is_merging(cpu_to_le32(lmv->lmv_hash_type));
+}
+
+static inline bool lmv_is_migrating(const struct lmv_mds_md_v1 *lmv)
+{
+	LASSERT(lmv_is_sane(lmv));
+	return lmv_hash_is_migrating(cpu_to_le32(lmv->lmv_hash_type));
+}
+
+static inline bool lmv_is_restriping(const struct lmv_mds_md_v1 *lmv)
+{
+	LASSERT(lmv_is_sane2(lmv));
+	return lmv_hash_is_splitting(cpu_to_le32(lmv->lmv_hash_type)) ||
+	       lmv_hash_is_merging(cpu_to_le32(lmv->lmv_hash_type));
+}
+
+static inline bool lmv_is_layout_changing(const struct lmv_mds_md_v1 *lmv)
+{
+	LASSERT(lmv_is_sane2(lmv));
+	return lmv_hash_is_splitting(cpu_to_le32(lmv->lmv_hash_type)) ||
+	       lmv_hash_is_merging(cpu_to_le32(lmv->lmv_hash_type)) ||
+	       lmv_hash_is_migrating(cpu_to_le32(lmv->lmv_hash_type));
+}
+
 #endif
diff --git a/fs/lustre/lmv/lmv_obd.c b/fs/lustre/lmv/lmv_obd.c
index f241269..bb60f64 100644
--- a/fs/lustre/lmv/lmv_obd.c
+++ b/fs/lustre/lmv/lmv_obd.c
@@ -1743,6 +1743,7 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
 	struct obd_device *obd = exp->exp_obd;
 	struct lmv_obd *lmv = &obd->u.lmv;
 	struct lmv_tgt_desc *tgt;
+	struct mdt_body *repbody;
 	int rc;
 
 	if (!lmv->lmv_mdt_descs.ltd_lmv_desc.ld_active_tgt_count)
@@ -1767,19 +1768,7 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
 	if (IS_ERR(tgt))
 		return PTR_ERR(tgt);
 
-	if (lmv_op_qos_mkdir(op_data)) {
-		tgt = lmv_locate_tgt_qos(lmv, &op_data->op_mds);
-		if (tgt == ERR_PTR(-EAGAIN))
-			tgt = lmv_locate_tgt_rr(lmv, &op_data->op_mds);
-		/*
-		 * only update statfs after QoS mkdir, this means the cached
-		 * statfs may be stale, and current mkdir may not follow QoS
-		 * accurately, but it's not serious, and avoids periodic statfs
-		 * when client doesn't mkdir by QoS.
-		 */
-		if (!IS_ERR(tgt))
-			lmv_statfs_check_update(obd, tgt);
-	} else if (lmv_op_user_specific_mkdir(op_data)) {
+	if (lmv_op_user_specific_mkdir(op_data)) {
 		struct lmv_user_md *lum = op_data->op_data;
 
 		op_data->op_mds = le32_to_cpu(lum->lum_stripe_offset);
@@ -1792,11 +1781,22 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
 		tgt = lmv_tgt(lmv, op_data->op_mds);
 		if (!tgt)
 			return -ENODEV;
+	} else if (lmv_op_qos_mkdir(op_data)) {
+		tgt = lmv_locate_tgt_qos(lmv, &op_data->op_mds);
+		if (tgt == ERR_PTR(-EAGAIN))
+			tgt = lmv_locate_tgt_rr(lmv, &op_data->op_mds);
+		if (IS_ERR(tgt))
+			return PTR_ERR(tgt);
+		/*
+		 * only update statfs after QoS mkdir, this means the cached
+		 * statfs may be stale, and current mkdir may not follow QoS
+		 * accurately, but it's not serious, and avoids periodic statfs
+		 * when client doesn't mkdir by QoS.
+		 */
+		lmv_statfs_check_update(obd, tgt);
 	}
 
-	if (IS_ERR(tgt))
-		return PTR_ERR(tgt);
-
+retry:
 	rc = lmv_fid_alloc(NULL, exp, &op_data->op_fid2, op_data);
 	if (rc)
 		return rc;
@@ -1816,7 +1816,30 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
 		CDEBUG(D_INODE, "Created - " DFID "\n",
 		       PFID(&op_data->op_fid2));
 	}
-	return rc;
+
+	/* dir restripe needs to send to MDT where dir is located */
+	if (rc != -EREMOTE ||
+	    !(exp_connect_flags2(exp) & OBD_CONNECT2_CRUSH))
+		return rc;
+
+	repbody = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY);
+	if (!repbody)
+		return -EPROTO;
+
+	/* Not cross-ref case, just get out of here. */
+	if (likely(!(repbody->mbo_valid & OBD_MD_MDS)))
+		return rc;
+
+	op_data->op_fid2 = repbody->mbo_fid1;
+	ptlrpc_req_finished(*request);
+	*request = NULL;
+
+	tgt = lmv_fid2tgt(lmv, &op_data->op_fid2);
+	if (IS_ERR(tgt))
+		return PTR_ERR(tgt);
+
+	op_data->op_mds = tgt->ltd_index;
+	goto retry;
 }
 
 static int
diff --git a/fs/lustre/ptlrpc/wiretest.c b/fs/lustre/ptlrpc/wiretest.c
index 8f824ee..dc1d0af 100644
--- a/fs/lustre/ptlrpc/wiretest.c
+++ b/fs/lustre/ptlrpc/wiretest.c
@@ -1760,6 +1760,10 @@ void lustre_assert_wire_constants(void)
 	BUILD_BUG_ON(LMV_MAGIC_V1 != 0x0CD20CD0);
 	BUILD_BUG_ON(LMV_MAGIC_STRIPE != 0x0CD40CD0);
 	BUILD_BUG_ON(LMV_HASH_TYPE_MASK != 0x0000ffff);
+	BUILD_BUG_ON(LMV_HASH_FLAG_MERGE != 0x04000000);
+	BUILD_BUG_ON(LMV_HASH_FLAG_SPLIT != 0x08000000);
+	BUILD_BUG_ON(LMV_HASH_FLAG_LOST_LMV != 0x10000000);
+	BUILD_BUG_ON(LMV_HASH_FLAG_BAD_TYPE != 0x20000000);
 	BUILD_BUG_ON(LMV_HASH_FLAG_MIGRATION != 0x80000000);
 	BUILD_BUG_ON(LMV_CRUSH_PG_COUNT != 4096);
 
@@ -2075,6 +2079,8 @@ void lustre_assert_wire_constants(void)
 		(unsigned int)MDS_OWNEROVERRIDE);
 	LASSERTF(MDS_HSM_RELEASE == 0x00001000UL, "found 0x%.8xUL\n",
 		(unsigned int)MDS_HSM_RELEASE);
+	LASSERTF(MDS_CLOSE_MIGRATE == 0x00002000UL, "found 0x%.8xUL\n",
+		(unsigned int)MDS_CLOSE_MIGRATE);
 	LASSERTF(MDS_CLOSE_LAYOUT_SWAP == 0x00004000UL, "found 0x%.8xUL\n",
 		(unsigned int)MDS_CLOSE_LAYOUT_SWAP);
 	LASSERTF(MDS_CLOSE_LAYOUT_MERGE == 0x00008000UL, "found 0x%.8xUL\n",
diff --git a/include/uapi/linux/lustre/lustre_user.h b/include/uapi/linux/lustre/lustre_user.h
index 4b7c89b..b255f14 100644
--- a/include/uapi/linux/lustre/lustre_user.h
+++ b/include/uapi/linux/lustre/lustre_user.h
@@ -706,6 +706,9 @@ static inline bool lmv_is_known_hash_type(__u32 type)
 	       (type & LMV_HASH_TYPE_MASK) == LMV_HASH_TYPE_CRUSH;
 }
 
+#define LMV_HASH_FLAG_MERGE		0x04000000
+#define LMV_HASH_FLAG_SPLIT		0x08000000
+
 /* The striped directory has ever lost its master LMV EA, then LFSCK
  * re-generated it. This flag is used to indicate such case. It is an
  * on-disk flag.
@@ -715,7 +718,39 @@ static inline bool lmv_is_known_hash_type(__u32 type)
 #define LMV_HASH_FLAG_BAD_TYPE		0x20000000
 #define LMV_HASH_FLAG_MIGRATION		0x80000000
 
-#define LMV_HASH_FLAG_LAYOUT_CHANGE	LMV_HASH_FLAG_MIGRATION
+#define LMV_HASH_FLAG_LAYOUT_CHANGE	\
+	(LMV_HASH_FLAG_MIGRATION | LMV_HASH_FLAG_SPLIT | LMV_HASH_FLAG_MERGE)
+
+/* both SPLIT and MIGRATION are set for directory split */
+static inline bool lmv_hash_is_splitting(__u32 hash)
+{
+	return (hash & LMV_HASH_FLAG_LAYOUT_CHANGE) ==
+		(LMV_HASH_FLAG_SPLIT | LMV_HASH_FLAG_MIGRATION);
+}
+
+/* both MERGE and MIGRATION are set for directory merge */
+static inline bool lmv_hash_is_merging(__u32 hash)
+{
+	return (hash & LMV_HASH_FLAG_LAYOUT_CHANGE) ==
+		(LMV_HASH_FLAG_MERGE | LMV_HASH_FLAG_MIGRATION);
+}
+
+/* only MIGRATION is set for directory migration */
+static inline bool lmv_hash_is_migrating(__u32 hash)
+{
+	return (hash & LMV_HASH_FLAG_LAYOUT_CHANGE) == LMV_HASH_FLAG_MIGRATION;
+}
+
+static inline bool lmv_hash_is_restriping(__u32 hash)
+{
+	return lmv_hash_is_splitting(hash) || lmv_hash_is_merging(hash);
+}
+
+static inline bool lmv_hash_is_layout_changing(__u32 hash)
+{
+	return lmv_hash_is_splitting(hash) || lmv_hash_is_merging(hash) ||
+	       lmv_hash_is_migrating(hash);
+}
 
 struct lustre_foreign_type {
 	__u32		lft_type;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 35/45] lustre: osc: Do not wait for grants for too long
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (33 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 34/45] lustre: dne: support directory restripe James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 36/45] lnet: use kmem_cache_zalloc as appropriate James Simmons
                   ` (10 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Oleg Drokin <green@whamcloud.com>

obd_timeout is way too long considering we are holding a lock
that might be contended. If OST is slow to respond, we might
get evicted, so limit us to a half of the shortest possible
max wait a server might have before switching to synchronous IO.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13131
Lustre-commit: 1eee11c75ca13 ("LU-13131 osc: Do not wait for grants for too long")
Signed-off-by: Oleg Drokin <green@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38283
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/lustre_dlm.h |  2 ++
 fs/lustre/ldlm/ldlm_request.c  |  1 +
 fs/lustre/osc/osc_cache.c      | 13 ++++++++++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/include/lustre_dlm.h b/fs/lustre/include/lustre_dlm.h
index f67b612..174b314 100644
--- a/fs/lustre/include/lustre_dlm.h
+++ b/fs/lustre/include/lustre_dlm.h
@@ -1320,6 +1320,8 @@ int ldlm_cli_cancel_list(struct list_head *head, int count,
 			 enum ldlm_cancel_flags flags);
 /** @} ldlm_cli_api */
 
+extern unsigned int ldlm_enqueue_min;
+
 int ldlm_inodebits_drop(struct ldlm_lock *lock, u64 to_drop);
 int ldlm_cli_inodebits_convert(struct ldlm_lock *lock,
 			       enum ldlm_cancel_flags cancel_flags);
diff --git a/fs/lustre/ldlm/ldlm_request.c b/fs/lustre/ldlm/ldlm_request.c
index 5f06def..12ee241 100644
--- a/fs/lustre/ldlm/ldlm_request.c
+++ b/fs/lustre/ldlm/ldlm_request.c
@@ -69,6 +69,7 @@
 unsigned int ldlm_enqueue_min = OBD_TIMEOUT_DEFAULT;
 module_param(ldlm_enqueue_min, uint, 0644);
 MODULE_PARM_DESC(ldlm_enqueue_min, "lock enqueue timeout minimum");
+EXPORT_SYMBOL(ldlm_enqueue_min);
 
 /* in client side, whether the cached locks will be canceled before replay */
 unsigned int ldlm_cancel_unused_locks_before_replay = 1;
diff --git a/fs/lustre/osc/osc_cache.c b/fs/lustre/osc/osc_cache.c
index 9e28ff6..c7f1502 100644
--- a/fs/lustre/osc/osc_cache.c
+++ b/fs/lustre/osc/osc_cache.c
@@ -39,6 +39,7 @@
 #define DEBUG_SUBSYSTEM S_OSC
 
 #include <lustre_osc.h>
+#include <lustre_dlm.h>
 
 #include "osc_internal.h"
 
@@ -1630,10 +1631,20 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli,
 {
 	struct osc_object *osc = oap->oap_obj;
 	struct lov_oinfo *loi = osc->oo_oinfo;
-	unsigned long timeout = (AT_OFF ? obd_timeout : at_max) * HZ;
 	int rc = -EDQUOT;
 	int remain;
 	bool entered = false;
+	/* We cannot wait for a long time here since we are holding ldlm lock
+	 * across the actual IO. If no requests complete fast (e.g. due to
+	 * overloaded OST that takes a long time to process everything, we'd
+	 * get evicted if we wait for a normal obd_timeout or some such.
+	 * So we try to wait half the time it would take the client to be
+	 * evicted by server which is half obd_timeout when AT is off
+	 * or at least ldlm_enqueue_min with AT on.
+	 * See LU-13131
+	 */
+	unsigned long timeout = (AT_OFF ? obd_timeout / 2 :
+					  ldlm_enqueue_min / 2) * HZ;
 
 	OSC_DUMP_GRANT(D_CACHE, cli, "need:%d\n", bytes);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 36/45] lnet: use kmem_cache_zalloc as appropriate.
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (34 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 35/45] lustre: osc: Do not wait for grants for too long James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 37/45] lustre: osc: Ensure immediate departure of sync write pages James Simmons
                   ` (9 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

Rather than passing __GFP_ZERO to kmem_cache_alloc(), or calling
memset(0) after the allocation, use kmem_cache_zalloc().

kmem_cache_zalloc() has been part of Linux since 2.6.17.

WC-bug-id: https://jira.whamcloud.com/browse/LU-6142
Lustre-commit: 3ceed00b0458d ("LU-6142 kernel: use kmem_cache_zalloc as appropriate.")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/38439
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/lnet/lib-me.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/lnet/lnet/lib-me.c b/net/lnet/lnet/lib-me.c
index 8a47405..14ab21f 100644
--- a/net/lnet/lnet/lib-me.c
+++ b/net/lnet/lnet/lib-me.c
@@ -87,7 +87,7 @@ struct lnet_me *
 	if (!mtable) /* can't match portal type */
 		return ERR_PTR(-EPERM);
 
-	me = kmem_cache_alloc(lnet_mes_cachep, GFP_NOFS | __GFP_ZERO);
+	me = kmem_cache_zalloc(lnet_mes_cachep, GFP_NOFS);
 	if (!me)
 		return ERR_PTR(-ENOMEM);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 37/45] lustre: osc: Ensure immediate departure of sync write pages
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (35 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 36/45] lnet: use kmem_cache_zalloc as appropriate James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 38/45] lnet: remove lnet_extract_iov() James Simmons
                   ` (8 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Oleg Drokin <green@whamcloud.com>

Except for the case of direct-io and server-lock, we are
hold potentially multiple locks that are next to impossible
to find and cross reference.
So instead just send it all right away - should only
be a factor in rare cases of out of quota or close to out
of space.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13131
Lustre-commit: 13b7cf4fabdd5 ("LU-13131 osc: Ensure immediate departure of sync write pages")
Signed-off-by: Oleg Drokin <green@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38453
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/osc/osc_cache.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/fs/lustre/osc/osc_cache.c b/fs/lustre/osc/osc_cache.c
index c7f1502..5049aaa 100644
--- a/fs/lustre/osc/osc_cache.c
+++ b/fs/lustre/osc/osc_cache.c
@@ -2015,7 +2015,6 @@ static unsigned int get_write_extents(struct osc_object *obj,
 	while ((ext = list_first_entry_or_null(&obj->oo_hp_exts,
 					       struct osc_extent,
 					       oe_link))) {
-		LASSERT(ext->oe_state == OES_CACHE);
 		if (!try_to_add_extent_for_io(cli, ext, &data))
 			return data.erd_page_count;
 		EASSERT(ext->oe_nr_pages <= data.erd_max_pages, ext);
@@ -2701,7 +2700,22 @@ int osc_queue_sync_pages(const struct lu_env *env, const struct cl_io *io,
 	/* Reuse the initial refcount for RPC, don't drop it */
 	osc_extent_state_set(ext, OES_LOCK_DONE);
 	if (!ext->oe_rw) { /* write */
-		list_add_tail(&ext->oe_link, &obj->oo_urgent_exts);
+		if (!ext->oe_srvlock && !ext->oe_dio) {
+			/* The most likely case here is from lack of grants
+			 * so we are either out of quota or out of space.
+			 * Since this means we are holding locks across
+			 * potentially multi-striped IO, we must send out
+			 * everything out instantly to avoid prolonged
+			 * waits resulting in lock eviction (likely since
+			 * the extended wait in osc_cache_enter() did not
+			 * yield any additional grant due to a timeout.
+			 * LU-13131
+			 */
+			ext->oe_hp = 1;
+			list_add_tail(&ext->oe_link, &obj->oo_hp_exts);
+		} else {
+			list_add_tail(&ext->oe_link, &obj->oo_urgent_exts);
+		}
 		osc_update_pending(obj, OBD_BRW_WRITE, page_count);
 	} else {
 		list_add_tail(&ext->oe_link, &obj->oo_reading_exts);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 38/45] lnet: remove lnet_extract_iov()
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (36 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 37/45] lustre: osc: Ensure immediate departure of sync write pages James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 39/45] lnet: simplify ksock_tx James Simmons
                   ` (7 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

The only place this is called, the src kvec is
NULL with length 0, so it returns 0.
So remove it.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13004
Lustre-commit: 571943f9cd090 ("LU-13004 lnet: remove lnet_extract_iov()")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/37848
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 include/linux/lnet/lib-lnet.h |  4 ----
 net/lnet/lnet/lib-move.c      | 49 -------------------------------------------
 2 files changed, 53 deletions(-)

diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h
index 01e8489..a4a323c 100644
--- a/include/linux/lnet/lib-lnet.h
+++ b/include/linux/lnet/lib-lnet.h
@@ -614,10 +614,6 @@ int lnet_delay_rule_list(int pos, struct lnet_fault_attr *attr,
 void lnet_counters_reset(void);
 
 unsigned int lnet_iov_nob(unsigned int niov, struct kvec *iov);
-int lnet_extract_iov(int dst_niov, struct kvec *dst,
-		     int src_niov, const struct kvec *src,
-		     unsigned int offset, unsigned int len);
-
 unsigned int lnet_kiov_nob(unsigned int niov, struct bio_vec *iov);
 int lnet_extract_kiov(int dst_niov, struct bio_vec *dst,
 		      int src_niov, const struct bio_vec *src,
diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c
index cf134b5..51b8191 100644
--- a/net/lnet/lnet/lib-move.c
+++ b/net/lnet/lnet/lib-move.c
@@ -364,55 +364,6 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 }
 EXPORT_SYMBOL(lnet_copy_kiov2iter);
 
-int
-lnet_extract_iov(int dst_niov, struct kvec *dst,
-		 int src_niov, const struct kvec *src,
-		 unsigned int offset, unsigned int len)
-{
-	/*
-	 * Initialise 'dst' to the subset of 'src' starting at 'offset',
-	 * for exactly 'len' bytes, and return the number of entries.
-	 * NB not destructive to 'src'
-	 */
-	unsigned int frag_len;
-	unsigned int niov;
-
-	if (!len)			/* no data => */
-		return 0;		/* no frags */
-
-	LASSERT(src_niov > 0);
-	while (offset >= src->iov_len) {	/* skip initial frags */
-		offset -= src->iov_len;
-		src_niov--;
-		src++;
-		LASSERT(src_niov > 0);
-	}
-
-	niov = 1;
-	for (;;) {
-		LASSERT(src_niov > 0);
-		LASSERT((int)niov <= dst_niov);
-
-		frag_len = src->iov_len - offset;
-		dst->iov_base = ((char *)src->iov_base) + offset;
-
-		if (len <= frag_len) {
-			dst->iov_len = len;
-			return niov;
-		}
-
-		dst->iov_len = frag_len;
-
-		len -= frag_len;
-		dst++;
-		src++;
-		niov++;
-		src_niov--;
-		offset = 0;
-	}
-}
-EXPORT_SYMBOL(lnet_extract_iov);
-
 unsigned int
 lnet_kiov_nob(unsigned int niov, struct bio_vec *kiov)
 {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 39/45] lnet: simplify ksock_tx.
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (37 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 38/45] lnet: remove lnet_extract_iov() James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 40/45] lnet: socklnd: discard tx_iov James Simmons
                   ` (6 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

The tx_frags union in 'struct ksock_tx' is largely unnecessary.  The
payload is always lnet_kiov_t, the only kvec is a header.  So replace
the union with just those two fields.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13004
Lustre-commit: 28ffde29603b1 ("LU-13004 lnet: simplify ksock_tx.")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/37850
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/klnds/socklnd/socklnd.h    | 13 +++----------
 net/lnet/klnds/socklnd/socklnd_cb.c |  8 ++++----
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/net/lnet/klnds/socklnd/socklnd.h b/net/lnet/klnds/socklnd/socklnd.h
index 2504e52..f85eb3c 100644
--- a/net/lnet/klnds/socklnd/socklnd.h
+++ b/net/lnet/klnds/socklnd/socklnd.h
@@ -291,18 +291,11 @@ struct ksock_tx {				/* transmit packet */
 	struct ksock_msg	tx_msg;		/* socklnd message buffer */
 	int			tx_desc_size;	/* size of this descriptor */
 	enum lnet_msg_hstatus	tx_hstatus;	/* health status of tx */
-	union {
-		struct {
-			struct kvec	iov;	/* virt hdr */
-			struct bio_vec	kiov[0];/* paged payload */
-		} paged;
-		struct {
-			struct kvec	iov[1];	/* virt hdr + payload */
-		} virt;
-	} tx_frags;
+	struct kvec		tx_hdr;		/* virt hdr */
+	struct bio_vec		tx_payload[0];	/* paged payload */
 };
 
-#define KSOCK_NOOP_TX_SIZE (offsetof(struct ksock_tx, tx_frags.paged.kiov[0]))
+#define KSOCK_NOOP_TX_SIZE (offsetof(struct ksock_tx, tx_payload[0]))
 
 /* network zero copy callback descriptor embedded in struct ksock_tx */
 
diff --git a/net/lnet/klnds/socklnd/socklnd_cb.c b/net/lnet/klnds/socklnd/socklnd_cb.c
index 83fcb28..b40fbf1 100644
--- a/net/lnet/klnds/socklnd/socklnd_cb.c
+++ b/net/lnet/klnds/socklnd/socklnd_cb.c
@@ -79,7 +79,7 @@ struct ksock_tx *
 	tx->tx_lnetmsg = NULL;
 	tx->tx_kiov = NULL;
 	tx->tx_nkiov = 0;
-	tx->tx_iov = tx->tx_frags.virt.iov;
+	tx->tx_iov = &tx->tx_hdr;
 	tx->tx_niov = 1;
 	tx->tx_nonblk = nonblk;
 
@@ -933,7 +933,7 @@ struct ksock_route *
 	LASSERT(!in_interrupt());
 
 	desc_size = offsetof(struct ksock_tx,
-			     tx_frags.paged.kiov[payload_niov]);
+			     tx_payload[payload_niov]);
 
 	if (lntmsg->msg_vmflush)
 		mpflag = memalloc_noreclaim_save();
@@ -950,8 +950,8 @@ struct ksock_route *
 	tx->tx_lnetmsg = lntmsg;
 
 	tx->tx_niov = 1;
-	tx->tx_iov = &tx->tx_frags.paged.iov;
-	tx->tx_kiov = tx->tx_frags.paged.kiov;
+	tx->tx_iov = &tx->tx_hdr;
+	tx->tx_kiov = tx->tx_payload;
 	tx->tx_nkiov = lnet_extract_kiov(payload_niov, tx->tx_kiov,
 					 payload_niov, payload_kiov,
 					 payload_offset, payload_nob);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 40/45] lnet: socklnd: discard tx_iov.
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (38 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 39/45] lnet: simplify ksock_tx James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 41/45] lustre: lmv: do not print MDTs that are inactive James Simmons
                   ` (5 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Mr NeilBrown <neilb@suse.de>

tx_iov always points to tx_hdr, so we can discard tx_iov, and just use
&tx_hdr.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13004
Lustre-commit: 89637985b9897 ("LU-13004 socklnd: discard tx_iov.")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/37851
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/klnds/socklnd/socklnd.h       |  3 +--
 net/lnet/klnds/socklnd/socklnd_cb.c    | 33 ++++++++++++++-------------------
 net/lnet/klnds/socklnd/socklnd_lib.c   | 32 +++++++++++++-------------------
 net/lnet/klnds/socklnd/socklnd_proto.c | 10 +++++-----
 4 files changed, 33 insertions(+), 45 deletions(-)

diff --git a/net/lnet/klnds/socklnd/socklnd.h b/net/lnet/klnds/socklnd/socklnd.h
index f85eb3c..6c77b75 100644
--- a/net/lnet/klnds/socklnd/socklnd.h
+++ b/net/lnet/klnds/socklnd/socklnd.h
@@ -277,7 +277,6 @@ struct ksock_tx {				/* transmit packet */
 	int			tx_nob;		/* # packet bytes */
 	int			tx_resid;	/* residual bytes */
 	int			tx_niov;	/* # packet iovec frags */
-	struct kvec		*tx_iov;	/* packet iovec frags */
 	int			tx_nkiov;	/* # packet page frags */
 	unsigned short		tx_zc_aborted;	/* aborted ZC request */
 	unsigned short		tx_zc_capable:1;/* payload is large enough for ZC */
@@ -675,7 +674,7 @@ int ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn,
 void ksocknal_lib_push_conn(struct ksock_conn *conn);
 int ksocknal_lib_get_conn_addrs(struct ksock_conn *conn);
 int ksocknal_lib_setup_sock(struct socket *so);
-int ksocknal_lib_send_iov(struct ksock_conn *conn, struct ksock_tx *tx);
+int ksocknal_lib_send_hdr(struct ksock_conn *conn, struct ksock_tx *tx);
 int ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx);
 void ksocknal_lib_eager_ack(struct ksock_conn *conn);
 int ksocknal_lib_recv(struct ksock_conn *conn);
diff --git a/net/lnet/klnds/socklnd/socklnd_cb.c b/net/lnet/klnds/socklnd/socklnd_cb.c
index b40fbf1..c03f91c7 100644
--- a/net/lnet/klnds/socklnd/socklnd_cb.c
+++ b/net/lnet/klnds/socklnd/socklnd_cb.c
@@ -79,7 +79,6 @@ struct ksock_tx *
 	tx->tx_lnetmsg = NULL;
 	tx->tx_kiov = NULL;
 	tx->tx_nkiov = 0;
-	tx->tx_iov = &tx->tx_hdr;
 	tx->tx_niov = 1;
 	tx->tx_nonblk = nonblk;
 
@@ -109,16 +108,16 @@ struct ksock_tx *
 }
 
 static int
-ksocknal_send_iov(struct ksock_conn *conn, struct ksock_tx *tx)
+ksocknal_send_hdr(struct ksock_conn *conn, struct ksock_tx *tx)
 {
-	struct kvec *iov = tx->tx_iov;
+	struct kvec *iov = &tx->tx_hdr;
 	int nob;
 	int rc;
 
 	LASSERT(tx->tx_niov > 0);
 
-	/* Never touch tx->tx_iov inside ksocknal_lib_send_iov() */
-	rc = ksocknal_lib_send_iov(conn, tx);
+	/* Never touch tx->tx_hdr inside ksocknal_lib_send_hdr() */
+	rc = ksocknal_lib_send_hdr(conn, tx);
 
 	if (rc <= 0)			/* sent nothing? */
 		return rc;
@@ -128,19 +127,16 @@ struct ksock_tx *
 	tx->tx_resid -= nob;
 
 	/* "consume" iov */
-	do {
-		LASSERT(tx->tx_niov > 0);
+	LASSERT(tx->tx_niov == 1);
 
-		if (nob < (int)iov->iov_len) {
-			iov->iov_base = (void *)((char *)iov->iov_base + nob);
-			iov->iov_len -= nob;
-			return rc;
-		}
+	if (nob < (int)iov->iov_len) {
+		iov->iov_base += nob;
+		iov->iov_len -= nob;
+		return rc;
+	}
 
-		nob -= iov->iov_len;
-		tx->tx_iov = ++iov;
-		tx->tx_niov--;
-	} while (nob);
+	LASSERT(nob == iov->iov_len);
+	tx->tx_niov--;
 
 	return rc;
 }
@@ -207,7 +203,7 @@ struct ksock_tx *
 			ksocknal_data.ksnd_enomem_tx--;
 			rc = -EAGAIN;
 		} else if (tx->tx_niov) {
-			rc = ksocknal_send_iov(conn, tx);
+			rc = ksocknal_send_hdr(conn, tx);
 		} else {
 			rc = ksocknal_send_kiov(conn, tx);
 		}
@@ -694,7 +690,7 @@ struct ksock_conn *
 	 * We always expect at least 1 mapped fragment containing the
 	 * complete ksocknal message header.
 	 */
-	LASSERT(lnet_iov_nob(tx->tx_niov, tx->tx_iov) +
+	LASSERT(lnet_iov_nob(tx->tx_niov, &tx->tx_hdr) +
 		lnet_kiov_nob(tx->tx_nkiov, tx->tx_kiov) ==
 		(unsigned int)tx->tx_nob);
 	LASSERT(tx->tx_niov >= 1);
@@ -950,7 +946,6 @@ struct ksock_route *
 	tx->tx_lnetmsg = lntmsg;
 
 	tx->tx_niov = 1;
-	tx->tx_iov = &tx->tx_hdr;
 	tx->tx_kiov = tx->tx_payload;
 	tx->tx_nkiov = lnet_extract_kiov(payload_niov, tx->tx_kiov,
 					 payload_niov, payload_kiov,
diff --git a/net/lnet/klnds/socklnd/socklnd_lib.c b/net/lnet/klnds/socklnd/socklnd_lib.c
index 251c28f..2adc99c 100644
--- a/net/lnet/klnds/socklnd/socklnd_lib.c
+++ b/net/lnet/klnds/socklnd/socklnd_lib.c
@@ -73,11 +73,11 @@
 }
 
 int
-ksocknal_lib_send_iov(struct ksock_conn *conn, struct ksock_tx *tx)
+ksocknal_lib_send_hdr(struct ksock_conn *conn, struct ksock_tx *tx)
 {
 	struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
 	struct socket *sock = conn->ksnc_sock;
-	int nob, i;
+	int nob = 0;
 
 	if (*ksocknal_tunables.ksnd_enable_csum	&&		/* checksum enabled */
 	    conn->ksnc_proto == &ksocknal_protocol_v2x &&	/* V2.x connection */
@@ -85,15 +85,15 @@
 	    !tx->tx_msg.ksm_csum)				/* not checksummed */
 		ksocknal_lib_csum_tx(tx);
 
-	for (nob = i = 0; i < tx->tx_niov; i++)
-		nob += tx->tx_iov[i].iov_len;
+	if (tx->tx_niov)
+		nob += tx->tx_hdr.iov_len;
 
 	if (!list_empty(&conn->ksnc_tx_queue) ||
 	    nob < tx->tx_resid)
 		msg.msg_flags |= MSG_MORE;
 
 	iov_iter_kvec(&msg.msg_iter, WRITE,
-		      tx->tx_iov, tx->tx_niov, nob);
+		      &tx->tx_hdr, tx->tx_niov, nob);
 	return sock_sendmsg(sock, &msg);
 }
 
@@ -208,28 +208,22 @@ static int lustre_csum(struct kvec *v, void *context)
 	u32 csum;
 	void *base;
 
-	LASSERT(tx->tx_iov[0].iov_base == &tx->tx_msg);
+	LASSERT(tx->tx_hdr.iov_base == &tx->tx_msg);
 	LASSERT(tx->tx_conn);
 	LASSERT(tx->tx_conn->ksnc_proto == &ksocknal_protocol_v2x);
 
 	tx->tx_msg.ksm_csum = 0;
 
-	csum = crc32_le(~0, tx->tx_iov[0].iov_base,
-			tx->tx_iov[0].iov_len);
+	csum = crc32_le(~0, tx->tx_hdr.iov_base,
+			tx->tx_hdr.iov_len);
 
-	if (tx->tx_kiov) {
-		for (i = 0; i < tx->tx_nkiov; i++) {
-			base = kmap(tx->tx_kiov[i].bv_page) +
-			       tx->tx_kiov[i].bv_offset;
+	for (i = 0; i < tx->tx_nkiov; i++) {
+		base = kmap(tx->tx_kiov[i].bv_page) +
+		       tx->tx_kiov[i].bv_offset;
 
-			csum = crc32_le(csum, base, tx->tx_kiov[i].bv_len);
+		csum = crc32_le(csum, base, tx->tx_kiov[i].bv_len);
 
-			kunmap(tx->tx_kiov[i].bv_page);
-		}
-	} else {
-		for (i = 1; i < tx->tx_niov; i++)
-			csum = crc32_le(csum, tx->tx_iov[i].iov_base,
-					tx->tx_iov[i].iov_len);
+		kunmap(tx->tx_kiov[i].bv_page);
 	}
 
 	if (*ksocknal_tunables.ksnd_inject_csum_error) {
diff --git a/net/lnet/klnds/socklnd/socklnd_proto.c b/net/lnet/klnds/socklnd/socklnd_proto.c
index 183bb39..bc9f349 100644
--- a/net/lnet/klnds/socklnd/socklnd_proto.c
+++ b/net/lnet/klnds/socklnd/socklnd_proto.c
@@ -711,8 +711,8 @@
 	LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
 	LASSERT(tx->tx_lnetmsg);
 
-	tx->tx_iov[0].iov_base = &tx->tx_lnetmsg->msg_hdr;
-	tx->tx_iov[0].iov_len = sizeof(struct lnet_hdr);
+	tx->tx_hdr.iov_base = &tx->tx_lnetmsg->msg_hdr;
+	tx->tx_hdr.iov_len = sizeof(struct lnet_hdr);
 
 	tx->tx_nob = tx->tx_lnetmsg->msg_len + sizeof(struct lnet_hdr);
 	tx->tx_resid = tx->tx_lnetmsg->msg_len + sizeof(struct lnet_hdr);
@@ -721,19 +721,19 @@
 static void
 ksocknal_pack_msg_v2(struct ksock_tx *tx)
 {
-	tx->tx_iov[0].iov_base = &tx->tx_msg;
+	tx->tx_hdr.iov_base = &tx->tx_msg;
 
 	if (tx->tx_lnetmsg) {
 		LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
 
 		tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr;
-		tx->tx_iov[0].iov_len = sizeof(struct ksock_msg);
+		tx->tx_hdr.iov_len = sizeof(struct ksock_msg);
 		tx->tx_nob = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len;
 		tx->tx_resid = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len;
 	} else {
 		LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
 
-		tx->tx_iov[0].iov_len = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr);
+		tx->tx_hdr.iov_len = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr);
 		tx->tx_nob = offsetof(struct ksock_msg,  ksm_u.lnetmsg.ksnm_hdr);
 		tx->tx_resid = offsetof(struct ksock_msg,  ksm_u.lnetmsg.ksnm_hdr);
 	}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 41/45] lustre: lmv: do not print MDTs that are inactive
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (39 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 40/45] lnet: socklnd: discard tx_iov James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 42/45] lnet: use the same src nid for discovery James Simmons
                   ` (4 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Andreas Dilger <adilger@whamcloud.com>

Have lmv return -EAGAIN instead of -ENODATA for unconfigured MDTs.
That avoids "lfs df -v" from printing a long list of invalid MDTs
when trying to get the target state for non-rotational devices.

Add test for "lfs df -v" printing nonrotational state, as well as
limiting the reported OST and MDT to configured devices.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13427
Lustre-commit: 3728c2825aa27 ("LU-13427 lmv: do not print MDTs that are inactive")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38165
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Ben Evans <beevans@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/lmv/lmv_obd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/lmv/lmv_obd.c b/fs/lustre/lmv/lmv_obd.c
index bb60f64..4583cea 100644
--- a/fs/lustre/lmv/lmv_obd.c
+++ b/fs/lustre/lmv/lmv_obd.c
@@ -820,7 +820,10 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
 			return -ENODEV;
 
 		tgt = lmv_tgt(lmv, index);
-		if (!tgt || !tgt->ltd_active)
+		if (!tgt)
+			return -EAGAIN;
+
+		if (!tgt->ltd_active)
 			return -ENODATA;
 
 		mdc_obd = class_exp2obd(tgt->ltd_exp);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 42/45] lnet: use the same src nid for discovery
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (40 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 41/45] lustre: lmv: do not print MDTs that are inactive James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 43/45] lustre: llite: check if page truncated in ll_write_begin() James Simmons
                   ` (3 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Amir Shehata <ashehata@whamcloud.com>

When discovering a remote peer (not on the same network) a GET is
sent to the peer to retrieve the peer's interfaces.  This is followed
by a PUSH, if discovery is on, to push the node's interfaces However,
if both node and peer have multiple interfaces it is likely that the
GET and the PUSH will originate on different interfaces. When the
peer receives the PUSH it will not be able to connect the two NIDs
and will not be able to consolidate the node's NIDs.  This issue is
specific for remote peers because at the time the push handler is
invoked the remote lpni has not been created yet. lnet_parse()
creates the lpni of the gateway.

Similar to the strategy already in place of using the same source NID
for all the messages of an RPC, discovery should use the same source
NID for both the GET and PUSH.

This patch stores the source NID interfaces the GET was sent on and
uses it for the PUSH.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13471
Lustre-commit: 71ca66bcd9c3a ("LU-13471 lnet: use the same src nid for discovery")
Signed-off-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38320
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 include/linux/lnet/lib-types.h |  3 +++
 net/lnet/lnet/peer.c           | 11 ++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/linux/lnet/lib-types.h b/include/linux/lnet/lib-types.h
index f78b372..6aa691e 100644
--- a/include/linux/lnet/lib-types.h
+++ b/include/linux/lnet/lib-types.h
@@ -578,6 +578,9 @@ struct lnet_peer {
 	/* primary NID of the peer */
 	lnet_nid_t		lp_primary_nid;
 
+	/* source NID to use during discovery */
+	lnet_nid_t		lp_disc_src_nid;
+
 	/* net to perform discovery on */
 	u32			lp_disc_net_id;
 
diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c
index 1b9190b..ae70033 100644
--- a/net/lnet/lnet/peer.c
+++ b/net/lnet/lnet/peer.c
@@ -216,6 +216,7 @@
 	init_waitqueue_head(&lp->lp_dc_waitq);
 	spin_lock_init(&lp->lp_lock);
 	lp->lp_primary_nid = nid;
+	lp->lp_disc_src_nid = LNET_NID_ANY;
 	if (lnet_peers_start_down())
 		lp->lp_alive = false;
 	else
@@ -2271,6 +2272,8 @@ static void lnet_peer_clear_discovery_error(struct lnet_peer *lp)
 
 	spin_lock(&lp->lp_lock);
 
+	lp->lp_disc_src_nid = ev->target.nid;
+
 	/*
 	 * If some kind of error happened the contents of message
 	 * cannot be used. Set PING_FAILED to trigger a retry.
@@ -3088,9 +3091,15 @@ static int lnet_peer_send_push(struct lnet_peer *lp)
 		goto fail_unlink;
 	}
 
-	rc = LNetPut(LNET_NID_ANY, lp->lp_push_mdh,
+	rc = LNetPut(lp->lp_disc_src_nid, lp->lp_push_mdh,
 		     LNET_ACK_REQ, id, LNET_RESERVED_PORTAL,
 		     LNET_PROTO_PING_MATCHBITS, 0, 0);
+	/* reset the discovery nid. There is no need to restrict sending
+	 * from that source, if we call lnet_push_update_to_peers(). It'll
+	 * get set to a specific NID, if we initiate discovery from the
+	 * scratch
+	 */
+	lp->lp_disc_src_nid = LNET_NID_ANY;
 	if (rc)
 		goto fail_unlink;
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 43/45] lustre: llite: check if page truncated in ll_write_begin()
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (41 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 42/45] lnet: use the same src nid for discovery James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 44/45] lustre: dne: improve temp file name check James Simmons
                   ` (2 subsequent siblings)
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Wang Shilong <wshilong@ddn.com>

See following function flows:

CPU0					CPU1:
|->grab_cache_page_nowait
  |->find_get_page
    |->__find_get_page (page unlocked)
					|->truncate page
    |->trylock_page -->page might has been truncated after

So it is possible that page might has been truncated after
grab_cache_page_nowait() return even page lock is held.

We need check wheather vmpage->mapping change in ll_write_begin()
otherwise, we will have truncated page with NULL mapping, which
will trigger assertions in vvp_set_pagevec_dirty().

This patch also fix assertion string doesn't end in newline.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13493
Lustre-commit: 985de582849df ("LU-13493 llite: check if page truncated in ll_write_begin()")
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/38425
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/rw26.c   | 16 +++++++++++++---
 fs/lustre/llite/vvp_io.c |  2 +-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/fs/lustre/llite/rw26.c b/fs/lustre/llite/rw26.c
index dd388b9..7abf3fc 100644
--- a/fs/lustre/llite/rw26.c
+++ b/fs/lustre/llite/rw26.c
@@ -453,11 +453,12 @@ static int ll_prepare_partial_page(const struct lu_env *env, struct cl_io *io,
 	return result;
 }
 
-static int ll_tiny_write_begin(struct page *vmpage)
+static int ll_tiny_write_begin(struct page *vmpage,
+			       struct address_space *mapping)
 {
 	/* Page must be present, up to date, dirty, and not in writeback. */
 	if (!vmpage || !PageUptodate(vmpage) || !PageDirty(vmpage) ||
-	    PageWriteback(vmpage))
+	    PageWriteback(vmpage) || vmpage->mapping != mapping)
 		return -ENODATA;
 
 	return 0;
@@ -483,7 +484,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
 	lcc = ll_cl_find(file);
 	if (!lcc) {
 		vmpage = grab_cache_page_nowait(mapping, index);
-		result = ll_tiny_write_begin(vmpage);
+		result = ll_tiny_write_begin(vmpage, mapping);
 		goto out;
 	}
 
@@ -547,6 +548,15 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
 		}
 	}
 
+	/* page was truncated */
+	if (mapping != vmpage->mapping) {
+		CDEBUG(D_VFSTRACE, "page: %lu was truncated\n", index);
+		unlock_page(vmpage);
+		put_page(vmpage);
+		vmpage = NULL;
+		goto again;
+	}
+
 	page = cl_page_find(env, clob, vmpage->index, vmpage, CPT_CACHEABLE);
 	if (IS_ERR(page)) {
 		result = PTR_ERR(page);
diff --git a/fs/lustre/llite/vvp_io.c b/fs/lustre/llite/vvp_io.c
index d755551..371d988 100644
--- a/fs/lustre/llite/vvp_io.c
+++ b/fs/lustre/llite/vvp_io.c
@@ -899,7 +899,7 @@ void vvp_set_pagevec_dirty(struct pagevec *pvec)
 		ClearPageReclaim(pvec->pages[i]);
 
 	LASSERTF(page->mapping,
-		 "mapping must be set. page %p, page->private (cl_page) %p",
+		 "mapping must be set. page %p, page->private (cl_page) %p\n",
 		 page, (void *) page->private);
 
 	/* Rest of code derived from __set_page_dirty_nobuffers */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 44/45] lustre: dne: improve temp file name check
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (42 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 43/45] lustre: llite: check if page truncated in ll_write_begin() James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-25 22:08 ` [lustre-devel] [PATCH 45/45] lustre: all: Cleanup LASSERTF uses missing newlines James Simmons
  2020-05-29  6:29 ` [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today NeilBrown
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Lai Siyao <lai.siyao@whamcloud.com>

Previously if all but two characters in file name suffix are digit,
it's not treated as temp file, as is too strict if suffix length is
short, e.g. 6. Change it to allow one character, and this non-digit
character should not be the starting character.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13481
Lustre-commit: 51e5749683838 ("LU-13481 dne: improve temp file name check")
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38539
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/lu_object.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/include/lu_object.h b/fs/lustre/include/lu_object.h
index 718fdb8..6886177 100644
--- a/fs/lustre/include/lu_object.h
+++ b/fs/lustre/include/lu_object.h
@@ -1309,7 +1309,8 @@ static inline bool lu_name_is_temp_file(const char *name, int namelen,
 	 * About 0.07% of randomly-generated names will slip through,
 	 * but this avoids 99.93% of cross-MDT renames for those files.
 	 */
-	if (digit >= suffixlen - 2 || upper == suffixlen || lower == suffixlen)
+	if ((digit >= suffixlen - 1 && !isdigit(name[namelen - suffixlen])) ||
+	    upper == suffixlen || lower == suffixlen)
 		return false;
 
 	return true;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 45/45] lustre: all: Cleanup LASSERTF uses missing newlines
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (43 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 44/45] lustre: dne: improve temp file name check James Simmons
@ 2020-05-25 22:08 ` James Simmons
  2020-05-29  6:29 ` [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today NeilBrown
  45 siblings, 0 replies; 54+ messages in thread
From: James Simmons @ 2020-05-25 22:08 UTC (permalink / raw)
  To: lustre-devel

From: Shaun Tancheff <shaun.tancheff@hpe.com>

LASSERTF() usage that does not include a terminating newline
present an unclear syslog entry from admins.

This adds the terminating newline for a few cases.

HPE-bug-id: LUS-8853
WC-bug-id: https://jira.whamcloud.com/browse/LU-13539
Lustre-commit: 74f8e405b2c9d ("LU-13539 all: Cleanup LASSERTF uses missing newlines")
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-on: https://review.whamcloud.com/38540
Reviewed-by: Arshad Hussain <arshad.super@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/lov/lov_cl_internal.h | 6 ++++--
 fs/lustre/ptlrpc/client.c       | 2 +-
 fs/lustre/ptlrpc/import.c       | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/lustre/lov/lov_cl_internal.h b/fs/lustre/lov/lov_cl_internal.h
index e21439d..9dd523f 100644
--- a/fs/lustre/lov/lov_cl_internal.h
+++ b/fs/lustre/lov/lov_cl_internal.h
@@ -342,7 +342,8 @@ static inline struct lov_layout_raid0 *lov_r0(struct lov_object *lov, int i)
 {
 	LASSERT(lov->lo_type == LLT_COMP);
 	LASSERTF(i < lov->u.composite.lo_entry_count,
-		 "entry %d entry_count %d", i, lov->u.composite.lo_entry_count);
+		 "entry %d entry_count %d\n", i,
+		 lov->u.composite.lo_entry_count);
 
 	return &lov->u.composite.lo_entries[i].lle_raid0;
 }
@@ -372,7 +373,8 @@ static inline struct lov_layout_entry *lov_entry(struct lov_object *lov, int i)
 {
 	LASSERT(lov->lo_type == LLT_COMP);
 	LASSERTF(i < lov->u.composite.lo_entry_count,
-		 "entry %d entry_count %d", i, lov->u.composite.lo_entry_count);
+		 "entry %d entry_count %d\n", i,
+		 lov->u.composite.lo_entry_count);
 
 	return &lov->u.composite.lo_entries[i];
 }
diff --git a/fs/lustre/ptlrpc/client.c b/fs/lustre/ptlrpc/client.c
index 0c13145..4865b04 100644
--- a/fs/lustre/ptlrpc/client.c
+++ b/fs/lustre/ptlrpc/client.c
@@ -848,7 +848,7 @@ struct ptlrpc_request *__ptlrpc_request_alloc(struct obd_import *imp,
 	if (request) {
 		ptlrpc_cli_req_init(request);
 
-		LASSERTF((unsigned long)imp > 0x1000, "%p", imp);
+		LASSERTF((unsigned long)imp > 0x1000, "%p\n", imp);
 		LASSERT(imp != LP_POISON);
 		LASSERTF((unsigned long)imp->imp_client > 0x1000, "%p\n",
 			 imp->imp_client);
diff --git a/fs/lustre/ptlrpc/import.c b/fs/lustre/ptlrpc/import.c
index 709b9fd..6b0b115 100644
--- a/fs/lustre/ptlrpc/import.c
+++ b/fs/lustre/ptlrpc/import.c
@@ -1495,7 +1495,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
 					   "%s: This client was evicted by %.*s; in progress operations using this service will fail.\n",
 					   imp->imp_obd->obd_name, target_len,
 					   target_start);
-			LASSERTF(!obd_lbug_on_eviction, "LBUG upon eviction");
+			LASSERTF(!obd_lbug_on_eviction, "LBUG upon eviction\n");
 		}
 		CDEBUG(D_HA, "evicted from %s@%s; invalidating\n",
 		       obd2cli_tgt(imp->imp_obd),
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today
  2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
                   ` (44 preceding siblings ...)
  2020-05-25 22:08 ` [lustre-devel] [PATCH 45/45] lustre: all: Cleanup LASSERTF uses missing newlines James Simmons
@ 2020-05-29  6:29 ` NeilBrown
  2020-06-01 22:52   ` James Simmons
  45 siblings, 1 reply; 54+ messages in thread
From: NeilBrown @ 2020-05-29  6:29 UTC (permalink / raw)
  To: lustre-devel

On Mon, May 25 2020, James Simmons wrote:

> Merge the client side patches that landed to the OpenSFS
> tree since Apirl 30 to today. Include a fid missing patches
> as well and one patch to fix issues with 2 patches from the
> earlier 600+ patch set. Please review to ensure their correctness.

Hi James,
I tried applying these and hit lots of conflicts.
What tree are they on top of?

Thanks,
NeilBrown


>
> Alexander Boyko (1):
>   lustre: llog: allow delete of zero size llog
>
> Amir Shehata (2):
>   lnet: restrict gateway selection
>   lnet: use the same src nid for discovery
>
> Andreas Dilger (5):
>   lustre: llite: verify truncated xattr is handled
>   lustre: obd: fix printing of client connection UUID
>   lustre: llite: restore ll_dcompare()
>   lustre: ldlm: use proper units for timeouts
>   lustre: lmv: do not print MDTs that are inactive
>
> Andriy Skulysh (1):
>   lustre: ptlrpc: connect to MDT stucks
>
> Bobi Jam (2):
>   lustre: lov: lov_io_sub_init()) ASSERTION
>   lustre: llite: do not flush COW pages from mapping
>
> Chris Horn (2):
>   lnet: Introduce constant for the lolnd NID
>   lnet: Add MD options for response tracking
>
> James Simmons (2):
>   lustre: cleanups and bug fixes
>   lnet: stop using struct timeval
>
> Lai Siyao (3):
>   lustre: uapi: add OBD_CONNECT2_FIDMAP
>   lustre: dne: support directory restripe
>   lustre: dne: improve temp file name check
>
> Mr NeilBrown (13):
>   lnet: merge lnet_md_alloc into lnet_md_build.
>   lnet: always put a page list into struct lnet_libmd
>   lnet: discard kvec option from lnet_libmd.
>   lnet: remove msg_iov from lnet_msg.
>   lnet: o2iblnd: discard kiblnd_setup_rd_iov
>   lustre: Remove inappropriate uses of BIT() macro.
>   lnet: libcfs: use BIT() macro where appropriate
>   lustre: llite: clean up pcc_layout_wait()
>   lustre: misc: declare static chars as const where possible.
>   lnet: use kmem_cache_zalloc as appropriate.
>   lnet: remove lnet_extract_iov()
>   lnet: simplify ksock_tx.
>   lnet: socklnd: discard tx_iov.
>
> NeilBrown (2):
>   lustre: fid: revert seq_client_rpc patch.
>   lustre: fld: convert cache_flush file to LPROC_SEQ_FOPS
>
> Oleg Drokin (3):
>   lustre: ptlrpc: return proper write count from ping_store
>   lustre: osc: Do not wait for grants for too long
>   lustre: osc: Ensure immediate departure of sync write pages
>
> Qian Yingjin (1):
>   lustre: Send file creation time to clients
>
> Sebastien Buisson (2):
>   lustre: sec: check permissions for changelogs access
>   lustre: mgc: protect from NULL exp in mgc_enqueue()
>
> Sergey Cheremencev (1):
>   lustre: quota: quota pools for OSTs
>
> Shaun Tancheff (1):
>   lustre: all: Cleanup LASSERTF uses missing newlines
>
> Swapnil Pimpale (1):
>   lustre: fallocate: Implement fallocate preallocate operation
>
> Wang Shilong (3):
>   lustre: llite: fix to make jobstats work for async ra
>   lustre: llite: fix possible divide zero in ll_use_fast_io()
>   lustre: llite: check if page truncated in ll_write_begin()
>
>  fs/lustre/fid/fid_request.c             |  12 +--
>  fs/lustre/fld/fld_cache.c               |  40 --------
>  fs/lustre/fld/fld_internal.h            |   7 --
>  fs/lustre/fld/lproc_fld.c               |  31 +++---
>  fs/lustre/include/cl_object.h           |  44 ++++++++-
>  fs/lustre/include/lu_object.h           |  16 +--
>  fs/lustre/include/lustre_dlm.h          |  17 ++--
>  fs/lustre/include/lustre_import.h       |   4 +-
>  fs/lustre/include/lustre_lmv.h          |  94 ++++++++++++++++--
>  fs/lustre/include/lustre_req_layout.h   |   3 +
>  fs/lustre/include/lustre_swab.h         |   2 +-
>  fs/lustre/include/obd_support.h         |   5 +-
>  fs/lustre/include/obd_target.h          |  54 ++++++++++
>  fs/lustre/ldlm/ldlm_lockd.c             |   3 +-
>  fs/lustre/ldlm/ldlm_request.c           |   1 +
>  fs/lustre/ldlm/ldlm_resource.c          |  11 ++-
>  fs/lustre/llite/dcache.c                |  56 ++++++++---
>  fs/lustre/llite/dir.c                   |  33 +++++--
>  fs/lustre/llite/file.c                  |  84 +++++++++++++++-
>  fs/lustre/llite/lcommon_cl.c            |   2 +
>  fs/lustre/llite/llite_internal.h        |   6 +-
>  fs/lustre/llite/llite_lib.c             |   6 +-
>  fs/lustre/llite/llite_mmap.c            |   2 +-
>  fs/lustre/llite/lproc_llite.c           |  19 ++--
>  fs/lustre/llite/namei.c                 |   5 +-
>  fs/lustre/llite/pcc.c                   |  17 ++--
>  fs/lustre/llite/rw.c                    |  13 ++-
>  fs/lustre/llite/rw26.c                  |  16 ++-
>  fs/lustre/llite/statahead.c             |   2 +-
>  fs/lustre/llite/vvp_io.c                |  19 ++--
>  fs/lustre/llite/vvp_object.c            |   2 +-
>  fs/lustre/llite/xattr.c                 |  15 ++-
>  fs/lustre/lmv/lmv_obd.c                 |  66 +++++++++----
>  fs/lustre/lov/lov_cl_internal.h         |   6 +-
>  fs/lustre/lov/lov_io.c                  |  31 ++++--
>  fs/lustre/mdc/mdc_changelog.c           |   1 +
>  fs/lustre/mdc/mdc_request.c             |  41 +++++---
>  fs/lustre/mgc/mgc_request.c             |  11 ++-
>  fs/lustre/obdclass/cl_page.c            |   1 -
>  fs/lustre/obdclass/class_obd.c          |  35 +++----
>  fs/lustre/obdclass/llog.c               |   9 +-
>  fs/lustre/obdclass/llog_cat.c           |   3 +-
>  fs/lustre/obdclass/lprocfs_status.c     |   8 +-
>  fs/lustre/obdclass/obd_mount.c          |   2 +-
>  fs/lustre/osc/osc_cache.c               |  33 ++++++-
>  fs/lustre/osc/osc_internal.h            |   3 +
>  fs/lustre/osc/osc_io.c                  |  56 +++++++++--
>  fs/lustre/osc/osc_request.c             |  70 ++++++++++++-
>  fs/lustre/ptlrpc/client.c               |   2 +-
>  fs/lustre/ptlrpc/events.c               |   2 +-
>  fs/lustre/ptlrpc/import.c               |   4 +-
>  fs/lustre/ptlrpc/layout.c               |  26 ++++-
>  fs/lustre/ptlrpc/llog_client.c          |   4 +
>  fs/lustre/ptlrpc/lproc_ptlrpc.c         |   4 +-
>  fs/lustre/ptlrpc/pack_generic.c         |  16 ++-
>  fs/lustre/ptlrpc/ptlrpc_internal.h      |  19 ++++
>  fs/lustre/ptlrpc/wiretest.c             |  16 ++-
>  include/linux/lnet/lib-lnet.h           |  56 +----------
>  include/linux/lnet/lib-types.h          |  15 +--
>  include/uapi/linux/lnet/lnet-types.h    |  11 +++
>  include/uapi/linux/lnet/lnetst.h        |   8 +-
>  include/uapi/linux/lustre/lustre_idl.h  |  28 ++++--
>  include/uapi/linux/lustre/lustre_user.h |  51 +++++++++-
>  net/lnet/klnds/o2iblnd/o2iblnd_cb.c     | 122 +++--------------------
>  net/lnet/klnds/socklnd/socklnd.h        |  16 +--
>  net/lnet/klnds/socklnd/socklnd_cb.c     |  68 +++++--------
>  net/lnet/klnds/socklnd/socklnd_lib.c    |  32 +++---
>  net/lnet/klnds/socklnd/socklnd_proto.c  |  10 +-
>  net/lnet/libcfs/debug.c                 |   2 +-
>  net/lnet/libcfs/libcfs_string.c         |   4 +-
>  net/lnet/libcfs/module.c                |  17 ++--
>  net/lnet/lnet/api-ni.c                  |  16 +--
>  net/lnet/lnet/config.c                  |  16 +--
>  net/lnet/lnet/lib-md.c                  | 168 ++++++++++++++++----------------
>  net/lnet/lnet/lib-me.c                  |   2 +-
>  net/lnet/lnet/lib-move.c                | 167 ++++++++++++++-----------------
>  net/lnet/lnet/lib-msg.c                 |   5 +-
>  net/lnet/lnet/lib-socket.c              |  34 ++-----
>  net/lnet/lnet/lo.c                      |  17 +---
>  net/lnet/lnet/peer.c                    |  17 +++-
>  net/lnet/lnet/router.c                  |   2 +-
>  net/lnet/selftest/conctl.c              |   1 -
>  net/lnet/selftest/conrpc.c              |   6 +-
>  net/lnet/selftest/conrpc.h              |   1 -
>  net/lnet/selftest/console.h             |   1 -
>  85 files changed, 1201 insertions(+), 802 deletions(-)
>  create mode 100644 fs/lustre/include/obd_target.h
>
> -- 
> 1.8.3.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20200529/b82d6062/attachment.sig>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today
  2020-05-29  6:29 ` [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today NeilBrown
@ 2020-06-01 22:52   ` James Simmons
  2020-06-23  4:10     ` NeilBrown
  0 siblings, 1 reply; 54+ messages in thread
From: James Simmons @ 2020-06-01 22:52 UTC (permalink / raw)
  To: lustre-devel


> > Merge the client side patches that landed to the OpenSFS
> > tree since Apirl 30 to today. Include a fid missing patches
> > as well and one patch to fix issues with 2 patches from the
> > earlier 600+ patch set. Please review to ensure their correctness.
> 
> Hi James,
> I tried applying these and hit lots of conflicts.
> What tree are they on top of?

This is based off the top of my tree. Currently I'm using my tree as the 
OpenSFS version of the Linux client so I only add things that land. Your
tree is more the development / prototype tree since it has not yet landed
things. So most likely its the LNet LU-13004 work that is conflicting.
I also run the patches by checkpatch which has the LNET comment change 
that  wasn't in the OpenSFS branch until just recently; OpenSFS commit
d3f1ceeb123da9603cd5ee3acbd4ee638a995f10. That should reduce the conflicts
going forward. We are getting to the point in which both our trees are
almost in sync ;-) 

> Thanks,
> NeilBrown
> 
> 
> >
> > Alexander Boyko (1):
> >   lustre: llog: allow delete of zero size llog
> >
> > Amir Shehata (2):
> >   lnet: restrict gateway selection
> >   lnet: use the same src nid for discovery
> >
> > Andreas Dilger (5):
> >   lustre: llite: verify truncated xattr is handled
> >   lustre: obd: fix printing of client connection UUID
> >   lustre: llite: restore ll_dcompare()
> >   lustre: ldlm: use proper units for timeouts
> >   lustre: lmv: do not print MDTs that are inactive
> >
> > Andriy Skulysh (1):
> >   lustre: ptlrpc: connect to MDT stucks
> >
> > Bobi Jam (2):
> >   lustre: lov: lov_io_sub_init()) ASSERTION
> >   lustre: llite: do not flush COW pages from mapping
> >
> > Chris Horn (2):
> >   lnet: Introduce constant for the lolnd NID
> >   lnet: Add MD options for response tracking
> >
> > James Simmons (2):
> >   lustre: cleanups and bug fixes
> >   lnet: stop using struct timeval
> >
> > Lai Siyao (3):
> >   lustre: uapi: add OBD_CONNECT2_FIDMAP
> >   lustre: dne: support directory restripe
> >   lustre: dne: improve temp file name check
> >
> > Mr NeilBrown (13):
> >   lnet: merge lnet_md_alloc into lnet_md_build.
> >   lnet: always put a page list into struct lnet_libmd
> >   lnet: discard kvec option from lnet_libmd.
> >   lnet: remove msg_iov from lnet_msg.
> >   lnet: o2iblnd: discard kiblnd_setup_rd_iov
> >   lustre: Remove inappropriate uses of BIT() macro.
> >   lnet: libcfs: use BIT() macro where appropriate
> >   lustre: llite: clean up pcc_layout_wait()
> >   lustre: misc: declare static chars as const where possible.
> >   lnet: use kmem_cache_zalloc as appropriate.
> >   lnet: remove lnet_extract_iov()
> >   lnet: simplify ksock_tx.
> >   lnet: socklnd: discard tx_iov.
> >
> > NeilBrown (2):
> >   lustre: fid: revert seq_client_rpc patch.
> >   lustre: fld: convert cache_flush file to LPROC_SEQ_FOPS
> >
> > Oleg Drokin (3):
> >   lustre: ptlrpc: return proper write count from ping_store
> >   lustre: osc: Do not wait for grants for too long
> >   lustre: osc: Ensure immediate departure of sync write pages
> >
> > Qian Yingjin (1):
> >   lustre: Send file creation time to clients
> >
> > Sebastien Buisson (2):
> >   lustre: sec: check permissions for changelogs access
> >   lustre: mgc: protect from NULL exp in mgc_enqueue()
> >
> > Sergey Cheremencev (1):
> >   lustre: quota: quota pools for OSTs
> >
> > Shaun Tancheff (1):
> >   lustre: all: Cleanup LASSERTF uses missing newlines
> >
> > Swapnil Pimpale (1):
> >   lustre: fallocate: Implement fallocate preallocate operation
> >
> > Wang Shilong (3):
> >   lustre: llite: fix to make jobstats work for async ra
> >   lustre: llite: fix possible divide zero in ll_use_fast_io()
> >   lustre: llite: check if page truncated in ll_write_begin()
> >
> >  fs/lustre/fid/fid_request.c             |  12 +--
> >  fs/lustre/fld/fld_cache.c               |  40 --------
> >  fs/lustre/fld/fld_internal.h            |   7 --
> >  fs/lustre/fld/lproc_fld.c               |  31 +++---
> >  fs/lustre/include/cl_object.h           |  44 ++++++++-
> >  fs/lustre/include/lu_object.h           |  16 +--
> >  fs/lustre/include/lustre_dlm.h          |  17 ++--
> >  fs/lustre/include/lustre_import.h       |   4 +-
> >  fs/lustre/include/lustre_lmv.h          |  94 ++++++++++++++++--
> >  fs/lustre/include/lustre_req_layout.h   |   3 +
> >  fs/lustre/include/lustre_swab.h         |   2 +-
> >  fs/lustre/include/obd_support.h         |   5 +-
> >  fs/lustre/include/obd_target.h          |  54 ++++++++++
> >  fs/lustre/ldlm/ldlm_lockd.c             |   3 +-
> >  fs/lustre/ldlm/ldlm_request.c           |   1 +
> >  fs/lustre/ldlm/ldlm_resource.c          |  11 ++-
> >  fs/lustre/llite/dcache.c                |  56 ++++++++---
> >  fs/lustre/llite/dir.c                   |  33 +++++--
> >  fs/lustre/llite/file.c                  |  84 +++++++++++++++-
> >  fs/lustre/llite/lcommon_cl.c            |   2 +
> >  fs/lustre/llite/llite_internal.h        |   6 +-
> >  fs/lustre/llite/llite_lib.c             |   6 +-
> >  fs/lustre/llite/llite_mmap.c            |   2 +-
> >  fs/lustre/llite/lproc_llite.c           |  19 ++--
> >  fs/lustre/llite/namei.c                 |   5 +-
> >  fs/lustre/llite/pcc.c                   |  17 ++--
> >  fs/lustre/llite/rw.c                    |  13 ++-
> >  fs/lustre/llite/rw26.c                  |  16 ++-
> >  fs/lustre/llite/statahead.c             |   2 +-
> >  fs/lustre/llite/vvp_io.c                |  19 ++--
> >  fs/lustre/llite/vvp_object.c            |   2 +-
> >  fs/lustre/llite/xattr.c                 |  15 ++-
> >  fs/lustre/lmv/lmv_obd.c                 |  66 +++++++++----
> >  fs/lustre/lov/lov_cl_internal.h         |   6 +-
> >  fs/lustre/lov/lov_io.c                  |  31 ++++--
> >  fs/lustre/mdc/mdc_changelog.c           |   1 +
> >  fs/lustre/mdc/mdc_request.c             |  41 +++++---
> >  fs/lustre/mgc/mgc_request.c             |  11 ++-
> >  fs/lustre/obdclass/cl_page.c            |   1 -
> >  fs/lustre/obdclass/class_obd.c          |  35 +++----
> >  fs/lustre/obdclass/llog.c               |   9 +-
> >  fs/lustre/obdclass/llog_cat.c           |   3 +-
> >  fs/lustre/obdclass/lprocfs_status.c     |   8 +-
> >  fs/lustre/obdclass/obd_mount.c          |   2 +-
> >  fs/lustre/osc/osc_cache.c               |  33 ++++++-
> >  fs/lustre/osc/osc_internal.h            |   3 +
> >  fs/lustre/osc/osc_io.c                  |  56 +++++++++--
> >  fs/lustre/osc/osc_request.c             |  70 ++++++++++++-
> >  fs/lustre/ptlrpc/client.c               |   2 +-
> >  fs/lustre/ptlrpc/events.c               |   2 +-
> >  fs/lustre/ptlrpc/import.c               |   4 +-
> >  fs/lustre/ptlrpc/layout.c               |  26 ++++-
> >  fs/lustre/ptlrpc/llog_client.c          |   4 +
> >  fs/lustre/ptlrpc/lproc_ptlrpc.c         |   4 +-
> >  fs/lustre/ptlrpc/pack_generic.c         |  16 ++-
> >  fs/lustre/ptlrpc/ptlrpc_internal.h      |  19 ++++
> >  fs/lustre/ptlrpc/wiretest.c             |  16 ++-
> >  include/linux/lnet/lib-lnet.h           |  56 +----------
> >  include/linux/lnet/lib-types.h          |  15 +--
> >  include/uapi/linux/lnet/lnet-types.h    |  11 +++
> >  include/uapi/linux/lnet/lnetst.h        |   8 +-
> >  include/uapi/linux/lustre/lustre_idl.h  |  28 ++++--
> >  include/uapi/linux/lustre/lustre_user.h |  51 +++++++++-
> >  net/lnet/klnds/o2iblnd/o2iblnd_cb.c     | 122 +++--------------------
> >  net/lnet/klnds/socklnd/socklnd.h        |  16 +--
> >  net/lnet/klnds/socklnd/socklnd_cb.c     |  68 +++++--------
> >  net/lnet/klnds/socklnd/socklnd_lib.c    |  32 +++---
> >  net/lnet/klnds/socklnd/socklnd_proto.c  |  10 +-
> >  net/lnet/libcfs/debug.c                 |   2 +-
> >  net/lnet/libcfs/libcfs_string.c         |   4 +-
> >  net/lnet/libcfs/module.c                |  17 ++--
> >  net/lnet/lnet/api-ni.c                  |  16 +--
> >  net/lnet/lnet/config.c                  |  16 +--
> >  net/lnet/lnet/lib-md.c                  | 168 ++++++++++++++++----------------
> >  net/lnet/lnet/lib-me.c                  |   2 +-
> >  net/lnet/lnet/lib-move.c                | 167 ++++++++++++++-----------------
> >  net/lnet/lnet/lib-msg.c                 |   5 +-
> >  net/lnet/lnet/lib-socket.c              |  34 ++-----
> >  net/lnet/lnet/lo.c                      |  17 +---
> >  net/lnet/lnet/peer.c                    |  17 +++-
> >  net/lnet/lnet/router.c                  |   2 +-
> >  net/lnet/selftest/conctl.c              |   1 -
> >  net/lnet/selftest/conrpc.c              |   6 +-
> >  net/lnet/selftest/conrpc.h              |   1 -
> >  net/lnet/selftest/console.h             |   1 -
> >  85 files changed, 1201 insertions(+), 802 deletions(-)
> >  create mode 100644 fs/lustre/include/obd_target.h
> >
> > -- 
> > 1.8.3.1
> 

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today
  2020-06-01 22:52   ` James Simmons
@ 2020-06-23  4:10     ` NeilBrown
  2020-06-23  7:57       ` Degremont, Aurelien
  2020-06-24 14:34       ` James Simmons
  0 siblings, 2 replies; 54+ messages in thread
From: NeilBrown @ 2020-06-23  4:10 UTC (permalink / raw)
  To: lustre-devel

On Mon, Jun 01 2020, James Simmons wrote:

>> > Merge the client side patches that landed to the OpenSFS
>> > tree since Apirl 30 to today. Include a fid missing patches
>> > as well and one patch to fix issues with 2 patches from the
>> > earlier 600+ patch set. Please review to ensure their correctness.
>> 
>> Hi James,
>> I tried applying these and hit lots of conflicts.
>> What tree are they on top of?
>
> This is based off the top of my tree. Currently I'm using my tree as the 
> OpenSFS version of the Linux client so I only add things that land. Your
> tree is more the development / prototype tree since it has not yet landed
> things. So most likely its the LNet LU-13004 work that is conflicting.
> I also run the patches by checkpatch which has the LNET comment change 
> that  wasn't in the OpenSFS branch until just recently; OpenSFS commit
> d3f1ceeb123da9603cd5ee3acbd4ee638a995f10. That should reduce the conflicts
> going forward. We are getting to the point in which both our trees are
> almost in sync ;-) 

I don't think it makes any sense to maintain two separate trees like
this.

Would you like to just keep maintaining your tree, and I'll stop with
mine?

If so, is your git tree published somewhere?

Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20200623/0d25b182/attachment.sig>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today
  2020-06-23  4:10     ` NeilBrown
@ 2020-06-23  7:57       ` Degremont, Aurelien
  2020-06-24  0:52         ` NeilBrown
  2020-06-24 14:34       ` James Simmons
  1 sibling, 1 reply; 54+ messages in thread
From: Degremont, Aurelien @ 2020-06-23  7:57 UTC (permalink / raw)
  To: lustre-devel



?Le 23/06/2020 06:11, ? lustre-devel au nom de NeilBrown ? <lustre-devel-bounces at lists.lustre.org au nom de neilb@suse.de> a ?crit :

    On Mon, Jun 01 2020, James Simmons wrote:

    >> > Merge the client side patches that landed to the OpenSFS
    >> > tree since Apirl 30 to today. Include a fid missing patches
    >> > as well and one patch to fix issues with 2 patches from the
    >> > earlier 600+ patch set. Please review to ensure their correctness.
    >>
    >> Hi James,
    >> I tried applying these and hit lots of conflicts.
    >> What tree are they on top of?
    >
    > This is based off the top of my tree. Currently I'm using my tree as the
    > OpenSFS version of the Linux client so I only add things that land. Your
    > tree is more the development / prototype tree since it has not yet landed
    > things. So most likely its the LNet LU-13004 work that is conflicting.
    > I also run the patches by checkpatch which has the LNET comment change
    > that  wasn't in the OpenSFS branch until just recently; OpenSFS commit
    > d3f1ceeb123da9603cd5ee3acbd4ee638a995f10. That should reduce the conflicts
    > going forward. We are getting to the point in which both our trees are
    > almost in sync ;-)

    I don't think it makes any sense to maintain two separate trees like
    this.

    Would you like to just keep maintaining your tree, and I'll stop with
    mine?

    If so, is your git tree published somewhere?


By the way, where's your tree available Neil? I'm checking your github account but not sure this is there.


Aur?lien

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today
  2020-06-23  7:57       ` Degremont, Aurelien
@ 2020-06-24  0:52         ` NeilBrown
  2020-07-03  6:37           ` NeilBrown
  0 siblings, 1 reply; 54+ messages in thread
From: NeilBrown @ 2020-06-24  0:52 UTC (permalink / raw)
  To: lustre-devel

On Tue, Jun 23 2020, Degremont, Aurelien wrote:

> ?Le 23/06/2020 06:11, ? lustre-devel au nom de NeilBrown ? <lustre-devel-bounces at lists.lustre.org au nom de neilb@suse.de> a ?crit :
>
>     On Mon, Jun 01 2020, James Simmons wrote:
>
>     >> > Merge the client side patches that landed to the OpenSFS
>     >> > tree since Apirl 30 to today. Include a fid missing patches
>     >> > as well and one patch to fix issues with 2 patches from the
>     >> > earlier 600+ patch set. Please review to ensure their correctness.
>     >>
>     >> Hi James,
>     >> I tried applying these and hit lots of conflicts.
>     >> What tree are they on top of?
>     >
>     > This is based off the top of my tree. Currently I'm using my tree as the
>     > OpenSFS version of the Linux client so I only add things that land. Your
>     > tree is more the development / prototype tree since it has not yet landed
>     > things. So most likely its the LNet LU-13004 work that is conflicting.
>     > I also run the patches by checkpatch which has the LNET comment change
>     > that  wasn't in the OpenSFS branch until just recently; OpenSFS commit
>     > d3f1ceeb123da9603cd5ee3acbd4ee638a995f10. That should reduce the conflicts
>     > going forward. We are getting to the point in which both our trees are
>     > almost in sync ;-)
>
>     I don't think it makes any sense to maintain two separate trees like
>     this.
>
>     Would you like to just keep maintaining your tree, and I'll stop with
>     mine?
>
>     If so, is your git tree published somewhere?
>
>
> By the way, where's your tree available Neil? I'm checking your github account but not sure this is there.
>

In the "linux" repo I have quite a few branches.
 "lustre/lustre" is the latest lustre code (as of late april).

https://github.com/neilbrown/linux/tree/lustre/lustre

NeilBrown

>
> Aur?lien
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20200624/49158995/attachment.sig>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today
  2020-06-23  4:10     ` NeilBrown
  2020-06-23  7:57       ` Degremont, Aurelien
@ 2020-06-24 14:34       ` James Simmons
  2020-06-25  1:46         ` NeilBrown
  1 sibling, 1 reply; 54+ messages in thread
From: James Simmons @ 2020-06-24 14:34 UTC (permalink / raw)
  To: lustre-devel


> On Mon, Jun 01 2020, James Simmons wrote:
> 
> >> > Merge the client side patches that landed to the OpenSFS
> >> > tree since Apirl 30 to today. Include a fid missing patches
> >> > as well and one patch to fix issues with 2 patches from the
> >> > earlier 600+ patch set. Please review to ensure their correctness.
> >> 
> >> Hi James,
> >> I tried applying these and hit lots of conflicts.
> >> What tree are they on top of?
> >
> > This is based off the top of my tree. Currently I'm using my tree as the 
> > OpenSFS version of the Linux client so I only add things that land. Your
> > tree is more the development / prototype tree since it has not yet landed
> > things. So most likely its the LNet LU-13004 work that is conflicting.
> > I also run the patches by checkpatch which has the LNET comment change 
> > that  wasn't in the OpenSFS branch until just recently; OpenSFS commit
> > d3f1ceeb123da9603cd5ee3acbd4ee638a995f10. That should reduce the conflicts
> > going forward. We are getting to the point in which both our trees are
> > almost in sync ;-) 
> 
> I don't think it makes any sense to maintain two separate trees like
> this.
> 
> Would you like to just keep maintaining your tree, and I'll stop with
> mine?
> 
> If so, is your git tree published somewhere?

At this point its okay to have two separate trees since our trees have
two different purposes. Mind you I do plan to retire my tree in the
near future for your tree. My tree:

https://github.com/jasimmons1973/lustre

is a 1 to 1 OpenSFS port to the Linux client. Your tree has new prototype
work; most has landed to the OpenSFS tree; which in turn ends up in my 
tree. Work is still outstanding in your tree that needs to be properly
vetted and merged. Also I have noticed the work in your tree that has
landed to OpenSFS is different. Sometimes the OpenSFS branch has 
improvements missing from the Linux client prototype patch and some times
the reverse is true. So those issues need to be sorted out as well. Your
tree is needed to work out these last bits. Once done a sweep will need
to be done on your tree to patch everything up.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today
  2020-06-24 14:34       ` James Simmons
@ 2020-06-25  1:46         ` NeilBrown
  0 siblings, 0 replies; 54+ messages in thread
From: NeilBrown @ 2020-06-25  1:46 UTC (permalink / raw)
  To: lustre-devel

On Wed, Jun 24 2020, James Simmons wrote:

>> On Mon, Jun 01 2020, James Simmons wrote:
>> 
>> >> > Merge the client side patches that landed to the OpenSFS
>> >> > tree since Apirl 30 to today. Include a fid missing patches
>> >> > as well and one patch to fix issues with 2 patches from the
>> >> > earlier 600+ patch set. Please review to ensure their correctness.
>> >> 
>> >> Hi James,
>> >> I tried applying these and hit lots of conflicts.
>> >> What tree are they on top of?
>> >
>> > This is based off the top of my tree. Currently I'm using my tree as the 
>> > OpenSFS version of the Linux client so I only add things that land. Your
>> > tree is more the development / prototype tree since it has not yet landed
>> > things. So most likely its the LNet LU-13004 work that is conflicting.
>> > I also run the patches by checkpatch which has the LNET comment change 
>> > that  wasn't in the OpenSFS branch until just recently; OpenSFS commit
>> > d3f1ceeb123da9603cd5ee3acbd4ee638a995f10. That should reduce the conflicts
>> > going forward. We are getting to the point in which both our trees are
>> > almost in sync ;-) 
>> 
>> I don't think it makes any sense to maintain two separate trees like
>> this.
>> 
>> Would you like to just keep maintaining your tree, and I'll stop with
>> mine?
>> 
>> If so, is your git tree published somewhere?
>
> At this point its okay to have two separate trees since our trees have
> two different purposes. Mind you I do plan to retire my tree in the
> near future for your tree. My tree:
>
> https://github.com/jasimmons1973/lustre

Thanks.

>
> is a 1 to 1 OpenSFS port to the Linux client. Your tree has new prototype
> work; most has landed to the OpenSFS tree; which in turn ends up in my 
> tree. Work is still outstanding in your tree that needs to be properly
> vetted and merged. Also I have noticed the work in your tree that has
> landed to OpenSFS is different. Sometimes the OpenSFS branch has 
> improvements missing from the Linux client prototype patch and some times
> the reverse is true. So those issues need to be sorted out as well. Your
> tree is needed to work out these last bits. Once done a sweep will need
> to be done on your tree to patch everything up.

Maybe...
I'm beginning to wonder it might be best to base our eventual submission
the Linux on the OpenSFS master branch.
i.e. get it to a state where we can write a tool that collects all the
code needed for the client and places it in the linux tree at the
appropriate place.  Then we submit that as a series of commits.

The big value proposition here is that the code we submit is
demonstrable close to the code that we test.

I don't know ... maybe maintaining the parallel tree is a good idea.
I'm just not as sure as I once was.  The testing is really a big deal.

NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20200625/928d57c2/attachment.sig>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today
  2020-06-24  0:52         ` NeilBrown
@ 2020-07-03  6:37           ` NeilBrown
  0 siblings, 0 replies; 54+ messages in thread
From: NeilBrown @ 2020-07-03  6:37 UTC (permalink / raw)
  To: lustre-devel

On Wed, Jun 24 2020, NeilBrown wrote:
>>
>> By the way, where's your tree available Neil? I'm checking your github account but not sure this is there.
>>
>
> In the "linux" repo I have quite a few branches.
>  "lustre/lustre" is the latest lustre code (as of late april).
>
> https://github.com/neilbrown/linux/tree/lustre/lustre

Just FYI, I've updated this to Linux 5.7 and *almost* current master.
There is one patch which causes all my testing to fail, so I've
postponed that one until I understand the problem.

NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20200703/5d6bb3ec/attachment.sig>

^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2020-07-03  6:37 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-25 22:07 [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 01/45] lustre: fid: revert seq_client_rpc patch James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 02/45] lustre: fld: convert cache_flush file to LPROC_SEQ_FOPS James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 03/45] lustre: cleanups and bug fixes James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 04/45] lnet: merge lnet_md_alloc into lnet_md_build James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 05/45] lnet: always put a page list into struct lnet_libmd James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 06/45] lnet: discard kvec option from lnet_libmd James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 07/45] lnet: remove msg_iov from lnet_msg James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 08/45] lnet: o2iblnd: discard kiblnd_setup_rd_iov James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 09/45] lustre: ptlrpc: return proper write count from ping_store James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 10/45] lustre: sec: check permissions for changelogs access James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 11/45] lustre: uapi: add OBD_CONNECT2_FIDMAP James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 12/45] lustre: lov: lov_io_sub_init()) ASSERTION James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 13/45] lnet: Introduce constant for the lolnd NID James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 14/45] lustre: Remove inappropriate uses of BIT() macro James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 15/45] lustre: mgc: protect from NULL exp in mgc_enqueue() James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 16/45] lustre: llite: do not flush COW pages from mapping James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 17/45] lustre: quota: quota pools for OSTs James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 18/45] lnet: libcfs: use BIT() macro where appropriate James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 19/45] lustre: llite: clean up pcc_layout_wait() James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 20/45] lustre: misc: declare static chars as const where possible James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 21/45] lustre: llite: fix to make jobstats work for async ra James Simmons
2020-05-25 22:07 ` [lustre-devel] [PATCH 22/45] lustre: llite: verify truncated xattr is handled James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 23/45] lustre: obd: fix printing of client connection UUID James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 24/45] lnet: Add MD options for response tracking James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 25/45] lustre: Send file creation time to clients James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 26/45] lnet: stop using struct timeval James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 27/45] lustre: ptlrpc: connect to MDT stucks James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 28/45] lnet: restrict gateway selection James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 29/45] lustre: llite: restore ll_dcompare() James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 30/45] lustre: fallocate: Implement fallocate preallocate operation James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 31/45] lustre: llite: fix possible divide zero in ll_use_fast_io() James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 32/45] lustre: llog: allow delete of zero size llog James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 33/45] lustre: ldlm: use proper units for timeouts James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 34/45] lustre: dne: support directory restripe James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 35/45] lustre: osc: Do not wait for grants for too long James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 36/45] lnet: use kmem_cache_zalloc as appropriate James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 37/45] lustre: osc: Ensure immediate departure of sync write pages James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 38/45] lnet: remove lnet_extract_iov() James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 39/45] lnet: simplify ksock_tx James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 40/45] lnet: socklnd: discard tx_iov James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 41/45] lustre: lmv: do not print MDTs that are inactive James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 42/45] lnet: use the same src nid for discovery James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 43/45] lustre: llite: check if page truncated in ll_write_begin() James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 44/45] lustre: dne: improve temp file name check James Simmons
2020-05-25 22:08 ` [lustre-devel] [PATCH 45/45] lustre: all: Cleanup LASSERTF uses missing newlines James Simmons
2020-05-29  6:29 ` [lustre-devel] [PATCH 00/45] lustre: merged OpenSFS client patches from April 30 to today NeilBrown
2020-06-01 22:52   ` James Simmons
2020-06-23  4:10     ` NeilBrown
2020-06-23  7:57       ` Degremont, Aurelien
2020-06-24  0:52         ` NeilBrown
2020-07-03  6:37           ` NeilBrown
2020-06-24 14:34       ` James Simmons
2020-06-25  1:46         ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).