Skip to contentSkip to conversation

OpenSFS backport for Nov 15 2020

PATCH New James Simmons 1 participant 29 messages Nov 16, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover OpenSFS backport for Nov 15 2020

Backport of various patches from the OpenSFS tree. Fixes for mmap and fscrypto has been included which impacted new kernels. This work has been validated against:

sanity-lnet.sh
sanity.sh
sanity-hsm.sh
sanity-sec.sh
sanity-pcc.sh

Alexander Boyko (2):
lustre: ptlrpc: remove unused code at pinger
lustre: ptlrpc: decrease time between reconnection

Amir Shehata (1):
lnet: o2iblnd: Don't retry indefinitely

Andriy Skulysh (2):
lustre: llite: ASSERTION( last_oap_count > 0 ) failed
lustre: ldlm: BL AST vs failed lock enqueue race

Aurelien Degremont (2):
lustre: ptlrpc: throttle RPC resend if network error
lustre: ptlrpc: don't log connection 'restored' inappropriately

Brian Behlendorf (1):
lnet: o2iblnd: 'Timed out tx' error message

Hongchao Zhang (1):
lustre: lov: doesn't check lov_refcount

James Simmons (1):
llite: remove splice_read handling for PCC

John L. Hammond (1):
lnet: o2ib: raise bind cap before resolving address

Lai Siyao (3):
lustre: llite: rmdir releases inode on client
lustre: mdc: remote object support getattr from cache
lustre: llite: pass name in getattr by FID

Mikhail Pershin (2):
lustre: ptlrpc: introduce OST_SEEK RPC
lustre: clio: SEEK_HOLE/SEEK_DATA on client side

Mr NeilBrown (2):
lustre: llite: disable statahead_agl for sanity test_56ra
lustre: seq_file .next functions must update *pos

NeilBrown (1):
lustre: use memalloc_nofs_save() for GFP_NOFS kvmalloc allocations.

Oleg Drokin (2):
lustre: ldlm: Fix unbounded OBD_FAIL_LDLM_CANCEL_BL_CB_RACE wait
lustre: llite: Avoid eternel retry loops with MAP_POPULATE

Sebastien Buisson (6):
lustre: gss: update sequence in case of target disconnect
lustre: sec: O_DIRECT for encrypted file
lustre: sec: restrict fallocate on encrypted files
lustre: sec: encryption with different client PAGE_SIZE
lustre: sec: require enc key in case of O_CREAT only
lustre: sec: fix O_DIRECT and encrypted files

Vitaly Fertman (1):
lustre: ldlm: group locks for DOM IBIT lock

 .../client_side_encryption/access_semantics.txt    |   3 -
 fs/lustre/include/cl_object.h                      |  10 +
 fs/lustre/include/lustre_export.h                  |   5 +
 fs/lustre/include/lustre_net.h                     |   5 -
 fs/lustre/include/lustre_osc.h                     |   4 +
 fs/lustre/include/lustre_req_layout.h              |   1 +
 fs/lustre/include/obd.h                            |   1 +
 fs/lustre/ldlm/ldlm_inodebits.c                    |   2 +
 fs/lustre/ldlm/ldlm_lock.c                         |  12 +-
 fs/lustre/ldlm/ldlm_lockd.c                        |   4 +-
 fs/lustre/ldlm/ldlm_request.c                      |   5 +-
 fs/lustre/llite/dir.c                              |   1 -
 fs/lustre/llite/file.c                             | 115 ++++++++++--
 fs/lustre/llite/llite_internal.h                   |   1 -
 fs/lustre/llite/llite_lib.c                        |  19 +-
 fs/lustre/llite/llite_mmap.c                       |  10 +-
 fs/lustre/llite/namei.c                            |  24 ++-
 fs/lustre/llite/pcc.c                              |  33 +---
 fs/lustre/llite/pcc.h                              |   5 -
 fs/lustre/llite/rw26.c                             |  27 ++-
 fs/lustre/llite/statahead.c                        |  31 ++--
 fs/lustre/llite/super25.c                          |  11 ++
 fs/lustre/llite/vvp_io.c                           |  53 +++++-
 fs/lustre/lmv/lmv_intent.c                         |  22 ++-
 fs/lustre/lmv/lmv_obd.c                            |   8 +-
 fs/lustre/lov/lov_io.c                             |  99 +++++++++-
 fs/lustre/lov/lov_obd.c                            |   3 +-
 fs/lustre/lov/lov_object.c                         |  13 +-
 fs/lustre/lov/lov_pool.c                           |   2 +-
 fs/lustre/mdc/mdc_dev.c                            |  14 +-
 fs/lustre/mdc/mdc_locks.c                          |   1 -
 fs/lustre/obdclass/cl_io.c                         |  12 ++
 fs/lustre/obdclass/lprocfs_status.c                |   1 +
 fs/lustre/obdecho/echo_client.c                    |   7 +-
 fs/lustre/osc/osc_io.c                             | 143 ++++++++++++++-
 fs/lustre/osc/osc_request.c                        |  95 +++++++---
 fs/lustre/ptlrpc/client.c                          |  20 ++
 fs/lustre/ptlrpc/events.c                          |   5 +
 fs/lustre/ptlrpc/import.c                          |  52 +++++-
 fs/lustre/ptlrpc/layout.c                          |   5 +
 fs/lustre/ptlrpc/lproc_ptlrpc.c                    |   4 +-
 fs/lustre/ptlrpc/niobuf.c                          |   2 -
 fs/lustre/ptlrpc/pinger.c                          | 202 +++++----------------
 fs/lustre/ptlrpc/sec.c                             |   4 +-
 fs/lustre/ptlrpc/sec_null.c                        |   8 -
 fs/lustre/ptlrpc/wiretest.c                        |  14 +-
 include/uapi/linux/lustre/lustre_idl.h             |   3 +
 net/lnet/klnds/o2iblnd/o2iblnd.h                   |   2 +
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c                |  48 ++++-
 net/lnet/klnds/o2iblnd/o2iblnd_modparams.c         |   2 +-
 50 files changed, 834 insertions(+), 339 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/28 llite: remove splice_read handling for PCC

For older kernels with PCC we handled splice_read ourself but this is no longer needed since generic_file_splice_read() is just a wrapper around the read_iter() operation. We can safely remove pcc_file_splice_read(). Use the read_iter() / write_iter() functions for pccf_file instead of the default file of the passed in kiocb.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13745
Lustre-commit: 1635dc9de0bc1d ("LU-13745 llite: switch generic_file_splice_read() to use of ->read_iter()")

Reviewed-on: https://review.whamcloud.com/39272

---
 fs/lustre/llite/pcc.c | 33 ++-------------------------------
 fs/lustre/llite/pcc.h |  5 -----
 2 files changed, 2 insertions(+), 36 deletions(-)
fs/lustre/llite/pcc.c +2 -31
index 5a4bb33..28ca9cb 100644
@@ -1592,7 +1592,7 @@ ssize_t pcc_file_read_iter(struct kiocb *iocb,
 	 * filp->f_ops->read_iter uses ->aio_read hook directly
 	 * to add support for ext4-dax.
 	 */
-	result = file->f_op->read_iter(iocb, iter);
+	result = iocb->ki_filp->f_op->read_iter(iocb, iter);
 	iocb->ki_filp = file;
 
 	pcc_io_fini(inode);
@@ -1633,7 +1633,7 @@ ssize_t pcc_file_write_iter(struct kiocb *iocb,
 	 * the normal vfs interface to the local PCC file system,
 	 * the inode lock is not needed.
 	 */
-	result = file->f_op->write_iter(iocb, iter);
+	result = iocb->ki_filp->f_op->write_iter(iocb, iter);
 	iocb->ki_filp = file;
 out:
 	pcc_io_fini(inode);
@@ -1734,35 +1734,6 @@ int pcc_inode_getattr(struct inode *inode, u32 request_mask,
 	return rc;
 }
 
-ssize_t pcc_file_splice_read(struct file *in_file, loff_t *ppos,
-			     struct pipe_inode_info *pipe,
-			     size_t count, unsigned int flags,
-			     bool *cached)
-{
-	struct inode *inode = file_inode(in_file);
-	struct ll_file_data *fd = in_file->private_data;
-	struct file *pcc_file = fd->fd_pcc_file.pccf_file;
-	ssize_t result;
-
-	*cached = false;
-	if (!pcc_file)
-		return 0;
-
-	if (!file_inode(pcc_file)->i_fop->splice_read)
-		return -ENOTSUPP;
-
-	pcc_io_init(inode, PIT_SPLICE_READ, cached);
-	if (!*cached)
-		return 0;
-
-	result = file_inode(pcc_file)->i_fop->splice_read(pcc_file,
-							  ppos, pipe, count,
-							  flags);
-
-	pcc_io_fini(inode);
-	return result;
-}
-
 int pcc_fsync(struct file *file, loff_t start, loff_t end,
 	      int datasync, bool *cached)
 {
fs/lustre/llite/pcc.h +0 -5
index b13f9da8..d3aae9b 100644
@@ -184,8 +184,6 @@ enum pcc_io_type {
 	PIT_FAULT,
 	/* fsync system call handling */
 	PIT_FSYNC,
-	/* splice_read system call */
-	PIT_SPLICE_READ,
 	/* open system call */
 	PIT_OPEN,
 };
@@ -241,9 +239,6 @@ ssize_t pcc_file_write_iter(struct kiocb *iocb, struct iov_iter *iter,
 int pcc_inode_getattr(struct inode *inode, u32 request_mask,
 		      unsigned int flags, bool *cached);
 int pcc_inode_setattr(struct inode *inode, struct iattr *attr, bool *cached);
-ssize_t pcc_file_splice_read(struct file *in_file, loff_t *ppos,
-			     struct pipe_inode_info *pipe, size_t count,
-			     unsigned int flags, bool *cached);
 int pcc_fsync(struct file *file, loff_t start, loff_t end,
 	      int datasync, bool *cached);
 int pcc_file_mmap(struct file *file, struct vm_area_struct *vma, bool *cached);
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/28 lustre: llite: disable statahead_agl for sanity test_56ra

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

The sanity test_56ra can fail because statahead_agl can cause extra glimpse request.

If a stat() systemcall is made after an AGL glimpse request is sent, but before the reply has been received, the code handling the stat cannot see that glimpse request and so will send another. This elevates the number of requests counted.

There is a parameter (statahead_agl) which make it easy to disable the AGL, but it isn't implemented properly. Specifically, inodes can still be added to the sai_agls list when agl is disabled. They will never be removed, which causes an assertion to fail.

To clean this up, remove the sai_agl_valid flag, and use a test on sai_task being non-NULL instead. Also check agl_should_run() while locked against ->sai_task changing, and before adding anything to lli_agl_list.

We don't need the 'added' variable. It is perfectly OK to wake_up the sai_agl_task *before* adding to the list as long is that is all done under the lock. The task will wait for the lock before checking the list, so it won't see it being empty.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13017
Lustre-commit: 3e04c4f0757c22 ("LU-13017 tests: disable statahead_agl for sanity test_56ra")

Reviewed-on: https://review.whamcloud.com/39667

---
 fs/lustre/llite/llite_internal.h |  1 -
 fs/lustre/llite/statahead.c      | 31 +++++++++++++------------------
 2 files changed, 13 insertions(+), 19 deletions(-)
fs/lustre/llite/llite_internal.h +0 -1
index 0bd6795..9d988aac 100644
@@ -1398,7 +1398,6 @@ struct ll_statahead_info {
 	unsigned int	    sai_ls_all:1,   /* "ls -al", do stat-ahead for
 					     * hidden entries
 					     */
-				sai_agl_valid:1,/* AGL is valid for the dir */
 				sai_in_readpage:1;/* statahead in readdir() */
 	wait_queue_head_t	sai_waitq;      /* stat-ahead wait queue */
 	struct task_struct     *sai_task;       /* stat-ahead thread */
fs/lustre/llite/statahead.c +13 -18
index 895e496..a7d3a43 100644
@@ -129,7 +129,7 @@ static inline int sa_hash(int val)
 static inline int agl_should_run(struct ll_statahead_info *sai,
 				 struct inode *inode)
 {
-	return (inode && S_ISREG(inode->i_mode) && sai->sai_agl_valid);
+	return inode && S_ISREG(inode->i_mode) && sai->sai_agl_task;
 }
 
 /* statahead window is full */
@@ -424,7 +424,6 @@ static void ll_agl_add(struct ll_statahead_info *sai,
 {
 	struct ll_inode_info *child = ll_i2info(inode);
 	struct ll_inode_info *parent = ll_i2info(sai->sai_dentry->d_inode);
-	int added = 0;
 
 	spin_lock(&child->lli_agl_lock);
 	if (child->lli_agl_index == 0) {
@@ -433,18 +432,20 @@ static void ll_agl_add(struct ll_statahead_info *sai,
 
 		LASSERT(list_empty(&child->lli_agl_list));
 
-		igrab(inode);
 		spin_lock(&parent->lli_agl_lock);
-		if (list_empty(&sai->sai_agls))
-			added = 1;
-		list_add_tail(&child->lli_agl_list, &sai->sai_agls);
+		/* Re-check under the lock */
+		if (agl_should_run(sai, inode)) {
+			if (list_empty(&sai->sai_agls))
+				wake_up_process(sai->sai_agl_task);
+			igrab(inode);
+			list_add_tail(&child->lli_agl_list, &sai->sai_agls);
+		} else {
+			child->lli_agl_index = 0;
+		}
 		spin_unlock(&parent->lli_agl_lock);
 	} else {
 		spin_unlock(&child->lli_agl_lock);
 	}
-
-	if (added > 0)
-		wake_up_process(sai->sai_agl_task);
 }
 
 /* allocate sai */
@@ -936,7 +937,6 @@ static void ll_stop_agl(struct ll_statahead_info *sai)
 
 	sai->sai_agl_task = NULL;
 	spin_lock(&plli->lli_agl_lock);
-	sai->sai_agl_valid = 0;
 	while ((clli = list_first_entry_or_null(&sai->sai_agls,
 						struct ll_inode_info,
 						lli_agl_list)) != NULL) {
@@ -967,16 +967,11 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai)
 				      plli->lli_opendir_pid);
 	if (IS_ERR(task)) {
 		CERROR("can't start ll_agl thread, rc: %ld\n", PTR_ERR(task));
-		sai->sai_agl_valid = 0;
 		return;
 	}
 
 	sai->sai_agl_task = task;
-	LASSERT(sai->sai_agl_valid == 1);
 	atomic_inc(&ll_i2sbi(d_inode(parent))->ll_agl_total);
-	spin_lock(&plli->lli_agl_lock);
-	sai->sai_agl_valid = 1;
-	spin_unlock(&plli->lli_agl_lock);
 	/* Get an extra reference that the thread holds */
 	ll_sai_get(d_inode(parent));
 
@@ -1569,7 +1564,6 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry,
 	}
 
 	sai->sai_ls_all = (first == LS_FIRST_DOT_DE);
-	sai->sai_agl_valid = agl;
 
 	/*
 	 * if current lli_opendir_key was deauthorized, or dir re-opened by
@@ -1643,10 +1637,11 @@ static inline bool ll_statahead_started(struct inode *dir, bool agl)
 
 	spin_lock(&lli->lli_sa_lock);
 	sai = lli->lli_sai;
-	if (sai && sai->sai_agl_valid != agl)
+	if (sai && (sai->sai_agl_task != NULL) != agl)
 		CDEBUG(D_READA,
 		       "%s: Statahead AGL hint changed from %d to %d\n",
-		       ll_i2sbi(dir)->ll_fsname, sai->sai_agl_valid, agl);
+		       ll_i2sbi(dir)->ll_fsname,
+		       sai->sai_agl_task != NULL, agl);
 	spin_unlock(&lli->lli_sa_lock);
 
 	return !!sai;
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/28 lustre: seq_file .next functions must update *pos

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

A seq_file .next function must update *pos on EOF to a value which will cause a subsequent ->start to also return EOF.
If it doesn't the last record of the file can be returned twice to a 'read()'. Also the seq_file code will generate a warning.

This patch fixes various ->next functions to always update *pos.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13985
Lustre-commit: 817d6c11659963 ("LU-13985 lustre: seq_file .next functions must update *pos")

Reviewed-on: https://review.whamcloud.com/40035

---
 fs/lustre/lov/lov_pool.c        | 2 +-
 fs/lustre/ptlrpc/lproc_ptlrpc.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
fs/lustre/lov/lov_pool.c +1 -1
index 9e937ac..f8f14f9 100644
@@ -111,6 +111,7 @@ static void *pool_proc_next(struct seq_file *s, void *v, loff_t *pos)
 
 	LASSERTF(iter->magic == POOL_IT_MAGIC, "%08X\n", iter->magic);
 
+	(*pos)++;
 	/* test if end of file */
 	if (*pos >= pool_tgt_count(iter->pool))
 		return NULL;
@@ -122,7 +123,6 @@ static void *pool_proc_next(struct seq_file *s, void *v, loff_t *pos)
 		iter->idx = prev_idx; /* we stay on the last entry */
 		return NULL;
 	}
-	(*pos)++;
 	/* return != NULL to continue */
 	return iter;
 }
fs/lustre/ptlrpc/lproc_ptlrpc.c +1 -0
index 4d2ae14..7276f81 100644
@@ -932,6 +932,7 @@ struct ptlrpc_srh_iterator {
 	}
 
 	kfree(srhi);
+	++*pos;
 	return NULL;
 }
 
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 4/28 lustre: llite: ASSERTION( last_oap_count > 0 ) failed

In reply to James Simmons

From: Andriy Skulysh <[email protected]>

Punch uses o_blocks to send end of a region. So it can be mixed with real blocks count on error.

Update blocks count only on success.

HPE-bug-id: LUS-7407
WC-bug-id: https://jira.whamcloud.com/browse/LU-13992
Lustre-commit: a56fefc535677b ("LU-13992 llite: ASSERTION( last_oap_count > 0 ) failed")

Reviewed-on: https://review.whamcloud.com/40050

---
 fs/lustre/osc/osc_io.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
fs/lustre/osc/osc_io.c +9 -7
index 7ec059a..6121f39 100644
@@ -691,14 +691,16 @@ void osc_io_setattr_end(const struct lu_env *env,
 	if (cl_io_is_trunc(io)) {
 		u64 size = io->u.ci_setattr.sa_attr.lvb_size;
 
-		cl_object_attr_lock(obj);
-		if (oa->o_valid & OBD_MD_FLBLOCKS) {
-			attr->cat_blocks = oa->o_blocks;
-			cl_valid |= CAT_BLOCKS;
-		}
+		if (result == 0) {
+			cl_object_attr_lock(obj);
+			if (oa->o_valid & OBD_MD_FLBLOCKS) {
+				attr->cat_blocks = oa->o_blocks;
+				cl_valid |= CAT_BLOCKS;
+			}
 
-		cl_object_attr_update(env, obj, attr, cl_valid);
-		cl_object_attr_unlock(obj);
+			cl_object_attr_update(env, obj, attr, cl_valid);
+			cl_object_attr_unlock(obj);
+		}
 		osc_trunc_check(env, io, oio, size);
 		osc_cache_truncate_end(env, oio->oi_trunc);
 		oio->oi_trunc = NULL;
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 5/28 lnet: o2ib: raise bind cap before resolving address

In reply to James Simmons

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

In kiblnd_resolve_addr(), ensure that the current task has CAP_NET_BIND_SERVICE before calling rdma_resolve_addr() with a protected source port.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14006
Lustre-commit: 1e4bd16acfa26a ("LU-14006 o2ib: raise bind cap before resolving address")

Reviewed-on: https://review.whamcloud.com/40127

---
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c | 38 +++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)
net/lnet/klnds/o2iblnd/o2iblnd_cb.c +34 -4
index ba2f46f..b642162 100644
@@ -1219,14 +1219,17 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	spin_unlock(&conn->ibc_lock);
 }
 
-static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
-			       struct sockaddr_in *srcaddr,
-			       struct sockaddr_in *dstaddr,
-			       int timeout_ms)
+static int
+kiblnd_resolve_addr_cap(struct rdma_cm_id *cmid,
+			struct sockaddr_in *srcaddr,
+			struct sockaddr_in *dstaddr,
+			int timeout_ms)
 {
 	unsigned short port;
 	int rc;
 
+	LASSERT(capable(CAP_NET_BIND_SERVICE));
+
 	/* allow the port to be reused */
 	rc = rdma_set_reuseaddr(cmid, 1);
 	if (rc) {
@@ -1256,6 +1259,33 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 	return rc;
 }
 
+static int
+kiblnd_resolve_addr(struct rdma_cm_id *cmid,
+		    struct sockaddr_in *srcaddr,
+		    struct sockaddr_in *dstaddr,
+		    int timeout_ms)
+{
+	const struct cred *old_creds = NULL;
+	struct cred *new_creds;
+	int rc;
+
+	if (!capable(CAP_NET_BIND_SERVICE)) {
+		new_creds = prepare_creds();
+		if (!new_creds)
+			return -ENOMEM;
+
+		cap_raise(new_creds->cap_effective, CAP_NET_BIND_SERVICE);
+		old_creds = override_creds(new_creds);
+	}
+
+	rc = kiblnd_resolve_addr_cap(cmid, srcaddr, dstaddr, timeout_ms);
+
+	if (old_creds)
+		revert_creds(old_creds);
+
+	return rc;
+}
+
 static void
 kiblnd_connect_peer(struct kib_peer_ni *peer_ni)
 {
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 6/28 lustre: use memalloc_nofs_save() for GFP_NOFS kvmalloc allocations.

In reply to James Simmons

From: NeilBrown <[email protected]>

The allocation of lo_sub should be GFP_NOFS as it can happen in support of write-out, and should allow vmalloc as the array can be as much as 2000 pointers (16K).
So change it to kvmalloc_array() and use memalloc_nofs_save() as GFP_NOFS doesn't work in kvmalloc_array().

The allocation in echo_client passes GFP_NOFS to kvmalloc_array() which causes it to map directly to kmalloc_array().
So use memalloc_nofs_save() there too.

---
 fs/lustre/lov/lov_object.c      | 13 +++++++------
 fs/lustre/obdecho/echo_client.c |  7 ++++++-
 2 files changed, 13 insertions(+), 7 deletions(-)
fs/lustre/lov/lov_object.c +7 -6
index 7285276..0762cc5 100644
@@ -38,6 +38,7 @@
 
 #define DEBUG_SUBSYSTEM S_LOV
 
+#include <linux/sched/mm.h>
 #include "lov_cl_internal.h"
 
 static inline struct lov_device *lov_object_dev(struct lov_object *obj)
@@ -207,6 +208,7 @@ static int lov_init_raid0(const struct lu_env *env, struct lov_device *dev,
 	struct cl_object_conf *subconf = &lti->lti_stripe_conf;
 	struct lu_fid *ofid = &lti->lti_fid;
 	struct cl_object *stripe;
+	unsigned int flags;
 	int result;
 	int psz, sz;
 	int i;
@@ -214,8 +216,10 @@ static int lov_init_raid0(const struct lu_env *env, struct lov_device *dev,
 	spin_lock_init(&r0->lo_sub_lock);
 	r0->lo_nr = lse->lsme_stripe_count;
 
-	r0->lo_sub = kcalloc(r0->lo_nr, sizeof(r0->lo_sub[0]),
-			     GFP_KERNEL);
+	flags = memalloc_nofs_save();
+	r0->lo_sub = kvmalloc_array(r0->lo_nr, sizeof(r0->lo_sub[0]),
+				    GFP_KERNEL | __GFP_ZERO);
+	memalloc_nofs_restore(flags);
 	if (!r0->lo_sub)
 		return -ENOMEM;
 
@@ -335,10 +339,7 @@ static void lov_fini_raid0(const struct lu_env *env,
 {
 	struct lov_layout_raid0 *r0 = &lle->lle_raid0;
 
-	if (r0->lo_sub) {
-		kvfree(r0->lo_sub);
-		r0->lo_sub = NULL;
-	}
+	kvfree(r0->lo_sub);
 }
 
 static int lov_print_raid0(const struct lu_env *env, void *cookie,
fs/lustre/obdecho/echo_client.c +6 -1
index a52e0362..3bee0c2 100644
@@ -34,6 +34,7 @@
 #define DEBUG_SUBSYSTEM S_ECHO
 
 #include <linux/highmem.h>
+#include <linux/sched/mm.h>
 #include <obd.h>
 #include <obd_support.h>
 #include <obd_class.h>
@@ -1369,6 +1370,7 @@ static int echo_client_prep_commit(const struct lu_env *env,
 	struct niobuf_remote rnb;
 	u64 off;
 	u64 npages, tot_pages;
+	unsigned int flags;
 	int i, ret = 0, brw_flags = 0;
 
 	if (count <= 0 || (count & (~PAGE_MASK)) != 0)
@@ -1377,8 +1379,11 @@ static int echo_client_prep_commit(const struct lu_env *env,
 	npages = batch >> PAGE_SHIFT;
 	tot_pages = count >> PAGE_SHIFT;
 
+	flags = memalloc_nofs_save();
 	lnb = kvmalloc_array(npages, sizeof(*lnb),
-			     GFP_NOFS | __GFP_ZERO);
+			     GFP_KERNEL | __GFP_ZERO);
+	memalloc_nofs_restore(flags);
+
 	if (!lnb) {
 		ret = -ENOMEM;
 		goto out;
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 7/28 lnet: o2iblnd: Don't retry indefinitely

In reply to James Simmons

From: Amir Shehata <[email protected]>

If peer is down don't retry indefinitely. Use the retry_count parameter to restrict the number of retries. After which the connection fails and error is propagated up.

This prevents long timeouts when mounting a file system with nodes which might have their NIDs configured in the FS, but the nodes have been taken offline.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13972
Lustre-commit: 7c8ad11ef08f0f ("LU-13972 o2iblnd: Don't retry indefinitely")

Reviewed-on: https://review.whamcloud.com/39981

---
 net/lnet/klnds/o2iblnd/o2iblnd.h           | 2 ++
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c        | 9 +++++++++
 net/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)
net/lnet/klnds/o2iblnd/o2iblnd.h +2 -0
index 9a2fb42..9b2f043 100644
@@ -626,6 +626,8 @@ struct kib_peer_ni {
 	unsigned char		ibp_races;
 	/* # consecutive reconnection attempts to this peer_ni */
 	unsigned int		ibp_reconnected;
+	/* number of total active retries */
+	unsigned int		ibp_retries;
 	/* errno on closing this peer_ni */
 	int			ibp_error;
 	/* max map_on_demand */
net/lnet/klnds/o2iblnd/o2iblnd_cb.c +9 -0
index b642162..9de733d 100644
@@ -2181,6 +2181,9 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	/* connection established */
 	write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
+	/* reset retry count */
+	peer_ni->ibp_retries = 0;
+
 	conn->ibc_last_send = ktime_get();
 	kiblnd_set_conn_state(conn, IBLND_CONN_ESTABLISHED);
 	kiblnd_peer_alive(peer_ni);
@@ -2631,6 +2634,11 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 		goto out;
 	}
 
+	if (peer_ni->ibp_retries > *kiblnd_tunables.kib_retry_count) {
+		reason = "retry count exceeded due to no listener";
+		goto out;
+	}
+
 	switch (why) {
 	default:
 		reason = "Unknown";
@@ -2688,6 +2696,7 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 		break;
 
 	case IBLND_REJECT_INVALID_SRV_ID:
+		peer_ni->ibp_retries++;
 		reason = "invalid service id";
 		break;
 	}
net/lnet/klnds/o2iblnd/o2iblnd_modparams.c +1 -1
index 73ad22d..029c9fb 100644
@@ -93,7 +93,7 @@
 
 static int retry_count = 5;
 module_param(retry_count, int, 0644);
-MODULE_PARM_DESC(retry_count, "Retransmissions when no ACK received");
+MODULE_PARM_DESC(retry_count, "Number of times to retry connection operations");
 
 static int rnr_retry_count = 6;
 module_param(rnr_retry_count, int, 0644);
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH 8/28 lustre: llite: rmdir releases inode on client

In reply to James Simmons

From: Lai Siyao <[email protected]>

Same as file unlink, rmdir should release inode on client, to achieve this, ll_rmdir() update inode i_nlink after rmdir, then the last iput() will release the inode.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13983
Lustre-commit: 4a4794364eb05f ("LU-13983 llite: rmdir releases inode on client")

Reviewed-on: https://review.whamcloud.com/40011

---
 fs/lustre/llite/namei.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/lustre/llite/namei.c +11 -0
index f9c10d0..da6b729 100644
@@ -1659,12 +1659,23 @@ static int ll_rmdir(struct inode *dir, struct dentry *dchild)
 	rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request);
 	ll_finish_md_op_data(op_data);
 	if (rc == 0) {
+		struct mdt_body *body;
+
 		ll_update_times(request, dir);
 		ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_RMDIR,
 				   ktime_us_delta(ktime_get(), kstart));
+		/*
+		 * The server puts attributes in on the last unlink, use them
+		 * to update the link count so the inode can be freed
+		 * immediately.
+		 */
+		body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY);
+		if (body->mbo_valid & OBD_MD_FLNLINK)
+			set_nlink(dchild->d_inode, body->mbo_nlink);
 	}
 
 	ptlrpc_req_finished(request);
+
 	return rc;
 }
 
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH 9/28 lustre: gss: update sequence in case of target disconnect

In reply to James Simmons

From: Sebastien Buisson <[email protected]>

Client to OST connections can go idle, leading to target disconnect. In this event, maintaining correct sequence number ensures that GSS does not erroneously consider requests as replays.
Sequence is normally updated on export destroy, but this can occur too late, ie after a new target connect request has been processed. So explicitly update sec context at disconnect time.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13498
Lustre-commit: 1275857c178fdf ("LU-13498 gss: update sequence in case of target disconnect")

Reviewed-on: https://review.whamcloud.com/40122

---
 fs/lustre/ptlrpc/sec.c      | 4 ++--
 fs/lustre/ptlrpc/sec_null.c | 8 --------
 2 files changed, 2 insertions(+), 10 deletions(-)
fs/lustre/ptlrpc/sec.c +2 -2
index ca8a646..44c15e6 100644
@@ -626,8 +626,8 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout)
 		return 0;
 
 	if (unlikely(test_bit(PTLRPC_CTX_NEW_BIT, &ctx->cc_flags))) {
-		LASSERT(ctx->cc_ops->refresh);
-		ctx->cc_ops->refresh(ctx);
+		if (ctx->cc_ops->refresh)
+			ctx->cc_ops->refresh(ctx);
 	}
 	LASSERT(test_bit(PTLRPC_CTX_NEW_BIT, &ctx->cc_flags) == 0);
 
fs/lustre/ptlrpc/sec_null.c +0 -8
index 14058bf..97c4e19 100644
@@ -66,13 +66,6 @@ enum lustre_sec_part null_decode_sec_part(struct lustre_msg *msg)
 	return (msg->lm_secflvr >> 24) & 0xFF;
 }
 
-static int null_ctx_refresh(struct ptlrpc_cli_ctx *ctx)
-{
-	/* should never reach here */
-	LBUG();
-	return 0;
-}
-
 static
 int null_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
 {
@@ -374,7 +367,6 @@ int null_authorize(struct ptlrpc_request *req)
 }
 
 static struct ptlrpc_ctx_ops null_ctx_ops = {
-	.refresh		= null_ctx_refresh,
 	.sign			= null_ctx_sign,
 	.verify			= null_ctx_verify,
 };
Signature · 1 line
1.8.3.1
#10 lore raw

PATCH 10/28 lustre: lov: doesn't check lov_refcount

In reply to James Simmons

From: Hongchao Zhang <[email protected]>

In lov_cleanup, the check of each OSC is protected by lov_tgt_getrefs, which will increment the "lov_refcount", so the "lov_refcount" shouldn't be checked inside because it is always larger than 0.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13719
Lustre-commit: 6ae92a7f1bd94c ("LU-13719 lov: doesn't check lov_refcount")

Reviewed-on: https://review.whamcloud.com/39702

---
 fs/lustre/lov/lov_obd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/lustre/lov/lov_obd.c +1 -2
index d88d325..c8654bd 100644
@@ -820,8 +820,7 @@ static int lov_cleanup(struct obd_device *obd)
 				continue;
 
 			/* Inactive targets may never have connected */
-			if (lov->lov_tgts[i]->ltd_active ||
-			    atomic_read(&lov->lov_refcount))
+			if (lov->lov_tgts[i]->ltd_active)
 			    /* We should never get here - these
 			     * should have been removed in the
 			     * disconnect.
Signature · 1 line
1.8.3.1
#11 lore raw

PATCH 11/28 lustre: ptlrpc: remove unused code at pinger

In reply to James Simmons

From: Alexander Boyko <[email protected]>

The timeout_list was previously used for grant shrinking, but right now is dead code.

HPE-bug-id: LUS-8520

Fixes abc88e83673c ("lustre: osc: depart grant shrinking from pinger")

WC-bug-id: https://jira.whamcloud.com/browse/LU-14031
Lustre-commit: f022663059414 ("LU-14031 ptlrpc: remove unused code at pinger")

Reviewed-on: https://review.whamcloud.com/40243

---
 fs/lustre/include/lustre_net.h |   5 --
 fs/lustre/ptlrpc/pinger.c      | 137 -----------------------------------------
 2 files changed, 142 deletions(-)
fs/lustre/include/lustre_net.h +0 -5
index 1e7fe03..61be05c 100644
@@ -2369,11 +2369,6 @@ enum timeout_event {
 typedef int (*timeout_cb_t)(struct timeout_item *, void *);
 int ptlrpc_pinger_add_import(struct obd_import *imp);
 int ptlrpc_pinger_del_import(struct obd_import *imp);
-int ptlrpc_add_timeout_client(time64_t time, enum timeout_event event,
-			      timeout_cb_t cb, void *data,
-			      struct list_head *obd_list);
-int ptlrpc_del_timeout_client(struct list_head *obd_list,
-			      enum timeout_event event);
 struct ptlrpc_request *ptlrpc_prep_ping(struct obd_import *imp);
 int ptlrpc_obd_ping(struct obd_device *obd);
 void ptlrpc_pinger_ir_up(void);
fs/lustre/ptlrpc/pinger.c +0 -137

181 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#12 lore raw

PATCH 12/28 lustre: mdc: remote object support getattr from cache

In reply to James Simmons

From: Lai Siyao <[email protected]>

For historical reason, IT_GETATTR lock revalidate matches LOOKUP|UPDATE|PERM lock bits because for MDS < 2.4, permission is protected by LOOKUP lock, but this will cause remote object not able to match the cached lock because LOOKUP and UPDATE lock are fetched separately.

Add sanity 803b, and rename 803 to 803a.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13437
Lustre-commit: 72a1ca996e3a35 ("LU-13437 mdc: remote object support getattr from cache")

Reviewed-on: https://review.whamcloud.com/40218

---
 fs/lustre/mdc/mdc_locks.c | 1 -
 1 file changed, 1 deletion(-)
fs/lustre/mdc/mdc_locks.c +0 -1
index 72ee070..a82e8ca 100644
@@ -1235,7 +1235,6 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
 			 * by LOOKUP lock, so it needs to match all bits here.
 			 */
 			policy.l_inodebits.bits = MDS_INODELOCK_UPDATE |
-						  MDS_INODELOCK_LOOKUP |
 						  MDS_INODELOCK_PERM;
 			break;
 		case IT_READDIR:
Signature · 1 line
1.8.3.1
#13 lore raw

PATCH 13/28 lustre: llite: pass name in getattr by FID

In reply to James Simmons

From: Lai Siyao <[email protected]>

Now parent FID is packed in getattr_by_FID request
(see https://review.whamcloud.com/39290), it should also pass in name from llite, so that lmv can replace fid1 with stripe FID, otherwise MDS may treat sub files under striped directory as remote object.

Note, the name is not packed in request, because if it's packed, MDS will getattr by name instead of FID.

Fixes 3a3a9eeaa ("lustre: llite: pack parent FID in getattr")

WC-bug-id: https://jira.whamcloud.com/browse/LU-13437
Lustre-commit: 90ebab5833007d ("LU-13437 llite: pass name in getattr by FID")

Reviewed-on: https://review.whamcloud.com/40219

---
 fs/lustre/include/obd.h     |  1 +
 fs/lustre/llite/file.c      | 15 +++++++++++----
 fs/lustre/llite/llite_lib.c |  4 +++-
 fs/lustre/lmv/lmv_intent.c  | 22 +++++++++++++++++++---
 fs/lustre/lmv/lmv_obd.c     |  8 ++++++--
 5 files changed, 40 insertions(+), 10 deletions(-)
fs/lustre/include/obd.h +1 -0
index 39e3d51..a017997 100644
@@ -704,6 +704,7 @@ enum md_op_flags {
 	MF_MDC_CANCEL_FID3	= BIT(2),
 	MF_MDC_CANCEL_FID4	= BIT(3),
 	MF_GET_MDT_IDX		= BIT(4),
+	MF_GETATTR_BY_FID	= BIT(5),
 };
 
 enum md_cli_flags {
fs/lustre/llite/file.c +11 -4
index 0a9a689..3ba9152 100644
@@ -4587,22 +4587,29 @@ static int ll_inode_revalidate(struct dentry *dentry, enum ldlm_intent_flags op)
 	};
 	struct ptlrpc_request *req = NULL;
 	struct md_op_data *op_data;
+	const char *name = NULL;
+	size_t namelen = 0;
 	int rc = 0;
 
 	CDEBUG(D_VFSTRACE, "VFS Op:inode=" DFID "(%p),name=%pd\n",
 	       PFID(ll_inode2fid(inode)), inode, dentry);
 
-	if (exp_connect_flags2(exp) & OBD_CONNECT2_GETATTR_PFID)
+	if (exp_connect_flags2(exp) & OBD_CONNECT2_GETATTR_PFID) {
 		parent = dentry->d_parent->d_inode;
-	else
+		name = dentry->d_name.name;
+		namelen = dentry->d_name.len;
+	} else {
 		parent = inode;
+	}
 
-	/* Call getattr by fid, so do not provide name at all. */
-	op_data = ll_prep_md_op_data(NULL, parent, inode, NULL, 0, 0,
+	op_data = ll_prep_md_op_data(NULL, parent, inode, name, namelen, 0,
 				     LUSTRE_OPC_ANY, NULL);
 	if (IS_ERR(op_data))
 		return PTR_ERR(op_data);
 
+	/* Call getattr by fid */
+	if (exp_connect_flags2(exp) & OBD_CONNECT2_GETATTR_PFID)
+		op_data->op_flags = MF_GETATTR_BY_FID;
 	rc = md_intent_lock(exp, op_data, &oit, &req, &ll_md_blocking_ast, 0);
 	ll_finish_md_op_data(op_data);
 	if (rc < 0) {
fs/lustre/llite/llite_lib.c +3 -1
index 8ef2437..d94c6ca 100644
@@ -2811,7 +2811,9 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
 		if (namelen > ll_i2sbi(i1)->ll_namelen)
 			return ERR_PTR(-ENAMETOOLONG);
 
-		if (!lu_name_is_valid_2(name, namelen))
+		/* "/" is not valid name, but it's allowed */
+		if (!lu_name_is_valid_2(name, namelen) &&
+		    strncmp("/", name, namelen) != 0)
 			return ERR_PTR(-EINVAL);
 	}
 
fs/lustre/lmv/lmv_intent.c +19 -3
index 3960b93..ad59b64 100644
@@ -448,13 +448,29 @@ static int lmv_intent_lookup(struct obd_export *exp,
 	}
 
 retry:
-	if (op_data->op_name) {
+	if (op_data->op_flags & MF_GETATTR_BY_FID) {
+		/* getattr by FID, replace fid1 with stripe FID */
+		LASSERT(op_data->op_name);
+		tgt = lmv_locate_tgt(lmv, op_data);
+		if (IS_ERR(tgt))
+			return PTR_ERR(tgt);
+
+		/* name is used to locate stripe target, clear it here
+		 * to avoid packing name in request, so that MDS knows
+		 * it's getattr by FID.
+		 */
+		op_data->op_name = NULL;
+		op_data->op_namelen = 0;
+
+		/* getattr request is sent to MDT where fid2 inode is */
+		tgt = lmv_fid2tgt(lmv, &op_data->op_fid2);
+	} else if (op_data->op_name) {
+		/* getattr by name */
 		tgt = lmv_locate_tgt(lmv, op_data);
 		if (!fid_is_sane(&op_data->op_fid2))
 			fid_zero(&op_data->op_fid2);
-	} else if (fid_is_sane(&op_data->op_fid2)) {
-		tgt = lmv_fid2tgt(lmv, &op_data->op_fid2);
 	} else {
+		/* old way to getattr by FID, parent FID not packed */
 		tgt = lmv_fid2tgt(lmv, &op_data->op_fid1);
 	}
 	if (IS_ERR(tgt))
fs/lustre/lmv/lmv_obd.c +6 -2
index 5a75c69..fa1dae5 100644
@@ -1513,6 +1513,9 @@ static struct lu_tgt_desc *lmv_locate_tgt_rr(struct lmv_obd *lmv, u32 *mdt)
 	return ERR_PTR(-ENODEV);
 }
 
+/* locate MDT by file name, for striped directory, the file name hash decides
+ * which stripe its dirent is stored.
+ */
 static struct lmv_tgt_desc *
 lmv_locate_tgt_by_name(struct lmv_obd *lmv, struct lmv_stripe_md *lsm,
 		       const char *name, int namelen, struct lu_fid *fid,
@@ -1564,8 +1567,9 @@ static struct lu_tgt_desc *lmv_locate_tgt_rr(struct lmv_obd *lmv, u32 *mdt)
  * For plain direcotry, it just locate the MDT of op_data->op_fid1.
  *
  * @lmv:	LMV device
- * @op_data:	client MD stack parameters, name, namelen
- *		mds_num etc.
+ * @op_data:	client MD stack parameters, name, namelen etc,
+ *		op_mds and op_fid1 will be updated if op_mea1
+ *		indicates fid1 represents a striped directory.
  *
  * Returns:	pointer to the lmv_tgt_desc if succeed.
  *		ERR_PTR(errno) if failed.
Signature · 1 line
1.8.3.1
#14 lore raw

PATCH 14/28 lnet: o2iblnd: 'Timed out tx' error message

In reply to James Simmons

From: Brian Behlendorf <[email protected]>

Trivial fix to report the total RDMA time outstanding rather than the number of seconds past the deadline.

WC-bug-id: https://jira.whamcloud.com/browse/LU-1742
Lustre-commit: 2be289a2b1f12b ("LU-1742 o2iblnd: 'Timed out tx' error message")

Reviewed-on: https://review.whamcloud.com/3622

---
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c | 1 +
 1 file changed, 1 insertion(+)
net/lnet/klnds/o2iblnd/o2iblnd_cb.c +1 -0
index 9de733d..3d7026b 100644
@@ -3219,6 +3219,7 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 		if (ktime_compare(ktime_get(), tx->tx_deadline) >= 0) {
 			CERROR("Timed out tx: %s, %lld seconds\n",
 			       kiblnd_queue2str(conn, txs),
+			       kiblnd_timeout() +
 			       ktime_ms_delta(ktime_get(),
 					      tx->tx_deadline) / MSEC_PER_SEC);
 			return 1;
Signature · 1 line
1.8.3.1
#15 lore raw

PATCH 15/28 lustre: ldlm: Fix unbounded OBD_FAIL_LDLM_CANCEL_BL_CB_RACE wait

In reply to James Simmons

From: Oleg Drokin <[email protected]>

in ldlm_handle_cp_callback the while loop is clearly supposed to be limited by the "to" value of 1 second, but is not. Seems to have been broken by all the Solaris porting in HEAD all the way back in 2008.
Restore the to assignment to make it not hang indefinitely.

Fixes adde80ff ("Land b_head_libcfs onto OpenSFS tree HEAD")

WC-bug-id: https://jira.whamcloud.com/browse/LU-14069
Lustre-commit: 5da99051e58b9e ("LU-14069 ldlm: Fix unbounded OBD_FAIL_LDLM_CANCEL_BL_CB_RACE wait")

Reviewed-on: https://review.whamcloud.com/40375

---
 fs/lustre/ldlm/ldlm_lockd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/lustre/ldlm/ldlm_lockd.c +1 -1
index 4a91a7f..1ae65b829 100644
@@ -223,7 +223,7 @@ static int ldlm_handle_cp_callback(struct ptlrpc_request *req,
 		ldlm_callback_reply(req, 0);
 
 		while (to > 0) {
-			schedule_timeout_interruptible(to);
+			to = schedule_timeout_interruptible(to);
 			if (ldlm_is_granted(lock) ||
 			    ldlm_is_destroyed(lock))
 				break;
Signature · 1 line
1.8.3.1
#16 lore raw

PATCH 16/28 lustre: ldlm: group locks for DOM IBIT lock

In reply to James Simmons

From: Vitaly Fertman <[email protected]>

Group lock is supposed to be taken on such operations as layout swap used for e.g. HSM, and is to be taken for DOM locks as well.

HPE-bug-id: LUS-8987
WC-bug-id: https://jira.whamcloud.com/browse/LU-13645
Lustre-commit: 06740440363424 (LU-13645 ldlm: group locks for DOM IBIT lock")

Reviewed-on: https://review.whamcloud.com/39406

---
 fs/lustre/ldlm/ldlm_inodebits.c        |  2 ++
 fs/lustre/ldlm/ldlm_lock.c             | 12 ++++++++++--
 fs/lustre/mdc/mdc_dev.c                | 10 ++++++++--
 fs/lustre/ptlrpc/wiretest.c            |  6 +++++-
 include/uapi/linux/lustre/lustre_idl.h |  1 +
 5 files changed, 26 insertions(+), 5 deletions(-)
fs/lustre/ldlm/ldlm_inodebits.c +2 -0
index 2288eb5..a367ff1 100644
@@ -59,6 +59,7 @@ void ldlm_ibits_policy_wire_to_local(const union ldlm_wire_policy_data *wpolicy,
 				     union ldlm_policy_data *lpolicy)
 {
 	lpolicy->l_inodebits.bits = wpolicy->l_inodebits.bits;
+	lpolicy->l_inodebits.li_gid = wpolicy->l_inodebits.li_gid;
 }
 
 void ldlm_ibits_policy_local_to_wire(const union ldlm_policy_data *lpolicy,
@@ -66,6 +67,7 @@ void ldlm_ibits_policy_local_to_wire(const union ldlm_policy_data *lpolicy,
 {
 	memset(wpolicy, 0, sizeof(*wpolicy));
 	wpolicy->l_inodebits.bits = lpolicy->l_inodebits.bits;
+	wpolicy->l_inodebits.li_gid = lpolicy->l_inodebits.li_gid;
 }
 
 /**
fs/lustre/ldlm/ldlm_lock.c +10 -2
index 0dbd4f3..56f1550 100644
@@ -1111,6 +1111,12 @@ static bool lock_matches(struct ldlm_lock *lock, void *vdata)
 		     data->lmd_policy->l_inodebits.bits) !=
 		    data->lmd_policy->l_inodebits.bits)
 			return false;
+
+		if (unlikely(match == LCK_GROUP) &&
+		    data->lmd_policy->l_inodebits.li_gid != LDLM_GID_ANY &&
+		    lpol->l_inodebits.li_gid !=
+		    data->lmd_policy->l_inodebits.li_gid)
+			return false;
 		break;
 	default:
 		break;
@@ -1903,7 +1909,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 	switch (resource->lr_type) {
 	case LDLM_EXTENT:
 		libcfs_debug_msg(msgdata,
-				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lld lvb_type: %d\n",
+				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) gid %llu flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lld lvb_type: %d\n",
 				 &vaf,
 				 ldlm_lock_to_ns_name(lock), lock,
 				 lock->l_handle.h_cookie,
@@ -1918,6 +1924,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				 lock->l_policy_data.l_extent.end,
 				 lock->l_req_extent.start,
 				 lock->l_req_extent.end,
+				 lock->l_req_extent.gid,
 				 lock->l_flags, nid,
 				 lock->l_remote_handle.cookie,
 				 exp ? refcount_read(&exp->exp_handle.h_ref) : -99,
@@ -1949,7 +1956,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 
 	case LDLM_IBITS:
 		libcfs_debug_msg(msgdata,
-				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lld lvb_type: %d\n",
+				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s gid %llu flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lld lvb_type: %d\n",
 				 &vaf,
 				 ldlm_lock_to_ns_name(lock),
 				 lock, lock->l_handle.h_cookie,
@@ -1961,6 +1968,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				 lock->l_policy_data.l_inodebits.bits,
 				 atomic_read(&resource->lr_refcount),
 				 ldlm_typename[resource->lr_type],
+				 lock->l_policy_data.l_inodebits.li_gid,
 				 lock->l_flags, nid,
 				 lock->l_remote_handle.cookie,
 				 exp ? refcount_read(&exp->exp_handle.h_ref) : -99,
fs/lustre/mdc/mdc_dev.c +8 -2
index 329371b..90b60f5 100644
@@ -40,10 +40,13 @@
 #include "mdc_internal.h"
 
 static void mdc_lock_build_policy(const struct lu_env *env,
+				  const struct cl_lock *lock,
 				  union ldlm_policy_data *policy)
 {
 	memset(policy, 0, sizeof(*policy));
 	policy->l_inodebits.bits = MDS_INODELOCK_DOM;
+	if (lock)
+		policy->l_inodebits.li_gid = lock->cll_descr.cld_gid;
 }
 
 int mdc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data)
@@ -144,7 +147,8 @@ struct ldlm_lock *mdc_dlmlock_at_pgoff(const struct lu_env *env,
 	enum ldlm_match_flags match_flags = 0;
 
 	fid_build_reg_res_name(lu_object_fid(osc2lu(obj)), resname);
-	mdc_lock_build_policy(env, policy);
+	mdc_lock_build_policy(env, NULL, policy);
+	policy->l_inodebits.li_gid = LDLM_GID_ANY;
 
 	flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING;
 	if (dap_flags & OSC_DAP_FL_TEST_LOCK)
@@ -867,7 +871,7 @@ static int mdc_lock_enqueue(const struct lu_env *env,
 	 * osc_lock.
 	 */
 	fid_build_reg_res_name(lu_object_fid(osc2lu(osc)), resname);
-	mdc_lock_build_policy(env, policy);
+	mdc_lock_build_policy(env, lock, policy);
 	LASSERT(!oscl->ols_speculative);
 	result = mdc_enqueue_send(env, osc_export(osc), resname,
 				  &oscl->ols_flags, policy,
@@ -931,6 +935,8 @@ int mdc_lock_init(const struct lu_env *env, struct cl_object *obj,
 
 	ols->ols_flags = flags;
 	ols->ols_speculative = !!(enqflags & CEF_SPECULATIVE);
+	if (lock->cll_descr.cld_mode == CLM_GROUP)
+		ols->ols_flags |= LDLM_FL_ATOMIC_CB;
 
 	if (ols->ols_flags & LDLM_FL_HAS_INTENT) {
 		ols->ols_flags |= LDLM_FL_BLOCK_GRANTED;
fs/lustre/ptlrpc/wiretest.c +5 -1
index 556aaff..9b1caf4 100644
@@ -3249,12 +3249,16 @@ void lustre_assert_wire_constants(void)
 		 (long long)(int)sizeof(((struct ldlm_extent *)0)->gid));
 
 	/* Checks for struct ldlm_inodebits */
-	LASSERTF((int)sizeof(struct ldlm_inodebits) == 16, "found %lld\n",
+	LASSERTF((int)sizeof(struct ldlm_inodebits) == 24, "found %lld\n",
 		 (long long)(int)sizeof(struct ldlm_inodebits));
 	LASSERTF((int)offsetof(struct ldlm_inodebits, bits) == 0, "found %lld\n",
 		 (long long)(int)offsetof(struct ldlm_inodebits, bits));
 	LASSERTF((int)sizeof(((struct ldlm_inodebits *)0)->bits) == 8, "found %lld\n",
 		 (long long)(int)sizeof(((struct ldlm_inodebits *)0)->bits));
+	LASSERTF((int)offsetof(struct ldlm_inodebits, li_gid) == 16, "found %lld\n",
+		 (long long)(int)offsetof(struct ldlm_inodebits, li_gid));
+	LASSERTF((int)sizeof(((struct ldlm_inodebits *)0)->li_gid) == 8, "found %lld\n",
+		 (long long)(int)sizeof(((struct ldlm_inodebits *)0)->li_gid));
 
 	/* Checks for struct ldlm_flock_wire */
 	LASSERTF((int)sizeof(struct ldlm_flock_wire) == 32, "found %lld\n",
include/uapi/linux/lustre/lustre_idl.h +1 -0
index fda56d8..34b2367 100644
@@ -2206,6 +2206,7 @@ static inline bool ldlm_extent_equal(const struct ldlm_extent *ex1,
 struct ldlm_inodebits {
 	__u64 bits;
 	__u64 cancel_bits; /* for lock convert */
+	__u64 li_gid;
 };
 
 struct ldlm_flock_wire {
Signature · 1 line
1.8.3.1
#17 lore raw

PATCH 17/28 lustre: ptlrpc: decrease time between reconnection

In reply to James Simmons

From: Alexander Boyko <[email protected]>

When a connection get a timeout or get an error reply from a sever, the next attempt happens after PING_INTERVAL. It is equal to obd_timeout/4. When a first reconnection fails, a second go to failover pair. And a third connection go to a original server. Only 3 reconnection before server evicts client base on blocking ast timeout. Some times a first failed and the last is a bit late, so client is evicted. It is better to try reconnect with a timeout equal to a connection request deadline, it would increase a number of attempts in 5 times for a large obd_timeout. For example,
obd_timeout=200
- [ 1597902357, CONNECTING ]
- [ 1597902357, FULL ]
- [ 1597902422, DISCONN ]
- [ 1597902422, CONNECTING ]
- [ 1597902433, DISCONN ]
- [ 1597902473, CONNECTING ]
- [ 1597902473, DISCONN ] <- ENODEV from a failover pair
- [ 1597902523, CONNECTING ]
- [ 1597902539, DISCONN ]

The patch adds a logic to wakeup pinger for failed connection request with ETIMEDOUT or ENODEV. It adds imp_next_ping processing for ptlrpc_pinger_main() time_to_next_wake calculation, and fixes setting of imp_next_ping value.

HPE-bug-id: LUS-8520
WC-bug-id: https://jira.whamcloud.com/browse/LU-14031
Lustre-commit: de8ed5f19f0413 ("LU-14031 ptlrpc: decrease time between reconnection")

Reviewed-on: https://review.whamcloud.com/40244

---
 fs/lustre/ptlrpc/events.c |  5 ++++
 fs/lustre/ptlrpc/import.c | 36 ++++++++++++++++++++++-
 fs/lustre/ptlrpc/niobuf.c |  2 --
 fs/lustre/ptlrpc/pinger.c | 73 ++++++++++++++++++++++++++++++-----------------
 4 files changed, 87 insertions(+), 29 deletions(-)
fs/lustre/ptlrpc/events.c +5 -0
index 0943612..fe33600 100644
@@ -59,6 +59,11 @@ void request_out_callback(struct lnet_event *ev)
 
 	DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status);
 
+	/* Do not update imp_next_ping for connection request */
+	if (lustre_msg_get_opc(req->rq_reqmsg) !=
+	    req->rq_import->imp_connect_op)
+		ptlrpc_pinger_sending_on_import(req->rq_import);
+
 	sptlrpc_request_out_callback(req);
 
 	spin_lock(&req->rq_lock);
fs/lustre/ptlrpc/import.c +35 -1
index 4e573cd..21ce593 100644
@@ -1037,7 +1037,6 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
 		 */
 		imp->imp_force_reconnect = ptlrpc_busy_reconnect(rc);
 		spin_unlock(&imp->imp_lock);
-		ptlrpc_maybe_ping_import_soon(imp);
 		goto out;
 	}
 
@@ -1303,6 +1302,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
 
 	if (rc) {
 		bool inact = false;
+		time64_t now = ktime_get_seconds();
+		time64_t next_connect;
 
 		import_set_state_nolock(imp, LUSTRE_IMP_DISCON);
 		if (rc == -EACCES) {
@@ -1344,7 +1345,28 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
 				import_set_state_nolock(imp, LUSTRE_IMP_CLOSED);
 				inact = true;
 			}
+		} else if (rc == -ENODEV || rc == -ETIMEDOUT) {
+			/* ENODEV means there is no service, force reconnection
+			 * to a pair if attempt happen ptlrpc_next_reconnect
+			 * before now. ETIMEDOUT could be set during network
+			 * error and do not guarantee request deadline happened.
+			 */
+			struct obd_import_conn *conn;
+			time64_t reconnect_time;
+
+			/* Same as ptlrpc_next_reconnect, but in past */
+			reconnect_time = now - INITIAL_CONNECT_TIMEOUT;
+			list_for_each_entry(conn, &imp->imp_conn_list,
+					    oic_item) {
+				if (conn->oic_last_attempt <= reconnect_time) {
+					imp->imp_force_verify = 1;
+					break;
+				}
+			}
 		}
+
+		next_connect = imp->imp_conn_current->oic_last_attempt +
+			       (request->rq_deadline - request->rq_sent);
 		spin_unlock(&imp->imp_lock);
 
 		if (inact)
@@ -1353,6 +1375,18 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
 		if (rc == -EPROTO)
 			return rc;
 
+		/* adjust imp_next_ping to request deadline + 1 and reschedule
+		 * a pinger if import lost processing during CONNECTING or far
+		 * away from request deadline. It could happen when connection
+		 * was initiated outside of pinger, like
+		 * ptlrpc_set_import_discon().
+		 */
+		if (!imp->imp_force_verify && (imp->imp_next_ping <= now ||
+		    imp->imp_next_ping > next_connect)) {
+			imp->imp_next_ping = max(now, next_connect) + 1;
+			ptlrpc_pinger_wake_up();
+		}
+
 		ptlrpc_maybe_ping_import_soon(imp);
 
 		CDEBUG(D_HA, "recovery of %s on %s failed (%d)\n",
fs/lustre/ptlrpc/niobuf.c +0 -2
index 924b9c4..a1e6581 100644
@@ -701,8 +701,6 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
 	request->rq_deadline = request->rq_sent + request->rq_timeout +
 			       ptlrpc_at_get_net_latency(request);
 
-	ptlrpc_pinger_sending_on_import(imp);
-
 	DEBUG_REQ(D_INFO, request, "send flags=%x",
 		  lustre_msg_get_flags(request->rq_reqmsg));
 	rc = ptl_send_buf(&request->rq_req_md_h,
fs/lustre/ptlrpc/pinger.c +47 -26

112 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#18 lore raw

PATCH 18/28 lustre: ptlrpc: throttle RPC resend if network error

In reply to James Simmons

From: Aurelien Degremont <[email protected]>

When sending a callback AST to a non-responding client, the server retries endlessly until the client is eventually evicted. When using ksocklnd, it will retry after each AST timeout, until the socket is eventually closed, after sock_timeout sec, where the retry will fail immediately, returning -110, as no socket could be established.

The thread will spin on retrying and failing, until eventual client eviction. This will cause high thread CPU usage and possible resource denial.

To workaround that, this patch avoids re-trying callback resend if:
- the request is flagged with network error and timeout
- last try was less than 1 sec ago

In worst case, retry will happen after a timeout based on req->rq_deadline. If there is nothing else to handle, thread will be sleeping during that time, removing CPU overhead.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13984
Lustre-commit: 4103527c1c9b38 ("LU-13984 ptlrpc: throttle RPC resend if network error")

Reviewed-on: https://review.whamcloud.com/40020

---
 fs/lustre/ptlrpc/client.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
fs/lustre/ptlrpc/client.c +20 -0
index c9d9fe9..0e01ab33 100644
@@ -1900,6 +1900,26 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
 					goto interpret;
 				}
 
+				/* don't resend too fast in case of network
+				 * errors.
+				 */
+				if (ktime_get_real_seconds() < (req->rq_sent + 1)
+				    && req->rq_net_err && req->rq_timedout) {
+					DEBUG_REQ(D_INFO, req,
+						  "throttle request");
+					/* Don't try to resend RPC right away
+					 * as it is likely it will fail again
+					 * and ptlrpc_check_set() will be
+					 * called again, keeping this thread
+					 * busy. Instead, wait for the next
+					 * timeout. Flag it as resend to
+					 * ensure we don't wait to long.
+					 */
+					req->rq_resend = 1;
+					spin_unlock(&imp->imp_lock);
+					continue;
+				}
+
 				list_move_tail(&req->rq_list,
 					       &imp->imp_sending_list);
 
Signature · 1 line
1.8.3.1
#19 lore raw

PATCH 19/28 lustre: ldlm: BL AST vs failed lock enqueue race

In reply to James Simmons

From: Andriy Skulysh <[email protected]>

failed_lock_cleanup() marks the lock with LDLM_FL_LOCAL_ONLY, so cancel request isn't sent.

Mark failed lock with LDLM_FL_LOCAL_ONLY only
if BL AST wasn't received.
Add server's lock handle to BL AST RPC.
So client will be able to cancel the lock
even if enqueue fails.

HPE-bug-id: LUS-8493, LUS-8830
WC-bug-id: https://jira.whamcloud.com/browse/LU-13989
Lustre-commit: c1be044913dde3 ("LU-13989 ldlm: BL AST vs failed lock enqueue race")

Reviewed-on: https://review.whamcloud.com/40046

---
 fs/lustre/ldlm/ldlm_lockd.c   | 2 ++
 fs/lustre/ldlm/ldlm_request.c | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)
fs/lustre/ldlm/ldlm_lockd.c +2 -0
index 1ae65b829..6f498cc 100644
@@ -698,6 +698,8 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
 		ldlm_lock_remove_from_lru(lock);
 		ldlm_set_bl_ast(lock);
 	}
+	if (lock->l_remote_handle.cookie == 0)
+		lock->l_remote_handle = dlm_req->lock_handle[1];
 	unlock_res_and_lock(lock);
 
 	/*
fs/lustre/ldlm/ldlm_request.c +4 -1
index dd897ec..74bcba2 100644
@@ -317,8 +317,11 @@ static void failed_lock_cleanup(struct ldlm_namespace *ns,
 		 * bl_ast and -EINVAL reply is sent to server anyways.
 		 * b=17645
 		 */
-		lock->l_flags |= LDLM_FL_LOCAL_ONLY | LDLM_FL_FAILED |
+		lock->l_flags |= LDLM_FL_FAILED |
 				 LDLM_FL_ATOMIC_CB | LDLM_FL_CBPENDING;
+		if (!(ldlm_is_bl_ast(lock) &&
+		      lock->l_remote_handle.cookie != 0))
+			lock->l_flags |= LDLM_FL_LOCAL_ONLY;
 		need_cancel = 1;
 	}
 	unlock_res_and_lock(lock);
Signature · 1 line
1.8.3.1
#20 lore raw

PATCH 20/28 lustre: ptlrpc: don't log connection 'restored' inappropriately

In reply to James Simmons

From: Aurelien Degremont <[email protected]>

Reverse imports maintain a target->client connection which does not support recovery as client don't run a recovery. At every connection, the reverse import state goes from NEW to RECOVER to FULL which triggers a Connection restored log message, even if this is the first connection from this client.

Suppress this log message for reverse import to avoid this wrong logging.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14057
Lustre-commit: 2135f46b816223 ("LU-14057 ptlrpc: don't log connection 'restored' inappropriately")

Reviewed-on: https://review.whamcloud.com/40331

---
 fs/lustre/ptlrpc/import.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
fs/lustre/ptlrpc/import.c +10 -6
index 21ce593..35c4f83 100644
@@ -1590,12 +1590,16 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
 			goto out;
 		ptlrpc_activate_import(imp, true);
 
-		CDEBUG_LIMIT(imp->imp_was_idle ?
-				imp->imp_idle_debug : D_CONSOLE,
-			     "%s: Connection restored to %s (at %s)\n",
-			     imp->imp_obd->obd_name,
-			     obd_uuid2str(&conn->c_remote_uuid),
-			     obd_import_nid2str(imp));
+		/* Reverse import are flagged with dlm_fake == 1.
+		 * They do not do recovery and connection are not "restored".
+		 */
+		if (!imp->imp_dlm_fake)
+			CDEBUG_LIMIT(imp->imp_was_idle ?
+				     imp->imp_idle_debug : D_CONSOLE,
+				     "%s: Connection restored to %s (at %s)\n",
+				     imp->imp_obd->obd_name,
+				     obd_uuid2str(&conn->c_remote_uuid),
+				     obd_import_nid2str(imp));
 		spin_lock(&imp->imp_lock);
 		imp->imp_was_idle = 0;
 		spin_unlock(&imp->imp_lock);
Signature · 1 line
1.8.3.1
#21 lore raw

PATCH 21/28 lustre: llite: Avoid eternel retry loops with MAP_POPULATE

In reply to James Simmons

From: Oleg Drokin <[email protected]>

Kernels 5.4+ have an infinite retry loop from MAP_POPULATE mmap option. Use the FAULT_FLAG_RETRY_NOWAIT to instruct filemap_fault to not drop the mmap_sem so if the call fails, we could use the slow path and break the loop from forming.
(Idea by Neil Brown)

WC-bug-id: https://jira.whamcloud.com/browse/LU-13182
Lustre-commit: bb50c62c6f4cdd ("LU-13182 llite: Avoid eternel retry loops with MAP_POPULATE")

Reviewed-on: https://review.whamcloud.com/40221

---
 fs/lustre/llite/llite_mmap.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/lustre/llite/llite_mmap.c +8 -2
index f77b8f9..f0be7ba 100644
@@ -288,18 +288,24 @@ static vm_fault_t __ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 
 	if (ll_sbi_has_fast_read(ll_i2sbi(file_inode(vma->vm_file)))) {
 		/* do fast fault */
+		bool has_retry = vmf->flags & FAULT_FLAG_RETRY_NOWAIT;
+
+		/* To avoid loops, instruct downstream to not drop mmap_sem */
+		vmf->flags |= FAULT_FLAG_RETRY_NOWAIT;
 		ll_cl_add(vma->vm_file, env, NULL, LCC_MMAP);
 		fault_ret = filemap_fault(vmf);
 		ll_cl_remove(vma->vm_file, env);
+		if (has_retry)
+			vmf->flags &= ~FAULT_FLAG_RETRY_NOWAIT;
 
 		/*
 		 * - If there is no error, then the page was found in cache and
 		 *   uptodate;
 		 * - If VM_FAULT_RETRY is set, the page existed but failed to
-		 *   lock. It will return to kernel and retry;
+		 *   lock. We will try slow path to avoid loops.
 		 * - Otherwise, it should try normal fault under DLM lock.
 		 */
-		if ((fault_ret & VM_FAULT_RETRY) ||
+		if (!(fault_ret & VM_FAULT_RETRY) &&
 		    !(fault_ret & VM_FAULT_ERROR)) {
 			result = 0;
 			goto out;
Signature · 1 line
1.8.3.1
#22 lore raw

PATCH 22/28 lustre: ptlrpc: introduce OST_SEEK RPC

In reply to James Simmons

From: Mikhail Pershin <[email protected]>

For the purposes of SEEK_HOLE/SEEK_DATA support introduce new OST_SEEK RPC.

Patch add RPC layout, unified handler and connect flag for compatibility needs.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10810
Lustre-commit: 6d5fe29066af5f ("LU-10810 ptlrpc: introduce OST_SEEK RPC")

Reviewed-on: https://review.whamcloud.com/39707

---
 fs/lustre/include/lustre_req_layout.h  | 1 +
 fs/lustre/obdclass/lprocfs_status.c    | 1 +
 fs/lustre/ptlrpc/layout.c              | 5 +++++
 fs/lustre/ptlrpc/lproc_ptlrpc.c        | 3 ++-
 fs/lustre/ptlrpc/wiretest.c            | 6 +++++-
 include/uapi/linux/lustre/lustre_idl.h | 2 ++
 6 files changed, 16 insertions(+), 2 deletions(-)
fs/lustre/include/lustre_req_layout.h +1 -0
index 54041b0..434bb08 100644
@@ -199,6 +199,7 @@ void req_capsule_shrink(struct req_capsule *pill,
 extern struct req_format RQF_OST_SET_INFO_LAST_FID;
 extern struct req_format RQF_OST_GET_INFO_FIEMAP;
 extern struct req_format RQF_OST_LADVISE;
+extern struct req_format RQF_OST_SEEK;
 
 /* LDLM req_format */
 extern struct req_format RQF_LDLM_ENQUEUE;
fs/lustre/obdclass/lprocfs_status.c +1 -0
index a3c5657..6ce0a5d 100644
@@ -129,6 +129,7 @@
 	"client_encryption",	/* 0x8000 */
 	"fidmap",		/* 0x10000 */
 	"getattr_pfid",		/* 0x20000 */
+	"lseek",		/* 0x40000 */
 	NULL
 };
 
fs/lustre/ptlrpc/layout.c +5 -0
index 4e37bbb..11c0d50 100644
@@ -777,6 +777,7 @@
 	&RQF_OST_SET_INFO_LAST_FID,
 	&RQF_OST_GET_INFO_FIEMAP,
 	&RQF_OST_LADVISE,
+	&RQF_OST_SEEK,
 	&RQF_LDLM_ENQUEUE,
 	&RQF_LDLM_ENQUEUE_LVB,
 	&RQF_LDLM_CONVERT,
@@ -1611,6 +1612,10 @@ 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_SEEK =
+	DEFINE_REQ_FMT0("OST_SEEK", ost_body_only, ost_body_only);
+EXPORT_SYMBOL(RQF_OST_SEEK);
+
 struct req_format RQF_OST_SYNC =
 	DEFINE_REQ_FMT0("OST_SYNC", ost_body_capa, ost_body_only);
 EXPORT_SYMBOL(RQF_OST_SYNC);
fs/lustre/ptlrpc/lproc_ptlrpc.c +2 -1
index 7276f81..26ca55e 100644
@@ -67,7 +67,8 @@
 	{ OST_QUOTACTL,				"ost_quotactl" },
 	{ OST_QUOTA_ADJUST_QUNIT,		"ost_quota_adjust_qunit" },
 	{ OST_LADVISE,				"ost_ladvise" },
-	{ OST_FALLOCATE,			"ost_fallocate"},
+	{ OST_FALLOCATE,			"ost_fallocate" },
+	{ OST_SEEK,				"ost_seek" },
 	{ MDS_GETATTR,				"mds_getattr" },
 	{ MDS_GETATTR_NAME,			"mds_getattr_lock" },
 	{ MDS_CLOSE,				"mds_close" },
fs/lustre/ptlrpc/wiretest.c +5 -1
index 9b1caf4..ba19b78 100644
@@ -108,7 +108,9 @@ void lustre_assert_wire_constants(void)
 		 (long long)OST_LADVISE);
 	LASSERTF(OST_FALLOCATE == 22, "found %lld\n",
 		 (long long)OST_FALLOCATE);
-	LASSERTF(OST_LAST_OPC == 23, "found %lld\n",
+	LASSERTF(OST_SEEK == 23, "found %lld\n",
+		 (long long)OST_SEEK);
+	LASSERTF(OST_LAST_OPC == 24, "found %lld\n",
 		 (long long)OST_LAST_OPC);
 	LASSERTF(OBD_OBJECT_EOF == 0xffffffffffffffffULL, "found 0x%.16llxULL\n",
 		 OBD_OBJECT_EOF);
@@ -1245,6 +1247,8 @@ void lustre_assert_wire_constants(void)
 		 OBD_CONNECT2_FIDMAP);
 	LASSERTF(OBD_CONNECT2_GETATTR_PFID == 0x20000ULL, "found 0x%.16llxULL\n",
 		 OBD_CONNECT2_GETATTR_PFID);
+	LASSERTF(OBD_CONNECT2_LSEEK == 0x40000ULL, "found 0x%.16llxULL\n",
+		 OBD_CONNECT2_LSEEK);
 	LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n",
 		 (unsigned int)OBD_CKSUM_CRC32);
 	LASSERTF(OBD_CKSUM_ADLER == 0x00000002UL, "found 0x%.8xUL\n",
include/uapi/linux/lustre/lustre_idl.h +2 -0
index 34b2367..f56b3c5 100644
@@ -838,6 +838,7 @@ struct ptlrpc_body_v2 {
 #define OBD_CONNECT2_ENCRYPT	       0x8000ULL /* client-to-disk encrypt */
 #define OBD_CONNECT2_FIDMAP	      0x10000ULL /* FID map */
 #define OBD_CONNECT2_GETATTR_PFID     0x20000ULL /* pack parent FID in getattr */
+#define OBD_CONNECT2_LSEEK	      0x40000ULL /* SEEK_HOLE/DATA RPC */
 /* 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
@@ -972,6 +973,7 @@ enum ost_cmd {
 	OST_QUOTA_ADJUST_QUNIT = 20, /* not used since 2.4 */
 	OST_LADVISE	= 21,
 	OST_FALLOCATE	= 22,
+	OST_SEEK	= 23,
 	OST_LAST_OPC /* must be < 33 to avoid MDS_GETATTR */
 };
 #define OST_FIRST_OPC  OST_REPLY
Signature · 1 line
1.8.3.1
#23 lore raw

PATCH 23/28 lustre: clio: SEEK_HOLE/SEEK_DATA on client side

In reply to James Simmons

From: Mikhail Pershin <[email protected]>

Patch introduces basic support for lseek SEEK_HOLE/SEEK_DATA parameters in lustre client.

- introduce new IO type CIT_LSEEK in CLIO stack
- LOV splits request to all stripes involved and merges results back.
- OSC sends OST LSEEK RPC asynchronously
- if target doesn't support LSEEK RPC then OSC assumes whole related object is data with virtual hole at the end
- lseek restores released files assuming it is done prior the file copying.
- tool is added to request needed lseek on file
- basic tests are added in sanity, sanityn and sanity-hsm

WC-bug-id: https://jira.whamcloud.com/browse/LU-10810
Lustre-commit: cda353e6efae50 ("LU-10810 clio: SEEK_HOLE/SEEK_DATA on client side")

Reviewed-on: https://review.whamcloud.com/39708

---
 fs/lustre/include/cl_object.h     |  10 +++
 fs/lustre/include/lustre_export.h |   5 ++
 fs/lustre/include/lustre_osc.h    |   4 ++
 fs/lustre/llite/file.c            |  61 ++++++++++++++++--
 fs/lustre/llite/llite_lib.c       |   4 +-
 fs/lustre/llite/vvp_io.c          |  53 +++++++++++++++-
 fs/lustre/lov/lov_io.c            |  99 ++++++++++++++++++++++++++++-
 fs/lustre/mdc/mdc_dev.c           |   4 ++
 fs/lustre/obdclass/cl_io.c        |   1 +
 fs/lustre/osc/osc_io.c            | 127 ++++++++++++++++++++++++++++++++++++++
 10 files changed, 358 insertions(+), 10 deletions(-)
fs/lustre/include/cl_object.h +10 -0
index 56200d2..e17385c0 100644
@@ -1415,6 +1415,11 @@ enum cl_io_type {
 	 * To give advice about access of a file
 	 */
 	CIT_LADVISE,
+	/**
+	 * SEEK_HOLE/SEEK_DATA handling to search holes or data
+	 * across all file objects
+	 */
+	CIT_LSEEK,
 	CIT_OP_NR
 };
 
@@ -1892,6 +1897,11 @@ struct cl_io {
 			enum lu_ladvise_type	li_advice;
 			u64			li_flags;
 		} ci_ladvise;
+		struct cl_lseek_io {
+			loff_t			ls_start;
+			loff_t			ls_result;
+			int			ls_whence;
+		} ci_lseek;
 	} u;
 	struct cl_2queue	ci_queue;
 	size_t			ci_nob;
fs/lustre/include/lustre_export.h +5 -0
index b5fdf8a..ed49a97 100644
@@ -285,6 +285,11 @@ static inline int exp_connect_encrypt(struct obd_export *exp)
 	return !!(exp_connect_flags2(exp) & OBD_CONNECT2_ENCRYPT);
 }
 
+static inline int exp_connect_lseek(struct obd_export *exp)
+{
+	return !!(exp_connect_flags2(exp) & OBD_CONNECT2_LSEEK);
+}
+
 enum {
 	/* archive_ids in array format */
 	KKUC_CT_DATA_ARRAY_MAGIC	= 0x092013cea,
fs/lustre/include/lustre_osc.h +4 -0
index 24cfec8..ef5237b 100644
@@ -704,6 +704,10 @@ int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
 void osc_io_fsync_end(const struct lu_env *env,
 		      const struct cl_io_slice *slice);
 void osc_read_ahead_release(const struct lu_env *env, void *cbdata);
+int osc_io_lseek_start(const struct lu_env *env,
+		       const struct cl_io_slice *slice);
+void osc_io_lseek_end(const struct lu_env *env,
+		      const struct cl_io_slice *slice);
 
 /* osc_lock.c */
 void osc_lock_to_lockless(const struct lu_env *env, struct osc_lock *ols,
fs/lustre/llite/file.c +55 -6

81 lines not on this page · raw message

fs/lustre/llite/llite_lib.c +2 -2
index d94c6ca..a4042b8 100644
@@ -263,7 +263,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 				   OBD_CONNECT2_LSOM |
 				   OBD_CONNECT2_ASYNC_DISCARD |
 				   OBD_CONNECT2_PCC |
-				   OBD_CONNECT2_CRUSH |
+				   OBD_CONNECT2_CRUSH | OBD_CONNECT2_LSEEK |
 				   OBD_CONNECT2_GETATTR_PFID;
 
 	if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
@@ -473,7 +473,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 				  OBD_CONNECT_FLAGS2 | OBD_CONNECT_GRANT_SHRINK;
 
 	data->ocd_connect_flags2 = OBD_CONNECT2_LOCKAHEAD |
-				   OBD_CONNECT2_INC_XID;
+				   OBD_CONNECT2_INC_XID | OBD_CONNECT2_LSEEK;
 
 	if (!OBD_FAIL_CHECK(OBD_FAIL_OSC_CONNECT_GRANT_PARAM))
 		data->ocd_connect_flags |= OBD_CONNECT_GRANT_PARAM;
fs/lustre/llite/vvp_io.c +52 -1

65 lines not on this page · raw message

fs/lustre/lov/lov_io.c +98 -1

136 lines not on this page · raw message

fs/lustre/mdc/mdc_dev.c +4 -0
index 90b60f5..214fd31 100644
@@ -1297,6 +1297,10 @@ static void mdc_io_data_version_end(const struct lu_env *env,
 			.cio_start	= mdc_io_fsync_start,
 			.cio_end	= osc_io_fsync_end,
 		},
+		[CIT_LSEEK] = {
+			.cio_start	= osc_io_lseek_start,
+			.cio_end	= osc_io_lseek_end,
+		},
 	},
 	.cio_read_ahead		= mdc_io_read_ahead,
 	.cio_submit		= osc_io_submit,
fs/lustre/obdclass/cl_io.c +1 -0
index aa3cb17..c57a3766 100644
@@ -127,6 +127,7 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io)
 	case CIT_GLIMPSE:
 		break;
 	case CIT_LADVISE:
+	case CIT_LSEEK:
 		break;
 	default:
 		LBUG();
fs/lustre/osc/osc_io.c +127 -0

139 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#24 lore raw

PATCH 24/28 lustre: sec: O_DIRECT for encrypted file

In reply to James Simmons

From: Sebastien Buisson <[email protected]>

Add O_DIRECT support for encrypted files.
By default, fscrypt does not support O_DIRECT because it needs pagecache pages to proceed.
With Lustre, we can make use of pages being used for sending RPCs. They can be twisted so that they have a proper mapping and index, suitable for encryption/decryption.

One of the benefits of O_DIRECT support for encrypted files is that we get support for mirroring at the same time.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12275
Lustre-commit: 728036f25635a ("LU-12275 sec: O_DIRECT for encrypted file")

Reviewed-on: https://review.whamcloud.com/38967

---
 .../client_side_encryption/access_semantics.txt    |  3 --
 fs/lustre/llite/dir.c                              |  1 -
 fs/lustre/llite/llite_lib.c                        | 11 ++++++-
 fs/lustre/llite/rw26.c                             | 27 +++++++++++++---
 fs/lustre/llite/super25.c                          | 11 +++++++
 fs/lustre/obdclass/cl_io.c                         | 11 +++++++
 fs/lustre/osc/osc_request.c                        | 37 ++++++++++++++++++----
 fs/lustre/ptlrpc/wiretest.c                        |  2 ++
 8 files changed, 87 insertions(+), 16 deletions(-)
Documentation/lustre/client_side_encryption/access_semantics.txt +0 -3
index fe2c28d..7ed0bc7 100644
@@ -42,9 +42,6 @@ astute users may notice some differences in behavior:
   may be used to overwrite the source files but isn't guaranteed to be
   effective on all filesystems and storage devices.
 
-- Direct I/O is not supported on encrypted files.  Attempts to use
-  direct I/O on such files will fall back to buffered I/O.
-
 - The fallocate operations FALLOC_FL_COLLAPSE_RANGE,
   FALLOC_FL_INSERT_RANGE, and FALLOC_FL_ZERO_RANGE are not supported
   on encrypted files and will fail with EOPNOTSUPP.
fs/lustre/llite/dir.c +0 -1
index 262aea0..6bc95d9 100644
@@ -481,7 +481,6 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump,
 			goto out_op_data;
 	}
 
-
 	op_data->op_cli_flags |= CLI_SET_MEA;
 	err = md_create(sbi->ll_md_exp, op_data, lump, len, mode,
 			from_kuid(&init_user_ns, current_fsuid()),
fs/lustre/llite/llite_lib.c +10 -1
index a4042b8..e4036af 100644
@@ -1759,6 +1759,7 @@ int ll_io_zero_page(struct inode *inode, pgoff_t index, pgoff_t offset,
 			 * file, we must not zero and write as below. Subsequent
 			 * server-side truncate will handle things correctly.
 			 */
+			rc = 0;
 			goto clpfini;
 		ClearPagePrivate2(vmpage);
 		if (rc)
@@ -1960,7 +1961,15 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr,
 			    attr->ia_valid & ATTR_SIZE) {
 				xvalid |= OP_XVALID_FLAGS;
 				flags = LUSTRE_ENCRYPT_FL;
-				if (attr->ia_size & ~PAGE_MASK) {
+				/* Call to ll_io_zero_page is not necessary if
+				 * truncating on PAGE_SIZE boundary, because
+				 * whole pages will be wiped.
+				 * In case of Direct IO, all we need is to set
+				 * new size.
+				 */
+				if (attr->ia_size & ~PAGE_MASK &&
+				    !(attr->ia_valid & ATTR_FILE &&
+				      attr->ia_file->f_flags & O_DIRECT)) {
 					pgoff_t offset;
 
 					offset = attr->ia_size & (PAGE_SIZE - 1);
fs/lustre/llite/rw26.c +23 -4
index a4ae211..1736e9a 100644
@@ -207,6 +207,7 @@ struct ll_dio_pages {
 	int io_pages = 0;
 	size_t page_size = cl_page_size(obj);
 	int i;
+	pgoff_t index = offset >> PAGE_SHIFT;
 	ssize_t rc = 0;
 
 	cl_2queue_init(queue);
@@ -226,6 +227,28 @@ struct ll_dio_pages {
 		}
 
 		page->cp_sync_io = anchor;
+		if (inode && IS_ENCRYPTED(inode)) {
+			struct page *vmpage = cl_page_vmpage(page);
+
+			/* In case of Direct IO on encrypted file, we need to
+			 * set the correct page index, and add a reference to
+			 * the mapping. This is required by llcrypt to proceed
+			 * to encryption/decryption, because each block is
+			 * encrypted independently, and each block's IV is set
+			 * to the logical block number within the file.
+			 * This is safe because we know these pages are private
+			 * to the thread doing the Direct IO, and despite
+			 * setting a mapping on the pages, cached lookups will
+			 * not find them.
+			 * Set PageChecked to detect special case of Direct IO
+			 * in osc_brw_fini_request().
+			 * Reference to the mapping and PageChecked flag are
+			 * removed in cl_aio_end().
+			 */
+			vmpage->index = index++;
+			vmpage->mapping = inode->i_mapping;
+			SetPageChecked(vmpage);
+		}
 		cl_page_list_add(&queue->c2_qin, page);
 		/*
 		 * Set page clip to tell transfer formation engine
@@ -297,10 +320,6 @@ static ssize_t ll_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 	int rw = iov_iter_rw(iter);
 	struct vvp_io *vio;
 
-	/* if file is encrypted, return 0 so that we fall back to buffered IO */
-	if (IS_ENCRYPTED(inode))
-		return 0;
-
 	/* Check EOF by ourselves */
 	if (rw == READ && file_offset >= i_size_read(inode))
 		return 0;
fs/lustre/llite/super25.c +11 -0
index 8eb3fc3..d02c8cf 100644
@@ -72,10 +72,21 @@ static void ll_destroy_inode(struct inode *inode)
 	call_rcu(&inode->i_rcu, ll_inode_destroy_callback);
 }
 
+static int ll_drop_inode(struct inode *inode)
+{
+	int drop = generic_drop_inode(inode);
+
+	if (!drop)
+		drop = llcrypt_drop_inode(inode);
+
+	return drop;
+}
+
 /* exported operations */
 struct super_operations lustre_super_operations = {
 	.alloc_inode		= ll_alloc_inode,
 	.destroy_inode		= ll_destroy_inode,
+	.drop_inode		= ll_drop_inode,
 	.evict_inode		= ll_delete_inode,
 	.put_super		= ll_put_super,
 	.statfs			= ll_statfs,
fs/lustre/obdclass/cl_io.c +11 -0
index c57a3766..37b0828 100644
@@ -1081,8 +1081,19 @@ static void cl_aio_end(const struct lu_env *env, struct cl_sync_io *anchor)
 	/* release pages */
 	while (aio->cda_pages.pl_nr > 0) {
 		struct cl_page *page = cl_page_list_first(&aio->cda_pages);
+		struct page *vmpage = cl_page_vmpage(page);
+		struct inode *inode = vmpage ? page2inode(vmpage) : NULL;
 
 		cl_page_get(page);
+		/* We end up here in case of Direct IO only. For encrypted file,
+		 * mapping was set on pages in ll_direct_rw_pages(), so it has
+		 * to be cleared now before page cleanup.
+		 * PageChecked flag was also set there, so we clean up here.
+		 */
+		if (inode && IS_ENCRYPTED(inode)) {
+			vmpage->mapping = NULL;
+			ClearPageChecked(vmpage);
+		}
 		cl_page_list_del(env, &aio->cda_pages, page);
 		cl_page_delete(env, page);
 		cl_page_put(env, page);
fs/lustre/osc/osc_request.c +30 -7
index 8a8a624..bf9ce44 100644
@@ -1369,13 +1369,9 @@ static inline void osc_release_bounce_pages(struct brw_page **pga,
 	int i;
 
 	for (i = 0; i < page_count; i++) {
-		if (pga[i]->pg->mapping)
+		if (!pga[i]->pg->mapping)
 			/* bounce pages are unmapped */
-			continue;
-		if (pga[i]->flag & OBD_BRW_SYNC)
-			/* sync transfer cannot have encrypted pages */
-			continue;
-		llcrypt_finalize_bounce_page(&pga[i]->pg);
+			llcrypt_finalize_bounce_page(&pga[i]->pg);
 		pga[i]->count -= pga[i]->bp_count_diff;
 		pga[i]->off += pga[i]->bp_off_diff;
 	}
@@ -1470,6 +1466,19 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
 			pg->bp_off_diff = pg->off & ~PAGE_MASK;
 			pg->off = pg->off & PAGE_MASK;
 		}
+	} else if (opc == OST_READ && inode && IS_ENCRYPTED(inode)) {
+		for (i = 0; i < page_count; i++) {
+			struct brw_page *pg = pga[i];
+
+			/* count/off are forced to cover the whole page so that
+			 * all encrypted data is stored on the OST, so adjust
+			 * bp_{count,off}_diff for the size of the clear text.
+			 */
+			pg->bp_count_diff = PAGE_SIZE - pg->count;
+			pg->count = PAGE_SIZE;
+			pg->bp_off_diff = pg->off & ~PAGE_MASK;
+			pg->off = pg->off & PAGE_MASK;
+		}
 	}
 
 	for (niocount = i = 1; i < page_count; i++) {
@@ -1483,8 +1492,13 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
 	req_capsule_set_size(pill, &RMF_NIOBUF_REMOTE, RCL_CLIENT,
 			     niocount * sizeof(*niobuf));
 
-	for (i = 0; i < page_count; i++)
+	for (i = 0; i < page_count; i++) {
 		short_io_size += pga[i]->count;
+		if (!inode || !IS_ENCRYPTED(inode)) {
+			pga[i]->bp_count_diff = 0;
+			pga[i]->bp_off_diff = 0;
+		}
+	}
 
 	/* Check if read/write is small enough to be a short io. */
 	if (short_io_size > cli->cl_max_short_io_bytes || niocount > 1 ||
@@ -2093,8 +2107,17 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc)
 				continue;
 			}
 
+			/* The page is already locked when we arrive here,
+			 * except when we deal with a twisted page for
+			 * specific Direct IO support, in which case
+			 * PageChecked flag is set on page.
+			 */
+			if (PageChecked(pg->pg))
+				lock_page(pg->pg);
 			rc = llcrypt_decrypt_pagecache_blocks(pg->pg,
 							      PAGE_SIZE, 0);
+			if (PageChecked(pg->pg))
+				unlock_page(pg->pg);
 			if (rc)
 				goto out;
 		}
fs/lustre/ptlrpc/wiretest.c +2 -0
index ba19b78..c8b97fa 100644
@@ -2307,6 +2307,8 @@ void lustre_assert_wire_constants(void)
 		 LUSTRE_TOPDIR_FL);
 	LASSERTF(LUSTRE_INLINE_DATA_FL == 0x10000000, "found 0x%.8x\n",
 		 LUSTRE_INLINE_DATA_FL);
+	LASSERTF(LUSTRE_ENCRYPT_FL == 0x00800000UL, "found 0x%.8x\n",
+		 LUSTRE_ENCRYPT_FL);
 	LASSERTF(MDS_INODELOCK_LOOKUP == 0x00000001UL, "found 0x%.8x\n",
 		 MDS_INODELOCK_LOOKUP);
 	LASSERTF(MDS_INODELOCK_UPDATE == 0x00000002UL, "found 0x%.8x\n",
Signature · 1 line
1.8.3.1
#25 lore raw

PATCH 25/28 lustre: sec: restrict fallocate on encrypted files

In reply to James Simmons

From: Sebastien Buisson <[email protected]>

For now, ll_fallocate only supports standard preallocation. Anyway, encrypted inodes can't handle collapse range or zero range or insert range since we would need to re-encrypt blocks with a different IV or XTS tweak (which are based on the logical block number). So make sure we return -EOPNOTSUPP in this case, like what ext4 does.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12275
Lustre-commit: a7870fb9568bf ("LU-12275 sec: restrict fallocate on encrypted files")

Reviewed-on: https://review.whamcloud.com/39220

---
 fs/lustre/llite/file.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/lustre/llite/file.c +11 -0
index 4a3c534..02cc2d6 100644
@@ -4927,6 +4927,17 @@ long ll_fallocate(struct file *filp, int mode, loff_t offset, loff_t len)
 	struct inode *inode = filp->f_path.dentry->d_inode;
 
 	/*
+	 * Encrypted inodes can't handle collapse range or zero range or insert
+	 * range since we would need to re-encrypt blocks with a different IV or
+	 * XTS tweak (which are based on the logical block number).
+	 * Similar to what ext4 does.
+	 */
+	if (IS_ENCRYPTED(inode) &&
+	    (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE |
+		     FALLOC_FL_ZERO_RANGE)))
+		return -EOPNOTSUPP;
+
+	/*
 	 * Only mode == 0 (which is standard prealloc) is supported now.
 	 * Punch is not supported yet.
 	 */
Signature · 1 line
1.8.3.1
#26 lore raw

PATCH 26/28 lustre: sec: encryption with different client PAGE_SIZE

In reply to James Simmons

From: Sebastien Buisson <[email protected]>

In order to properly handle encryption/decryption on clients that have a PAGE_SIZE != LUSTRE_ENCRYPTION_UNIT_SIZE (typically aarch64/ppc64), a few adjustements are necessary:
- when encrypting, do not proceed with PAGE_SIZE as encryption length. Instead, round up to a multiple of LUSTRE_ENCRYPTION_UNIT_SIZE. On aarch64/ppc64, it avoids encrypting way beyond LUSTRE_ENCRYPTION_UNIT_SIZE when the page is not full.
- when decrypting, do not proceed with PAGE_SIZE as decryption length. Instead, do LUSTRE_ENCRYPTION_UNIT_SIZE length at a time. It enables proper detection of 'all 0s' sent by servers for content beyond file size.

Regarding tests, add sanity-sec test_53 to exercise encryption from clients with different PAGE_SIZE.
The trick to achieve this with AT is to expect the client to have 64KB PAGE_SIZE, and the servers to have 4KB PAGE_SIZE, and then mount a client from the MDS node.
This also means code running on server side needs to have client encryption support enabled, so CentOS/RHEL 8 at least.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12275
Lustre-commit: ac5fcdce025b4 ("LU-12275 sec: encryption with different client PAGE_SIZE")

Reviewed-on: https://review.whamcloud.com/39315

---
 fs/lustre/llite/file.c      | 28 +++++++++++-----
 fs/lustre/osc/osc_request.c | 79 +++++++++++++++++++++++++++------------------
 2 files changed, 68 insertions(+), 39 deletions(-)
fs/lustre/llite/file.c +20 -8
index 02cc2d6..f7f917b 100644
@@ -444,16 +444,28 @@ static inline int ll_dom_readpage(void *data, struct page *page)
 	kunmap_atomic(kaddr);
 
 	if (inode && IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode)) {
-		if (!llcrypt_has_encryption_key(inode))
+		if (!llcrypt_has_encryption_key(inode)) {
 			CDEBUG(D_SEC, "no enc key for " DFID "\n",
 			       PFID(ll_inode2fid(inode)));
-		/* decrypt only if page is not empty */
-		else if (memcmp(page_address(page),
-				page_address(ZERO_PAGE(0)),
-				PAGE_SIZE) != 0)
-			rc = llcrypt_decrypt_pagecache_blocks(page,
-							      PAGE_SIZE,
-							      0);
+		} else {
+			unsigned int offs = 0;
+
+			while (offs < PAGE_SIZE) {
+				/* decrypt only if page is not empty */
+				if (memcmp(page_address(page) + offs,
+					   page_address(ZERO_PAGE(0)),
+					   LUSTRE_ENCRYPTION_UNIT_SIZE) == 0)
+					break;
+
+				rc = llcrypt_decrypt_pagecache_blocks(page,
+								      LUSTRE_ENCRYPTION_UNIT_SIZE,
+								      0);
+				if (rc)
+					break;
+
+				offs += LUSTRE_ENCRYPTION_UNIT_SIZE;
+			}
+		}
 	}
 	unlock_page(page);
 
fs/lustre/osc/osc_request.c +48 -31

117 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#27 lore raw

PATCH 27/28 lustre: sec: require enc key in case of O_CREAT only

In reply to James Simmons

From: Sebastien Buisson <[email protected]>

In ll_atomic_open(), do not return -ENOKEY when trying to open either a directory or a file without the encryption key, unless O_CREAT flag is specified.
Indeed, listing directory content is allowed even without the key. And in case of regular file, ll_file_open() already checks for the presence of an encryption key.

Improve sanity-sec test_54 to verify this is working properly.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13975
Lustre-commit: f6daee15b2c8ec ("LU-13975 sec: require enc key in case of O_CREAT only")

Reviewed-on: https://review.whamcloud.com/39983

---
 fs/lustre/llite/namei.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
fs/lustre/llite/namei.c +7 -6
index da6b729..b24f097 100644
@@ -1113,18 +1113,19 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
 	it->it_flags &= ~MDS_OPEN_FL_INTERNAL;
 
 	if (ll_sbi_has_encrypt(ll_i2sbi(dir)) && IS_ENCRYPTED(dir)) {
-		/* we know that we are going to create a regular file because
+		/* in case of create, this is going to be a regular file because
 		 * we set S_IFREG bit on it->it_create_mode above
 		 */
 		rc = llcrypt_get_encryption_info(dir);
 		if (rc)
 			goto out_release;
-		if (!llcrypt_has_encryption_key(dir)) {
-			rc = -ENOKEY;
-			goto out_release;
+		if (open_flags & O_CREAT) {
+			if (!llcrypt_has_encryption_key(dir)) {
+				rc = -ENOKEY;
+				goto out_release;
+			}
+			encrypt = true;
 		}
-		encrypt = true;
-		rc = 0;
 	}
 
 	OBD_FAIL_TIMEOUT(OBD_FAIL_LLITE_CREATE_FILE_PAUSE2, cfs_fail_val);
Signature · 1 line
1.8.3.1
#28 lore raw

PATCH 28/28 lustre: sec: fix O_DIRECT and encrypted files

In reply to James Simmons

From: Sebastien Buisson <[email protected]>

Sometimes, we can end up in a situation where osc_release_bounce_pages() mistakenly consider pages as fscrypt bounce pages, and tries to free them.
Fix the way we consider bounce pages by always setting the PageChecked flag on them.

Fixes feca6b62a6 ("lustre: sec: O_DIRECT for encrypted file")

WC-bug-id: https://jira.whamcloud.com/browse/LU-14045
Lustre-commit: e07d0516dcde4b ("LU-14045 sec: fix O_DIRECT and encrypted files")

Reviewed-on: https://review.whamcloud.com/40295

---
 fs/lustre/osc/osc_request.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
fs/lustre/osc/osc_request.c +9 -2
index 746b695..f225ccd 100644
@@ -1369,8 +1369,11 @@ static inline void osc_release_bounce_pages(struct brw_page **pga,
 	int i;
 
 	for (i = 0; i < page_count; i++) {
-		if (!pga[i]->pg->mapping)
-			/* bounce pages are unmapped */
+		/* Bounce pages allocated by a call to
+		 * llcrypt_encrypt_pagecache_blocks() in osc_brw_prep_request()
+		 * are identified thanks to the PageChecked flag.
+		 */
+		if (PageChecked(pga[i]->pg))
 			llcrypt_finalize_bounce_page(&pga[i]->pg);
 		pga[i]->count -= pga[i]->bp_count_diff;
 		pga[i]->off += pga[i]->bp_off_diff;
@@ -1453,6 +1456,10 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
 				ptlrpc_request_free(req);
 				return rc;
 			}
+			/* Set PageChecked flag on bounce page for
+			 * disambiguation in osc_release_bounce_pages().
+			 */
+			SetPageChecked(data_page);
 			pg->pg = data_page;
 			/* there should be no gap in the middle of page array */
 			if (i == page_count - 1) {
Signature · 1 line
1.8.3.1