From patchwork Tue Aug 11 12:19:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709163 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ACA4614E3 for ; Tue, 11 Aug 2020 12:20:24 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9361520578 for ; Tue, 11 Aug 2020 12:20:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9361520578 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id D2FC421F236; Tue, 11 Aug 2020 05:20:23 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 46F6221F157 for ; Tue, 11 Aug 2020 05:20:22 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id EA96310055E0; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id DEED22AC; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:19:57 -0400 Message-Id: <1597148419-20629-2-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 01/23] lustre: lov: one more fix to write_intent end for trunc X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Bobi Jam This patch fixes another case where the truncate write intent extent is set incorrectly. This may cause errors when truncating PFL files to exactly the boundary between two extents. Fixes: 782b737b76c1 ("lustre: lov: Correct write_intent end for trunc") WC-bug-id: https://jira.whamcloud.com/browse/LU-12586 Lustre-commit: ecf9e229cf59d ("LU-12586 lov: one more fix to write_intent end for trunc") Signed-off-by: Bobi Jam Reviewed-on: https://review.whamcloud.com/38412 Reviewed-by: Wang Shilong Reviewed-by: Li Dongyang Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- fs/lustre/lov/lov_io.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/lustre/lov/lov_io.c b/fs/lustre/lov/lov_io.c index 99b68d8..af79d20 100644 --- a/fs/lustre/lov/lov_io.c +++ b/fs/lustre/lov/lov_io.c @@ -363,11 +363,12 @@ static int lov_io_mirror_init(struct lov_io *lio, struct lov_object *obj, /** * for truncate, we uses [size, EOF) to judge whether * a write intent needs to be send, but we need to - * restore the write extent to [0, size). + * restore the write extent to [0, size), in truncate, + * the byte in the size position is accessed. */ io->ci_write_intent.e_start = 0; io->ci_write_intent.e_end = - io->u.ci_setattr.sa_attr.lvb_size; + io->u.ci_setattr.sa_attr.lvb_size + 1; } /* stop cl_io_init() loop */ return 1; From patchwork Tue Aug 11 12:19:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709169 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8C881392 for ; Tue, 11 Aug 2020 12:20:37 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A0BA4206C3 for ; Tue, 11 Aug 2020 12:20:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0BA4206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 8E2172F379C; Tue, 11 Aug 2020 05:20:30 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 43B0221F157 for ; Tue, 11 Aug 2020 05:20:23 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id EE2C310055EA; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id E1A582B1; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:19:58 -0400 Message-Id: <1597148419-20629-3-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 02/23] lustre: lov: annotate nested locking of obd_dev_mutex X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown obd_statfs() can call lmv_statfs() with ->obd_dev_mutex helds. lmv_statfs will then call obd_statfs() on a different device and ->obd_dev_mutex will be taken again. This is a *different* mutex, but lockdep cannot see the difference, so it complains. We can tell lockdep not to worry in this case using mutex_lock_interruptible_nested(). WC-bug-id: https://jira.whamcloud.com/browse/LU-9679 Lustre-commit: 10dae4c3b68eb ("LU-9679 lov: annotate nested locking of obd_dev_mutex") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/39248 Reviewed-by: James Simmons Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/include/obd_class.h | 8 +++++++- fs/lustre/lmv/lmv_obd.c | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/lustre/include/obd_class.h b/fs/lustre/include/obd_class.h index 78f7b16..e8168bc5 100644 --- a/fs/lustre/include/obd_class.h +++ b/fs/lustre/include/obd_class.h @@ -49,6 +49,10 @@ #define OBD_STATFS_FOR_MDT0 0x0004 /* get aggregated statfs from MDT */ #define OBD_STATFS_SUM 0x0008 +#define OBD_STATFS_NESTED 0x0010 /* Call while already holding + * obd_dev_mutex of a difference + * device. + */ /* OBD Device Declarations */ extern rwlock_t obd_dev_lock; @@ -945,7 +949,9 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, ((obd->obd_osfs.os_state & OS_STATFS_SUM) && !(flags & OBD_STATFS_SUM))) { /* the RPC will block anyway, so avoid sending many at once */ - rc = mutex_lock_interruptible(&obd->obd_dev_mutex); + rc = mutex_lock_interruptible_nested(&obd->obd_dev_mutex, + (flags & OBD_STATFS_NESTED) + ? SINGLE_DEPTH_NESTING : 0); if (rc) return rc; if (obd->obd_osfs_age < max_age || diff --git a/fs/lustre/lmv/lmv_obd.c b/fs/lustre/lmv/lmv_obd.c index 4131b49..5a75c69 100644 --- a/fs/lustre/lmv/lmv_obd.c +++ b/fs/lustre/lmv/lmv_obd.c @@ -1248,7 +1248,8 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, if (!tgt || !tgt->ltd_exp) continue; - rc = obd_statfs(env, tgt->ltd_exp, temp, max_age, flags); + rc = obd_statfs(env, tgt->ltd_exp, temp, max_age, + flags | OBD_STATFS_NESTED); if (rc) { CERROR("%s: can't stat MDS #%d: rc = %d\n", tgt->ltd_exp->exp_obd->obd_name, i, rc); From patchwork Tue Aug 11 12:19:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709167 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2ED9B14E3 for ; Tue, 11 Aug 2020 12:20:32 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 168DB20578 for ; Tue, 11 Aug 2020 12:20:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 168DB20578 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id D249F2F376E; Tue, 11 Aug 2020 05:20:27 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 860FD21F209 for ; Tue, 11 Aug 2020 05:20:23 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id EFA8810055EB; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id E3EF42B4; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:19:59 -0400 Message-Id: <1597148419-20629-4-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 03/23] lustre: ptlrpc: make ptlrpc_connection_put() static inline X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown This function needs to be called from the obdclass modules, but is currently defined in a module that depends on that module. The get around this interdependence, a global variable ptlrpc_put_connection_superhack is used to make a pointer to the function available. Rather than this hack, we can make ptlrpc_connection_put() static-inline. This does expose some details of ptlrpc to obdclass, but there is already a fairly tight connection. Also change the return value to 'void' as it is never used, and don't bother checking for NULL before calling, as the function has its own test for NULL. WC-bug-id: https://jira.whamcloud.com/browse/LU-9679 Lustre-commit: 0a03e51b7e49a ("LU-9679 lustre: make ptlrpc_connection_put() static inline") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/39291 Reviewed-by: Sebastien Buisson Reviewed-by: Alex Zhuravlev Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/include/lustre_net.h | 32 +++++++++++++++++++++++++++++++- fs/lustre/include/obd_class.h | 8 -------- fs/lustre/obdclass/genops.c | 11 +++-------- fs/lustre/ptlrpc/connection.c | 35 ----------------------------------- fs/lustre/ptlrpc/import.c | 6 ++---- fs/lustre/ptlrpc/ptlrpc_module.c | 2 -- 6 files changed, 36 insertions(+), 58 deletions(-) diff --git a/fs/lustre/include/lustre_net.h b/fs/lustre/include/lustre_net.h index 2d58f13e..dd482bc 100644 --- a/fs/lustre/include/lustre_net.h +++ b/fs/lustre/include/lustre_net.h @@ -1777,7 +1777,37 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, struct ptlrpc_connection *ptlrpc_connection_get(struct lnet_process_id peer, lnet_nid_t self, struct obd_uuid *uuid); -int ptlrpc_connection_put(struct ptlrpc_connection *c); + +static inline void ptlrpc_connection_put(struct ptlrpc_connection *conn) +{ + if (!conn) + return; + + LASSERT(atomic_read(&conn->c_refcount) > 0); + + /* + * We do not remove connection from hashtable and + * do not free it even if last caller released ref, + * as we want to have it cached for the case it is + * needed again. + * + * Deallocating it and later creating new connection + * again would be wastful. This way we also avoid + * expensive locking to protect things from get/put + * race when found cached connection is freed by + * ptlrpc_connection_put(). + * + * It will be freed later in module unload time, + * when ptlrpc_connection_fini()->lh_exit->conn_exit() + * path is called. + */ + atomic_dec(&conn->c_refcount); + + CDEBUG(D_INFO, "PUT conn=%p refcount %d to %s\n", + conn, atomic_read(&conn->c_refcount), + libcfs_nid2str(conn->c_peer.nid)); +} + struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *); int ptlrpc_connection_init(void); void ptlrpc_connection_fini(void); diff --git a/fs/lustre/include/obd_class.h b/fs/lustre/include/obd_class.h index e8168bc5..187553d 100644 --- a/fs/lustre/include/obd_class.h +++ b/fs/lustre/include/obd_class.h @@ -1691,14 +1691,6 @@ struct lwp_register_item { char lri_name[MTI_NAME_MAXLEN]; }; -/* - * I'm as embarrassed about this as you are. - * - * // XXX do not look into _superhack with remaining eye - * // XXX if this were any uglier, I'd get my own show on MTV - */ -extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c); - /* obd_mount.c */ int lustre_check_exclusion(struct super_block *sb, char *svname); diff --git a/fs/lustre/obdclass/genops.c b/fs/lustre/obdclass/genops.c index 759d97e..7bc4dab 100644 --- a/fs/lustre/obdclass/genops.c +++ b/fs/lustre/obdclass/genops.c @@ -53,9 +53,6 @@ static void obd_zombie_export_add(struct obd_export *exp); static void obd_zombie_import_add(struct obd_import *imp); -int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c); -EXPORT_SYMBOL(ptlrpc_put_connection_superhack); - /* * support functions: we could use inter-module communication, but this * is more portable to other OS's @@ -717,9 +714,7 @@ static void class_export_destroy(struct obd_export *exp) CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp, exp->exp_client_uuid.uuid, obd->obd_name); - /* "Local" exports (lctl, LOV->{mdc,osc}) have no connection. */ - if (exp->exp_connection) - ptlrpc_put_connection_superhack(exp->exp_connection); + ptlrpc_connection_put(exp->exp_connection); LASSERT(list_empty(&exp->exp_outstanding_replies)); LASSERT(list_empty(&exp->exp_uncommitted_replies)); @@ -907,13 +902,13 @@ static void obd_zombie_import_free(struct obd_import *imp) LASSERT(refcount_read(&imp->imp_refcount) == 0); - ptlrpc_put_connection_superhack(imp->imp_connection); + ptlrpc_connection_put(imp->imp_connection); while ((imp_conn = list_first_entry_or_null(&imp->imp_conn_list, struct obd_import_conn, oic_item)) != NULL) { list_del_init(&imp_conn->oic_item); - ptlrpc_put_connection_superhack(imp_conn->oic_conn); + ptlrpc_connection_put(imp_conn->oic_conn); kfree(imp_conn); } diff --git a/fs/lustre/ptlrpc/connection.c b/fs/lustre/ptlrpc/connection.c index a548d99..1551a9a 100644 --- a/fs/lustre/ptlrpc/connection.c +++ b/fs/lustre/ptlrpc/connection.c @@ -130,41 +130,6 @@ struct ptlrpc_connection * return conn; } -int ptlrpc_connection_put(struct ptlrpc_connection *conn) -{ - int rc = 0; - - if (!conn) - return rc; - - LASSERT(atomic_read(&conn->c_refcount) > 0); - - /* - * We do not remove connection from hashtable and - * do not free it even if last caller released ref, - * as we want to have it cached for the case it is - * needed again. - * - * Deallocating it and later creating new connection - * again would be wastful. This way we also avoid - * expensive locking to protect things from get/put - * race when found cached connection is freed by - * ptlrpc_connection_put(). - * - * It will be freed later in module unload time, - * when ptlrpc_connection_fini()->lh_exit->conn_exit() - * path is called. - */ - if (atomic_dec_return(&conn->c_refcount) == 0) - rc = 1; - - CDEBUG(D_INFO, "PUT conn=%p refcount %d to %s\n", - conn, atomic_read(&conn->c_refcount), - libcfs_nid2str(conn->c_peer.nid)); - - return rc; -} - struct ptlrpc_connection * ptlrpc_connection_addref(struct ptlrpc_connection *conn) { diff --git a/fs/lustre/ptlrpc/import.c b/fs/lustre/ptlrpc/import.c index 1490dcf..4e573cd 100644 --- a/fs/lustre/ptlrpc/import.c +++ b/fs/lustre/ptlrpc/import.c @@ -571,8 +571,7 @@ static int import_select_connection(struct obd_import *imp) imp_conn->oic_last_attempt = ktime_get_seconds(); /* switch connection, don't mind if it's same as the current one */ - if (imp->imp_connection) - ptlrpc_connection_put(imp->imp_connection); + ptlrpc_connection_put(imp->imp_connection); imp->imp_connection = ptlrpc_connection_addref(imp_conn->oic_conn); dlmexp = class_conn2export(&imp->imp_dlm_handle); @@ -580,8 +579,7 @@ static int import_select_connection(struct obd_import *imp) rc = -EINVAL; goto out_unlock; } - if (dlmexp->exp_connection) - ptlrpc_connection_put(dlmexp->exp_connection); + ptlrpc_connection_put(dlmexp->exp_connection); dlmexp->exp_connection = ptlrpc_connection_addref(imp_conn->oic_conn); class_export_put(dlmexp); diff --git a/fs/lustre/ptlrpc/ptlrpc_module.c b/fs/lustre/ptlrpc/ptlrpc_module.c index 0c988ae..85fb0fa 100644 --- a/fs/lustre/ptlrpc/ptlrpc_module.c +++ b/fs/lustre/ptlrpc/ptlrpc_module.c @@ -49,8 +49,6 @@ int ptlrpc_inc_ref(void) mutex_lock(&ptlrpc_startup); if (ptlrpc_active++ == 0) { - ptlrpc_put_connection_superhack = ptlrpc_connection_put; - rc = ptlrpc_init_portals(); if (!rc) { rc = ptlrpc_start_pinger(); From patchwork Tue Aug 11 12:20:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709177 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6383314E3 for ; Tue, 11 Aug 2020 12:20:54 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B6D4206C3 for ; Tue, 11 Aug 2020 12:20:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B6D4206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C77352F3809; Tue, 11 Aug 2020 05:20:37 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id DBD5A21F209 for ; Tue, 11 Aug 2020 05:20:23 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id F1A9610055EC; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id E76532B6; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:00 -0400 Message-Id: <1597148419-20629-5-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 04/23] lustre: mdc: create mdc_acl.c X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown This new C file contains acl related code so it can be conditionally compiled. Also remove conditional code around the call to mdc_unpack_acl(), as those tests are already performed inside mdc_unpack_acl(). This removes all #ifdef of CONFIG_LUSTRE_FS_POSIX_ACL from C files in 'mdc'. WC-bug-id: https://jira.whamcloud.com/browse/LU-9679 Lustre-commit: 896ff00276afd ("LU-9679 mdc: create mdc_acl.c") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/39292 Reviewed-by: James Simmons Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/mdc/Makefile | 1 + fs/lustre/mdc/mdc_acl.c | 64 ++++++++++++++++++++++++++++++++++++++++++++ fs/lustre/mdc/mdc_internal.h | 10 +++++++ fs/lustre/mdc/mdc_request.c | 61 +++++------------------------------------ 4 files changed, 81 insertions(+), 55 deletions(-) create mode 100644 fs/lustre/mdc/mdc_acl.c diff --git a/fs/lustre/mdc/Makefile b/fs/lustre/mdc/Makefile index 2cbc641..1ac97ee 100644 --- a/fs/lustre/mdc/Makefile +++ b/fs/lustre/mdc/Makefile @@ -3,3 +3,4 @@ ccflags-y += -I$(srctree)/$(src)/../include obj-$(CONFIG_LUSTRE_FS) += mdc.o mdc-y := mdc_changelog.o mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o lproc_mdc.o mdc-y += mdc_dev.o +mdc-$(CONFIG_LUSTRE_FS_POSIX_ACL) += mdc_acl.o diff --git a/fs/lustre/mdc/mdc_acl.c b/fs/lustre/mdc/mdc_acl.c new file mode 100644 index 0000000..6814045 --- /dev/null +++ b/fs/lustre/mdc/mdc_acl.c @@ -0,0 +1,64 @@ +// 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 + */ +#include + +#include "mdc_internal.h" + +int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md) +{ + struct req_capsule *pill = &req->rq_pill; + struct mdt_body *body = md->body; + struct posix_acl *acl; + void *buf; + int rc; + + /* for ACL, it's possible that FLACL is set but aclsize is zero. + * only when aclsize != 0 there's an actual segment for ACL + * in reply buffer. + */ + if (!body->mbo_aclsize) { + md->posix_acl = NULL; + return 0; + } + + buf = req_capsule_server_sized_get(pill, &RMF_ACL, body->mbo_aclsize); + if (!buf) + return -EPROTO; + + acl = posix_acl_from_xattr(&init_user_ns, buf, body->mbo_aclsize); + if (IS_ERR_OR_NULL(acl)) { + rc = acl ? PTR_ERR(acl) : 0; + CERROR("convert xattr to acl: %d\n", rc); + return rc; + } + + rc = posix_acl_valid(&init_user_ns, acl); + if (rc) { + CERROR("validate acl: %d\n", rc); + posix_acl_release(acl); + return rc; + } + + md->posix_acl = acl; + return 0; +} diff --git a/fs/lustre/mdc/mdc_internal.h b/fs/lustre/mdc/mdc_internal.h index b7ccc58..a1fb5d9 100644 --- a/fs/lustre/mdc/mdc_internal.h +++ b/fs/lustre/mdc/mdc_internal.h @@ -156,6 +156,16 @@ static inline int mdc_prep_elc_req(struct obd_export *exp, count); } +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL +int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md); +#else +static inline +int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md) +{ + return 0; +} +#endif + static inline unsigned long hash_x_index(u64 hash, int hash64) { if (BITS_PER_LONG == 32 && hash64) diff --git a/fs/lustre/mdc/mdc_request.c b/fs/lustre/mdc/mdc_request.c index cacc58b..f2bca8e 100644 --- a/fs/lustre/mdc/mdc_request.c +++ b/fs/lustre/mdc/mdc_request.c @@ -508,46 +508,6 @@ static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid, return rc; } -#ifdef CONFIG_LUSTRE_FS_POSIX_ACL -static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md) -{ - struct req_capsule *pill = &req->rq_pill; - struct mdt_body *body = md->body; - struct posix_acl *acl; - void *buf; - int rc; - - if (!body->mbo_aclsize) - return 0; - - buf = req_capsule_server_sized_get(pill, &RMF_ACL, body->mbo_aclsize); - - if (!buf) - return -EPROTO; - - acl = posix_acl_from_xattr(&init_user_ns, buf, body->mbo_aclsize); - if (!acl) - return 0; - - if (IS_ERR(acl)) { - rc = PTR_ERR(acl); - CERROR("convert xattr to acl: %d\n", rc); - return rc; - } - - rc = posix_acl_valid(&init_user_ns, acl); - if (rc) { - CERROR("validate acl: %d\n", rc); - posix_acl_release(acl); - return rc; - } - - md->posix_acl = acl; - return 0; -} -#else -#define mdc_unpack_acl(req, md) 0 -#endif static int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, @@ -658,21 +618,12 @@ static int mdc_get_lustre_md(struct obd_export *exp, } rc = 0; - if (md->body->mbo_valid & OBD_MD_FLACL) { - /* for ACL, it's possible that FLACL is set but aclsize is zero. - * only when aclsize != 0 there's an actual segment for ACL - * in reply buffer. - */ - if (md->body->mbo_aclsize) { - rc = mdc_unpack_acl(req, md); - if (rc) - goto out; -#ifdef CONFIG_LUSTRE_FS_POSIX_ACL - } else { - md->posix_acl = NULL; -#endif - } - } + /* for ACL, it's possible that FLACL is set but aclsize is zero. + * only when aclsize != 0 there's an actual segment for ACL + * in reply buffer. + */ + if (md->body->mbo_valid & OBD_MD_FLACL) + rc = mdc_unpack_acl(req, md); out: if (rc) From patchwork Tue Aug 11 12:20:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709181 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60AB11392 for ; Tue, 11 Aug 2020 12:21:00 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 48275206C3 for ; Tue, 11 Aug 2020 12:21:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48275206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id DF4772F37EC; Tue, 11 Aug 2020 05:20:40 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 97A7A21F209 for ; Tue, 11 Aug 2020 05:20:24 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 0906410055FE; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id E9C0C2B7; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:01 -0400 Message-Id: <1597148419-20629-6-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 05/23] lustre: llite: Remove mutex on dio read X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Patrick Farrell , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Patrick Farrell DIO reads in Lustre are protected by Lustre range locking and do not need the inode mutex. This code was removed in LU-1669, the range lock was added for DIO reads in LU-6227, and then the mutex was accidentally re-introduced in LU-6260. Remove it again. Fixes: fde7ac1942f5 ("lustre: llite: add support for direct IO api changes") WC-bug-id: https://jira.whamcloud.com/browse/LU-13196 Lustre-commit: 5bc1fe092cba0 ("LU-13196 llite: Remove mutex on dio read") Signed-off-by: Patrick Farrell Reviewed-on: https://review.whamcloud.com/37419 Reviewed-by: Wang Shilong Reviewed-by: Neil Brown Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/rw26.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/fs/lustre/llite/rw26.c b/fs/lustre/llite/rw26.c index b3802cf..7010fe8 100644 --- a/fs/lustre/llite/rw26.c +++ b/fs/lustre/llite/rw26.c @@ -328,13 +328,6 @@ static ssize_t ll_direct_IO(struct kiocb *iocb, struct iov_iter *iter) LASSERT(aio); LASSERT(aio->cda_iocb == iocb); - /* 0. Need locking between buffered and direct access. and race with - * size changing by concurrent truncates and writes. - * 1. Need inode mutex to operate transient pages. - */ - if (rw == READ) - inode_lock(inode); - while (iov_iter_count(iter)) { struct ll_dio_pages pvec = { .ldp_aio = aio }; struct page **pages; @@ -406,9 +399,6 @@ static ssize_t ll_direct_IO(struct kiocb *iocb, struct iov_iter *iter) result = -EIOCBQUEUED; } - if (rw == READ) - inode_unlock(inode); - return result; } From patchwork Tue Aug 11 12:20:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709173 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3845A1392 for ; Tue, 11 Aug 2020 12:20:44 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2008A206C3 for ; Tue, 11 Aug 2020 12:20:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2008A206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id ABED72F3705; Tue, 11 Aug 2020 05:20:33 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 3FC8F21F209 for ; Tue, 11 Aug 2020 05:20:24 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 07DF810055ED; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id ECC3E2CF; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:02 -0400 Message-Id: <1597148419-20629-7-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 06/23] lustre: obd: rename lprocfs_ / LPROC_SEQ_ to debugfs name X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" For a long time lustre has not used procfs so rename several functions starting with lprocfs_* to ldebugfs_*. Do this as well the for LPROC_SEQ_* macros to LDEBUGFS_SEQ_*. WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Lustre-commit: 0100ab268c312 ("LU-8066 obd: final pieces for sysfs/debugfs support.") Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/28108 Reviewed-by: Dmitry Eremin Reviewed-by: Ben Evans Reviewed-by: Oleg Drokin --- fs/lustre/fid/fid_internal.h | 2 +- fs/lustre/fid/lproc_fid.c | 10 +-- fs/lustre/fld/fld_internal.h | 2 +- fs/lustre/fld/lproc_fld.c | 12 +-- fs/lustre/include/lprocfs_status.h | 158 ++++++++++++------------------------ fs/lustre/include/obd.h | 2 +- fs/lustre/include/obd_class.h | 4 - fs/lustre/ldlm/ldlm_internal.h | 2 +- fs/lustre/ldlm/ldlm_pool.c | 4 +- fs/lustre/ldlm/ldlm_resource.c | 10 +-- fs/lustre/llite/lproc_llite.c | 30 +++---- fs/lustre/mdc/lproc_mdc.c | 28 +++---- fs/lustre/mgc/lproc_mgc.c | 12 +-- fs/lustre/obdclass/lprocfs_status.c | 48 ++++++----- fs/lustre/obdclass/obd_config.c | 92 --------------------- fs/lustre/obdclass/obd_sysfs.c | 2 +- fs/lustre/osc/lproc_osc.c | 24 +++--- fs/lustre/ptlrpc/lproc_ptlrpc.c | 30 +++---- fs/lustre/ptlrpc/sec_lproc.c | 15 ++-- 19 files changed, 171 insertions(+), 316 deletions(-) diff --git a/fs/lustre/fid/fid_internal.h b/fs/lustre/fid/fid_internal.h index 7bb1283..cbf0987 100644 --- a/fs/lustre/fid/fid_internal.h +++ b/fs/lustre/fid/fid_internal.h @@ -41,6 +41,6 @@ /* Functions used internally in module. */ -extern struct lprocfs_vars seq_client_debugfs_list[]; +extern struct ldebugfs_vars seq_client_debugfs_list[]; #endif /* __FID_INTERNAL_H */ diff --git a/fs/lustre/fid/lproc_fid.c b/fs/lustre/fid/lproc_fid.c index 15468b4..be9846b 100644 --- a/fs/lustre/fid/lproc_fid.c +++ b/fs/lustre/fid/lproc_fid.c @@ -209,12 +209,12 @@ static ssize_t ldebugfs_fid_width_seq_write(struct file *file, return 0; } -LPROC_SEQ_FOPS(ldebugfs_fid_space); -LPROC_SEQ_FOPS(ldebugfs_fid_width); -LPROC_SEQ_FOPS_RO(ldebugfs_fid_server); -LPROC_SEQ_FOPS_RO(ldebugfs_fid_fid); +LDEBUGFS_SEQ_FOPS(ldebugfs_fid_space); +LDEBUGFS_SEQ_FOPS(ldebugfs_fid_width); +LDEBUGFS_SEQ_FOPS_RO(ldebugfs_fid_server); +LDEBUGFS_SEQ_FOPS_RO(ldebugfs_fid_fid); -struct lprocfs_vars seq_client_debugfs_list[] = { +struct ldebugfs_vars seq_client_debugfs_list[] = { { .name = "space", .fops = &ldebugfs_fid_space_fops }, { .name = "width", diff --git a/fs/lustre/fld/fld_internal.h b/fs/lustre/fld/fld_internal.h index d44e378..d32360c 100644 --- a/fs/lustre/fld/fld_internal.h +++ b/fs/lustre/fld/fld_internal.h @@ -133,7 +133,7 @@ int fld_client_rpc(struct obd_export *exp, struct lu_seq_range *range, u32 fld_op, struct ptlrpc_request **reqp); -extern struct lprocfs_vars fld_client_debugfs_list[]; +extern struct ldebugfs_vars fld_client_debugfs_list[]; struct fld_cache *fld_cache_init(const char *name, int cache_size, int cache_threshold); diff --git a/fs/lustre/fld/lproc_fld.c b/fs/lustre/fld/lproc_fld.c index e8c8bc7..9e1be53 100644 --- a/fs/lustre/fld/lproc_fld.c +++ b/fs/lustre/fld/lproc_fld.c @@ -117,8 +117,8 @@ } static ssize_t -lprocfs_wr_cache_flush(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) +ldebugfs_cache_flush_seq_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { struct seq_file *m = file->private_data; struct lu_client_fld *fld = m->private; @@ -130,11 +130,11 @@ return count; } -LPROC_SEQ_FOPS_RO(fld_debugfs_targets); -LPROC_SEQ_FOPS(fld_debugfs_hash); -LPROC_SEQ_FOPS_WR_ONLY(fld, cache_flush); +LDEBUGFS_SEQ_FOPS_RO(fld_debugfs_targets); +LDEBUGFS_SEQ_FOPS(fld_debugfs_hash); +LDEBUGFS_SEQ_FOPS_WR_ONLY(fld, cache_flush); -struct lprocfs_vars fld_client_debugfs_list[] = { +struct ldebugfs_vars fld_client_debugfs_list[] = { { .name = "targets", .fops = &fld_debugfs_targets_fops }, { .name = "hash", diff --git a/fs/lustre/include/lprocfs_status.h b/fs/lustre/include/lprocfs_status.h index 759e66b..33d78de 100644 --- a/fs/lustre/include/lprocfs_status.h +++ b/fs/lustre/include/lprocfs_status.h @@ -49,13 +49,12 @@ #include #include -struct lprocfs_vars { +/** debugfs file mode. */ +struct ldebugfs_vars { const char *name; const struct file_operations *fops; void *data; - /** - * sysfs file mode. - */ + /** debugfs file mode. */ umode_t proc_mode; }; @@ -67,11 +66,6 @@ static inline unsigned int pct(unsigned long a, unsigned long b) #define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT)) #define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT)) -struct lprocfs_static_vars { - struct lprocfs_vars *obd_vars; - const struct attribute_group *sysfs_vars; -}; - /* if we find more consumers this could be generalized */ #define OBD_HIST_MAX 32 struct obd_histogram { @@ -446,7 +440,7 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index, extern const struct file_operations lprocfs_stats_seq_fops; /* lprocfs_status.c */ -void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var, +void ldebugfs_add_vars(struct dentry *parent, struct ldebugfs_vars *var, void *data); int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only); @@ -454,29 +448,30 @@ void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var, /* Generic callbacks */ -int lprocfs_rd_uint(struct seq_file *m, void *data); +int ldebugfs_uint(struct seq_file *m, void *data); int lprocfs_wr_uint(struct file *file, const char __user *buffer, unsigned long count, void *data); -int lprocfs_rd_server_uuid(struct seq_file *m, void *data); -int lprocfs_rd_conn_uuid(struct seq_file *m, void *data); +int ldebugfs_server_uuid_seq_show(struct seq_file *m, void *data); +int ldebugfs_conn_uuid_seq_show(struct seq_file *m, void *data); ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf); -int lprocfs_rd_import(struct seq_file *m, void *data); -int lprocfs_rd_state(struct seq_file *m, void *data); -int lprocfs_rd_connect_flags(struct seq_file *m, void *data); +int ldebugfs_import_seq_show(struct seq_file *m, void *data); +int ldebugfs_state_seq_show(struct seq_file *m, void *data); +int ldebugfs_connect_flags_seq_show(struct seq_file *m, void *data); struct adaptive_timeout; int lprocfs_at_hist_helper(struct seq_file *m, struct adaptive_timeout *at); -int lprocfs_rd_timeouts(struct seq_file *m, void *data); +int ldebugfs_timeouts_seq_show(struct seq_file *m, void *data); ssize_t ping_store(struct kobject *kobj, struct attribute *attr, const char *buffer, size_t count); ssize_t ping_show(struct kobject *kobj, struct attribute *attr, char *buffer); -int lprocfs_wr_import(struct file *file, const char __user *buffer, - size_t count, loff_t *off); -int lprocfs_rd_pinger_recov(struct seq_file *m, void *n); -int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, - size_t count, loff_t *off); +ssize_t ldebugfs_import_seq_write(struct file *file, const char __user *buffer, + size_t count, loff_t *off); +int ldebugfs_pinger_recov_seq_show(struct seq_file *m, void *n); +ssize_t ldebugfs_pinger_recov_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off); int string_to_size(u64 *size, const char *buffer, size_t count); int sysfs_memparse(const char *buffer, size_t count, u64 *val, @@ -501,12 +496,12 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, __imp ? 1 : (up_read(&(__obd)->u.cli.cl_sem), 0); \ __imp = NULL) -/* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only - * proc entries; otherwise, you will define name##_seq_write function also for - * a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally, - * call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); +/* write the name##_seq_show function, call LDEBUGFS_SEQ_FOPS_RO for read-only + * debugfs entries; otherwise, you will define name##_seq_write function also + * for a read-write debugfs entry, and then call LDEBUGFS_SEQ_SEQ instead. + * Finally, call debugfs_create_file(filename, 0444, obd, data, &name#_fops); */ -#define __LPROC_SEQ_FOPS(name, custom_seq_write) \ +#define __LDEBUGFS_SEQ_FOPS(name, custom_seq_write) \ static int name##_single_open(struct inode *inode, struct file *file) \ { \ return single_open(file, name##_seq_show, inode->i_private); \ @@ -520,44 +515,46 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, .release = single_release, \ } -#define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL) -#define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write) +#define LDEBUGFS_SEQ_FOPS_RO(name) __LDEBUGFS_SEQ_FOPS(name, NULL) +#define LDEBUGFS_SEQ_FOPS(name) __LDEBUGFS_SEQ_FOPS(name, \ + name##_seq_write) -#define LPROC_SEQ_FOPS_RO_TYPE(name, type) \ +#define LDEBUGFS_SEQ_FOPS_RO_TYPE(name, type) \ static int name##_##type##_seq_show(struct seq_file *m, void *v)\ { \ if (!m->private) \ return -ENODEV; \ - return lprocfs_rd_##type(m, m->private); \ + return ldebugfs_##type##_seq_show(m, m->private); \ } \ - LPROC_SEQ_FOPS_RO(name##_##type) + LDEBUGFS_SEQ_FOPS_RO(name##_##type) -#define LPROC_SEQ_FOPS_RW_TYPE(name, type) \ +#define LDEBUGFS_SEQ_FOPS_RW_TYPE(name, type) \ static int name##_##type##_seq_show(struct seq_file *m, void *v)\ { \ if (!m->private) \ return -ENODEV; \ - return lprocfs_rd_##type(m, m->private); \ + return ldebugfs_##type##_seq_show(m, m->private); \ } \ static ssize_t name##_##type##_seq_write(struct file *file, \ const char __user *buffer, size_t count, \ - loff_t *off) \ + loff_t *off) \ { \ struct seq_file *seq = file->private_data; \ \ if (!seq->private) \ return -ENODEV; \ - return lprocfs_wr_##type(file, buffer, \ - count, seq->private); \ + return ldebugfs_##type##_seq_write(file, buffer, count, \ + seq->private); \ } \ - LPROC_SEQ_FOPS(name##_##type) + LDEBUGFS_SEQ_FOPS(name##_##type) -#define LPROC_SEQ_FOPS_WR_ONLY(name, type) \ +#define LDEBUGFS_SEQ_FOPS_WR_ONLY(name, type) \ static ssize_t name##_##type##_write(struct file *file, \ - const char __user *buffer, size_t count, \ - loff_t *off) \ + const char __user *buffer, \ + size_t count, loff_t *off) \ { \ - return lprocfs_wr_##type(file, buffer, count, off); \ + return ldebugfs_##type##_seq_write(file, buffer, count, \ + off); \ } \ static int name##_##type##_open(struct inode *inode, \ struct file *file) \ @@ -565,8 +562,8 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, return single_open(file, NULL, inode->i_private); \ } \ static const struct file_operations name##_##type##_fops = { \ - .open = name##_##type##_open, \ - .write = name##_##type##_write, \ + .open = name##_##type##_open, \ + .write = name##_##type##_write, \ .release = single_release, \ } @@ -602,68 +599,13 @@ ssize_t short_io_bytes_store(struct kobject *kobj, struct attribute *attr, const char *buffer, size_t count); struct root_squash_info; -int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count, - struct root_squash_info *squash, char *name); -int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, - struct root_squash_info *squash, char *name); - -/* all quota proc functions */ -int lprocfs_quota_rd_bunit(char *page, char **start, - loff_t off, int count, - int *eof, void *data); -int lprocfs_quota_wr_bunit(struct file *file, const char *buffer, - unsigned long count, void *data); -int lprocfs_quota_rd_btune(char *page, char **start, - loff_t off, int count, - int *eof, void *data); -int lprocfs_quota_wr_btune(struct file *file, const char *buffer, - unsigned long count, void *data); -int lprocfs_quota_rd_iunit(char *page, char **start, - loff_t off, int count, - int *eof, void *data); -int lprocfs_quota_wr_iunit(struct file *file, const char *buffer, - unsigned long count, void *data); -int lprocfs_quota_rd_itune(char *page, char **start, - loff_t off, int count, - int *eof, void *data); -int lprocfs_quota_wr_itune(struct file *file, const char *buffer, - unsigned long count, void *data); -int lprocfs_quota_rd_type(char *page, char **start, loff_t off, int count, - int *eof, void *data); -int lprocfs_quota_wr_type(struct file *file, const char *buffer, - unsigned long count, void *data); -int lprocfs_quota_rd_switch_seconds(char *page, char **start, loff_t off, - int count, int *eof, void *data); -int lprocfs_quota_wr_switch_seconds(struct file *file, - const char *buffer, - unsigned long count, void *data); -int lprocfs_quota_rd_sync_blk(char *page, char **start, loff_t off, - int count, int *eof, void *data); -int lprocfs_quota_wr_sync_blk(struct file *file, const char *buffer, - unsigned long count, void *data); -int lprocfs_quota_rd_switch_qs(char *page, char **start, loff_t off, - int count, int *eof, void *data); -int lprocfs_quota_wr_switch_qs(struct file *file, - const char *buffer, unsigned long count, - void *data); -int lprocfs_quota_rd_boundary_factor(char *page, char **start, loff_t off, - int count, int *eof, void *data); -int lprocfs_quota_wr_boundary_factor(struct file *file, - const char *buffer, unsigned long count, - void *data); -int lprocfs_quota_rd_least_bunit(char *page, char **start, loff_t off, - int count, int *eof, void *data); -int lprocfs_quota_wr_least_bunit(struct file *file, - const char *buffer, unsigned long count, - void *data); -int lprocfs_quota_rd_least_iunit(char *page, char **start, loff_t off, - int count, int *eof, void *data); -int lprocfs_quota_wr_least_iunit(struct file *file, - const char *buffer, unsigned long count, - void *data); -int lprocfs_quota_rd_qs_factor(char *page, char **start, loff_t off, - int count, int *eof, void *data); -int lprocfs_quota_wr_qs_factor(struct file *file, - const char *buffer, unsigned long count, - void *data); +ssize_t ldebugfs_root_squash_seq_write(const char __user *buffer, + unsigned long count, + struct root_squash_info *squash, + char *name); +ssize_t ldebugfs_nosquash_nids_seq_write(const char __user *buffer, + unsigned long count, + struct root_squash_info *squash, + char *name); + #endif /* LPROCFS_SNMP_H */ diff --git a/fs/lustre/include/obd.h b/fs/lustre/include/obd.h index ad2b2f4..849483f 100644 --- a/fs/lustre/include/obd.h +++ b/fs/lustre/include/obd.h @@ -608,7 +608,7 @@ struct obd_device { struct dentry *obd_svc_debugfs_entry; struct lprocfs_stats *obd_svc_stats; const struct attribute **obd_attrs; - struct lprocfs_vars *obd_vars; + struct ldebugfs_vars *obd_vars; atomic_t obd_evict_inprogress; wait_queue_head_t obd_evict_inprogress_waitq; struct list_head obd_evict_list; /* protected with pet_lock */ diff --git a/fs/lustre/include/obd_class.h b/fs/lustre/include/obd_class.h index 187553d..a22581d 100644 --- a/fs/lustre/include/obd_class.h +++ b/fs/lustre/include/obd_class.h @@ -134,8 +134,6 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *, ssize_t class_set_global(const char *param); ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix, struct kobject *kobj); -int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, - struct lustre_cfg *lcfg, void *data); /* For interoperability */ struct cfg_interop_param { @@ -162,8 +160,6 @@ int class_config_llog_handler(const struct lu_env *env, struct llog_rec_hdr *rec, void *data); /* obdecho */ -void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars); - #define CFG_F_START 0x01 /* Set when we start updating from a log */ #define CFG_F_MARKER 0x02 /* We are within a maker */ #define CFG_F_SKIP 0x04 /* We should ignore this cfg command */ diff --git a/fs/lustre/ldlm/ldlm_internal.h b/fs/lustre/ldlm/ldlm_internal.h index 996c0fb..0dce219 100644 --- a/fs/lustre/ldlm/ldlm_internal.h +++ b/fs/lustre/ldlm/ldlm_internal.h @@ -298,7 +298,7 @@ enum ldlm_policy_res { struct __##var##__dummy_write {; } /* semicolon catcher */ static inline void -ldlm_add_var(struct lprocfs_vars *vars, struct dentry *debugfs_entry, +ldlm_add_var(struct ldebugfs_vars *vars, struct dentry *debugfs_entry, const char *name, void *data, const struct file_operations *ops) { vars->name = name; diff --git a/fs/lustre/ldlm/ldlm_pool.c b/fs/lustre/ldlm/ldlm_pool.c index 9185dc93..40585f7 100644 --- a/fs/lustre/ldlm/ldlm_pool.c +++ b/fs/lustre/ldlm/ldlm_pool.c @@ -459,7 +459,7 @@ static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused) return 0; } -LPROC_SEQ_FOPS_RO(lprocfs_pool_state); +LDEBUGFS_SEQ_FOPS_RO(lprocfs_pool_state); static ssize_t grant_speed_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -549,7 +549,7 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl) struct ldlm_namespace *ns = container_of(pl, struct ldlm_namespace, ns_pool); struct dentry *debugfs_ns_parent; - struct lprocfs_vars pool_vars[2]; + struct ldebugfs_vars pool_vars[2]; int rc = 0; debugfs_ns_parent = ns->ns_debugfs_entry; diff --git a/fs/lustre/ldlm/ldlm_resource.c b/fs/lustre/ldlm/ldlm_resource.c index a461ca7..d0a59a8 100644 --- a/fs/lustre/ldlm/ldlm_resource.c +++ b/fs/lustre/ldlm/ldlm_resource.c @@ -71,15 +71,15 @@ static unsigned int ldlm_dump_granted_max = 256; static ssize_t -lprocfs_wr_dump_ns(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +ldebugfs_dump_ns_seq_write(struct file *file, const char __user *buffer, + size_t count, loff_t *off) { ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE); ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE); return count; } -LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns); +LDEBUGFS_SEQ_FOPS_WR_ONLY(ldlm, dump_ns); static int ldlm_rw_uint_seq_show(struct seq_file *m, void *v) { @@ -99,9 +99,9 @@ static int ldlm_rw_uint_seq_show(struct seq_file *m, void *v) (unsigned int *)seq->private); } -LPROC_SEQ_FOPS(ldlm_rw_uint); +LDEBUGFS_SEQ_FOPS(ldlm_rw_uint); -static struct lprocfs_vars ldlm_debugfs_list[] = { +static struct ldebugfs_vars ldlm_debugfs_list[] = { { "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 }, { "dump_granted_max", &ldlm_rw_uint_fops, &ldlm_dump_granted_max }, { NULL } diff --git a/fs/lustre/llite/lproc_llite.c b/fs/lustre/llite/lproc_llite.c index f5a1940..a742200 100644 --- a/fs/lustre/llite/lproc_llite.c +++ b/fs/lustre/llite/lproc_llite.c @@ -319,7 +319,7 @@ static int ll_site_stats_seq_show(struct seq_file *m, void *v) return cl_site_stats_print(lu2cl_site(ll_s2sbi(sb)->ll_site), m); } -LPROC_SEQ_FOPS_RO(ll_site_stats); +LDEBUGFS_SEQ_FOPS_RO(ll_site_stats); static ssize_t max_read_ahead_mb_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -601,7 +601,7 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, return rc; } -LPROC_SEQ_FOPS(ll_max_cached_mb); +LDEBUGFS_SEQ_FOPS(ll_max_cached_mb); static ssize_t checksums_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -851,7 +851,7 @@ static int ll_statahead_stats_seq_show(struct seq_file *m, void *v) return 0; } -LPROC_SEQ_FOPS_RO(ll_statahead_stats); +LDEBUGFS_SEQ_FOPS_RO(ll_statahead_stats); static ssize_t lazystatfs_show(struct kobject *kobj, struct attribute *attr, @@ -1028,7 +1028,7 @@ static int ll_sbi_flags_seq_show(struct seq_file *m, void *v) return 0; } -LPROC_SEQ_FOPS_RO(ll_sbi_flags); +LDEBUGFS_SEQ_FOPS_RO(ll_sbi_flags); static ssize_t xattr_cache_show(struct kobject *kobj, struct attribute *attr, @@ -1376,7 +1376,7 @@ static ssize_t ll_unstable_stats_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_unstable_stats); +LDEBUGFS_SEQ_FOPS(ll_unstable_stats); static int ll_root_squash_seq_show(struct seq_file *m, void *v) { @@ -1397,9 +1397,10 @@ static ssize_t ll_root_squash_seq_write(struct file *file, struct ll_sb_info *sbi = ll_s2sbi(sb); struct root_squash_info *squash = &sbi->ll_squash; - return lprocfs_wr_root_squash(buffer, count, squash, sbi->ll_fsname); + return ldebugfs_root_squash_seq_write(buffer, count, squash, + sbi->ll_fsname); } -LPROC_SEQ_FOPS(ll_root_squash); +LDEBUGFS_SEQ_FOPS(ll_root_squash); static int ll_nosquash_nids_seq_show(struct seq_file *m, void *v) { @@ -1432,7 +1433,8 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file, struct root_squash_info *squash = &sbi->ll_squash; int rc; - rc = lprocfs_wr_nosquash_nids(buffer, count, squash, sbi->ll_fsname); + rc = ldebugfs_nosquash_nids_seq_write(buffer, count, squash, + sbi->ll_fsname); if (rc < 0) return rc; @@ -1441,7 +1443,7 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file, return rc; } -LPROC_SEQ_FOPS(ll_nosquash_nids); +LDEBUGFS_SEQ_FOPS(ll_nosquash_nids); static int ll_pcc_seq_show(struct seq_file *m, void *v) { @@ -1480,9 +1482,9 @@ static ssize_t ll_pcc_seq_write(struct file *file, const char __user *buffer, kfree(kernbuf); return rc ? rc : count; } -LPROC_SEQ_FOPS(ll_pcc); +LDEBUGFS_SEQ_FOPS(ll_pcc); -struct lprocfs_vars lprocfs_llite_obd_vars[] = { +struct ldebugfs_vars lprocfs_llite_obd_vars[] = { { .name = "site", .fops = &ll_site_stats_fops }, { .name = "max_cached_mb", @@ -1858,7 +1860,7 @@ static ssize_t ll_rw_extents_stats_pp_seq_write(struct file *file, return len; } -LPROC_SEQ_FOPS(ll_rw_extents_stats_pp); +LDEBUGFS_SEQ_FOPS(ll_rw_extents_stats_pp); static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v) { @@ -1918,7 +1920,7 @@ static ssize_t ll_rw_extents_stats_seq_write(struct file *file, return len; } -LPROC_SEQ_FOPS(ll_rw_extents_stats); +LDEBUGFS_SEQ_FOPS(ll_rw_extents_stats); void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct ll_file_data *file, loff_t pos, @@ -2109,4 +2111,4 @@ static ssize_t ll_rw_offset_stats_seq_write(struct file *file, return len; } -LPROC_SEQ_FOPS(ll_rw_offset_stats); +LDEBUGFS_SEQ_FOPS(ll_rw_offset_stats); diff --git a/fs/lustre/mdc/lproc_mdc.c b/fs/lustre/mdc/lproc_mdc.c index 0c252ed..d7506ea 100644 --- a/fs/lustre/mdc/lproc_mdc.c +++ b/fs/lustre/mdc/lproc_mdc.c @@ -90,7 +90,7 @@ static ssize_t mdc_max_dirty_mb_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(mdc_max_dirty_mb); +LDEBUGFS_SEQ_FOPS(mdc_max_dirty_mb); static int mdc_cached_mb_seq_show(struct seq_file *m, void *v) { @@ -150,7 +150,7 @@ static int mdc_cached_mb_seq_show(struct seq_file *m, void *v) return count; } -LPROC_SEQ_FOPS(mdc_cached_mb); +LDEBUGFS_SEQ_FOPS(mdc_cached_mb); static int mdc_contention_seconds_seq_show(struct seq_file *m, void *v) { @@ -189,7 +189,7 @@ static ssize_t mdc_contention_seconds_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(mdc_contention_seconds); +LDEBUGFS_SEQ_FOPS(mdc_contention_seconds); static int mdc_unstable_stats_seq_show(struct seq_file *m, void *v) { @@ -205,7 +205,7 @@ static int mdc_unstable_stats_seq_show(struct seq_file *m, void *v) "unstable_mb: %10d\n", pages, mb); return 0; } -LPROC_SEQ_FOPS_RO(mdc_unstable_stats); +LDEBUGFS_SEQ_FOPS_RO(mdc_unstable_stats); static ssize_t active_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -427,7 +427,7 @@ static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v) return 0; } -LPROC_SEQ_FOPS(mdc_rpc_stats); +LDEBUGFS_SEQ_FOPS(mdc_rpc_stats); static int mdc_stats_seq_show(struct seq_file *seq, void *v) { @@ -459,7 +459,7 @@ static ssize_t mdc_stats_seq_write(struct file *file, memset(stats, 0, sizeof(*stats)); return len; } -LPROC_SEQ_FOPS(mdc_stats); +LDEBUGFS_SEQ_FOPS(mdc_stats); static int mdc_dom_min_repsize_seq_show(struct seq_file *m, void *v) { @@ -489,17 +489,17 @@ static ssize_t mdc_dom_min_repsize_seq_write(struct file *file, obd->u.cli.cl_dom_min_inline_repsize = val; return count; } -LPROC_SEQ_FOPS(mdc_dom_min_repsize); +LDEBUGFS_SEQ_FOPS(mdc_dom_min_repsize); -LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags); -LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid); -LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts); -LPROC_SEQ_FOPS_RO_TYPE(mdc, state); +LDEBUGFS_SEQ_FOPS_RO_TYPE(mdc, connect_flags); +LDEBUGFS_SEQ_FOPS_RO_TYPE(mdc, server_uuid); +LDEBUGFS_SEQ_FOPS_RO_TYPE(mdc, timeouts); +LDEBUGFS_SEQ_FOPS_RO_TYPE(mdc, state); -LPROC_SEQ_FOPS_RW_TYPE(mdc, import); -LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov); +LDEBUGFS_SEQ_FOPS_RW_TYPE(mdc, import); +LDEBUGFS_SEQ_FOPS_RW_TYPE(mdc, pinger_recov); -static struct lprocfs_vars lprocfs_mdc_obd_vars[] = { +static struct ldebugfs_vars lprocfs_mdc_obd_vars[] = { { .name = "connect_flags", .fops = &mdc_connect_flags_fops }, { .name = "mds_server_uuid", diff --git a/fs/lustre/mgc/lproc_mgc.c b/fs/lustre/mgc/lproc_mgc.c index 0c716df..c22ec23 100644 --- a/fs/lustre/mgc/lproc_mgc.c +++ b/fs/lustre/mgc/lproc_mgc.c @@ -37,22 +37,22 @@ #include #include "mgc_internal.h" -LPROC_SEQ_FOPS_RO_TYPE(mgc, connect_flags); +LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, connect_flags); -LPROC_SEQ_FOPS_RO_TYPE(mgc, server_uuid); +LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, server_uuid); -LPROC_SEQ_FOPS_RO_TYPE(mgc, import); +LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, import); -LPROC_SEQ_FOPS_RO_TYPE(mgc, state); +LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, state); static int mgc_ir_state_seq_show(struct seq_file *m, void *v) { return lprocfs_mgc_rd_ir_state(m, m->private); } -LPROC_SEQ_FOPS_RO(mgc_ir_state); +LDEBUGFS_SEQ_FOPS_RO(mgc_ir_state); -struct lprocfs_vars lprocfs_mgc_obd_vars[] = { +struct ldebugfs_vars lprocfs_mgc_obd_vars[] = { { .name = "connect_flags", .fops = &mgc_connect_flags_fops }, { .name = "mgs_server_uuid", diff --git a/fs/lustre/obdclass/lprocfs_status.c b/fs/lustre/obdclass/lprocfs_status.c index aba04d5..3d16516 100644 --- a/fs/lustre/obdclass/lprocfs_status.c +++ b/fs/lustre/obdclass/lprocfs_status.c @@ -412,7 +412,7 @@ int sysfs_memparse(const char *buffer, size_t count, u64 *val, static const struct file_operations lprocfs_generic_fops = { }; -void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *list, +void ldebugfs_add_vars(struct dentry *parent, struct ldebugfs_vars *list, void *data) { if (IS_ERR_OR_NULL(parent) || IS_ERR_OR_NULL(list)) @@ -593,7 +593,7 @@ ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf) } EXPORT_SYMBOL(conn_uuid_show); -int lprocfs_rd_server_uuid(struct seq_file *m, void *data) +int ldebugfs_server_uuid_seq_show(struct seq_file *m, void *data) { struct obd_device *obd = data; struct obd_import *imp; @@ -610,7 +610,7 @@ int lprocfs_rd_server_uuid(struct seq_file *m, void *data) return 0; } -EXPORT_SYMBOL(lprocfs_rd_server_uuid); +EXPORT_SYMBOL(ldebugfs_server_uuid_seq_show); /** * Lock statistics structure for access, possibly only on this CPU. @@ -804,7 +804,7 @@ static void obd_connect_seq_flags2str(struct seq_file *m, u64 flags, } } -static void lprocfs_rd_import_locked(struct seq_file *m, +static void ldebugfs_import_locked(struct seq_file *m, struct obd_device *obd, struct obd_import *imp) { @@ -942,7 +942,7 @@ static void lprocfs_rd_import_locked(struct seq_file *m, } } -int lprocfs_rd_import(struct seq_file *m, void *data) +int ldebugfs_import_seq_show(struct seq_file *m, void *data) { struct obd_device *obd = (struct obd_device *)data; struct obd_import *imp; @@ -950,12 +950,12 @@ int lprocfs_rd_import(struct seq_file *m, void *data) LASSERT(obd); with_imp_locked(obd, imp, rc) - lprocfs_rd_import_locked(m, obd, imp); + ldebugfs_import_locked(m, obd, imp); return rc; } -EXPORT_SYMBOL(lprocfs_rd_import); +EXPORT_SYMBOL(ldebugfs_import_seq_show); -int lprocfs_rd_state(struct seq_file *m, void *data) +int ldebugfs_state_seq_show(struct seq_file *m, void *data) { struct obd_device *obd = data; struct obd_import *imp; @@ -980,7 +980,7 @@ int lprocfs_rd_state(struct seq_file *m, void *data) return rc; } -EXPORT_SYMBOL(lprocfs_rd_state); +EXPORT_SYMBOL(ldebugfs_state_seq_show); int lprocfs_at_hist_helper(struct seq_file *m, struct adaptive_timeout *at) { @@ -993,8 +993,8 @@ int lprocfs_at_hist_helper(struct seq_file *m, struct adaptive_timeout *at) } EXPORT_SYMBOL(lprocfs_at_hist_helper); -/* See also ptlrpc_lprocfs_rd_timeouts */ -static void lprocfs_rd_timeouts_locked(struct seq_file *m, +/* See also ptlrpc_ldebugfs_timeouts */ +static void ldebugfs_timeouts_locked(struct seq_file *m, struct obd_device *obd, struct obd_import *imp) { @@ -1037,19 +1037,19 @@ static void lprocfs_rd_timeouts_locked(struct seq_file *m, } } -int lprocfs_rd_timeouts(struct seq_file *m, void *data) +int ldebugfs_timeouts_seq_show(struct seq_file *m, void *data) { struct obd_device *obd = (struct obd_device *)data; struct obd_import *imp; int rc; with_imp_locked(obd, imp, rc) - lprocfs_rd_timeouts_locked(m, obd, imp); + ldebugfs_timeouts_locked(m, obd, imp); return rc; } -EXPORT_SYMBOL(lprocfs_rd_timeouts); +EXPORT_SYMBOL(ldebugfs_timeouts_seq_show); -int lprocfs_rd_connect_flags(struct seq_file *m, void *data) +int ldebugfs_connect_flags_seq_show(struct seq_file *m, void *data) { struct obd_device *obd = data; struct obd_import *imp; @@ -1067,7 +1067,7 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) return rc; } -EXPORT_SYMBOL(lprocfs_rd_connect_flags); +EXPORT_SYMBOL(ldebugfs_connect_flags_seq_show); static const struct attribute *obd_def_uuid_attrs[] = { &lustre_attr_uuid.attr, @@ -1640,8 +1640,10 @@ void lprocfs_oh_clear(struct obd_histogram *oh) } EXPORT_SYMBOL(lprocfs_oh_clear); -int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count, - struct root_squash_info *squash, char *name) +ssize_t ldebugfs_root_squash_seq_write(const char __user *buffer, + unsigned long count, + struct root_squash_info *squash, + char *name) { char kernbuf[64], *tmp, *errmsg; unsigned long uid, gid; @@ -1702,10 +1704,12 @@ int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count, name, errmsg, rc); return rc; } -EXPORT_SYMBOL(lprocfs_wr_root_squash); +EXPORT_SYMBOL(ldebugfs_root_squash_seq_write); -int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, - struct root_squash_info *squash, char *name) +ssize_t ldebugfs_nosquash_nids_seq_write(const char __user *buffer, + unsigned long count, + struct root_squash_info *squash, + char *name) { char *kernbuf = NULL, *errmsg; LIST_HEAD(tmp); @@ -1777,7 +1781,7 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, } return rc; } -EXPORT_SYMBOL(lprocfs_wr_nosquash_nids); +EXPORT_SYMBOL(ldebugfs_nosquash_nids_seq_write); ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) diff --git a/fs/lustre/obdclass/obd_config.c b/fs/lustre/obdclass/obd_config.c index 5495609..09dee7b 100644 --- a/fs/lustre/obdclass/obd_config.c +++ b/fs/lustre/obdclass/obd_config.c @@ -1158,98 +1158,6 @@ ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix, } EXPORT_SYMBOL(class_modify_config); -int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, - struct lustre_cfg *lcfg, void *data) -{ - struct lprocfs_vars *var; - struct file fakefile; - struct seq_file fake_seqfile; - char *key, *sval; - int i, keylen, vallen; - int matched = 0, j = 0; - int rc = 0; - int skip = 0; - - if (lcfg->lcfg_command != LCFG_PARAM) { - CERROR("Unknown command: %d\n", lcfg->lcfg_command); - return -EINVAL; - } - - /* fake a seq file so that var->fops->write can work... */ - fakefile.private_data = &fake_seqfile; - fake_seqfile.private = data; - /* e.g. tunefs.lustre --param mdt.group_upcall=foo /r/tmp/lustre-mdt - * or lctl conf_param lustre-MDT0000.mdt.group_upcall=bar - * or lctl conf_param lustre-OST0000.osc.max_dirty_mb=36 - */ - for (i = 1; i < lcfg->lcfg_bufcount; i++) { - key = lustre_cfg_buf(lcfg, i); - /* Strip off prefix */ - if (class_match_param(key, prefix, &key)) { - /* - * If the prefix doesn't match, return error so we - * can pass it down the stack - */ - return -ENOSYS; - } - sval = strchr(key, '='); - if (!sval || (*(sval + 1) == 0)) { - CERROR("Can't parse param %s (missing '=')\n", key); - /* rc = -EINVAL; continue parsing other params */ - continue; - } - keylen = sval - key; - sval++; - vallen = strlen(sval); - matched = 0; - j = 0; - /* Search proc entries */ - while (lvars[j].name) { - var = &lvars[j]; - if (!class_match_param(key, var->name, NULL) && - keylen == strlen(var->name)) { - matched++; - rc = -EROFS; - if (var->fops && var->fops->write) { - mm_segment_t oldfs; - - oldfs = get_fs(); - set_fs(KERNEL_DS); - rc = var->fops->write(&fakefile, - (const char __user *)sval, - vallen, NULL); - set_fs(oldfs); - } - break; - } - j++; - } - if (!matched) { - CERROR("%.*s: %s unknown param %s\n", - (int)strlen(prefix) - 1, prefix, - (char *)lustre_cfg_string(lcfg, 0), key); - /* rc = -EINVAL; continue parsing other params */ - skip++; - } else if (rc < 0) { - CERROR("%s: error writing parameter '%s': rc = %d\n", - prefix, var->name, rc); - rc = 0; - } else { - CDEBUG(D_CONFIG, "%s.%.*s: set parameter %.*s\n", - lustre_cfg_string(lcfg, 0), - (int)strlen(prefix) - 1, prefix, - (int)(sval - key - 1), key); - } - } - - if (rc > 0) - rc = 0; - if (!rc && skip) - rc = skip; - return rc; -} -EXPORT_SYMBOL(class_process_proc_param); - /** Parse a configuration llog, doing various manipulations on them * for various reasons, (modifications for compatibility, skip obsolete * records, change uuids, etc), then class_process_config() resulting diff --git a/fs/lustre/obdclass/obd_sysfs.c b/fs/lustre/obdclass/obd_sysfs.c index f1fc78d..cb2f0a9 100644 --- a/fs/lustre/obdclass/obd_sysfs.c +++ b/fs/lustre/obdclass/obd_sysfs.c @@ -443,7 +443,7 @@ static int obd_device_list_open(struct inode *inode, struct file *file) return 0; } -LPROC_SEQ_FOPS_RO(health_check); +LDEBUGFS_SEQ_FOPS_RO(health_check); struct kset *lustre_kset; EXPORT_SYMBOL_GPL(lustre_kset); diff --git a/fs/lustre/osc/lproc_osc.c b/fs/lustre/osc/lproc_osc.c index 9b43710..14cbe54 100644 --- a/fs/lustre/osc/lproc_osc.c +++ b/fs/lustre/osc/lproc_osc.c @@ -242,7 +242,7 @@ static ssize_t osc_cached_mb_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_cached_mb); +LDEBUGFS_SEQ_FOPS(osc_cached_mb); static ssize_t cur_dirty_bytes_show(struct kobject *kobj, struct attribute *attr, @@ -447,7 +447,7 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, } return rc; } -LPROC_SEQ_FOPS(osc_checksum_type); +LDEBUGFS_SEQ_FOPS(osc_checksum_type); static ssize_t resend_count_show(struct kobject *kobj, struct attribute *attr, @@ -605,7 +605,7 @@ static int osc_unstable_stats_seq_show(struct seq_file *m, void *v) return 0; } -LPROC_SEQ_FOPS_RO(osc_unstable_stats); +LDEBUGFS_SEQ_FOPS_RO(osc_unstable_stats); static ssize_t idle_timeout_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -729,15 +729,15 @@ static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr, } LUSTRE_RW_ATTR(grant_shrink); -LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); -LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); -LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts); -LPROC_SEQ_FOPS_RO_TYPE(osc, state); +LDEBUGFS_SEQ_FOPS_RO_TYPE(osc, connect_flags); +LDEBUGFS_SEQ_FOPS_RO_TYPE(osc, server_uuid); +LDEBUGFS_SEQ_FOPS_RO_TYPE(osc, timeouts); +LDEBUGFS_SEQ_FOPS_RO_TYPE(osc, state); -LPROC_SEQ_FOPS_RW_TYPE(osc, import); -LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov); +LDEBUGFS_SEQ_FOPS_RW_TYPE(osc, import); +LDEBUGFS_SEQ_FOPS_RW_TYPE(osc, pinger_recov); -static struct lprocfs_vars lprocfs_osc_obd_vars[] = { +static struct ldebugfs_vars lprocfs_osc_obd_vars[] = { { .name = "connect_flags", .fops = &osc_connect_flags_fops }, { .name = "ost_server_uuid", @@ -876,7 +876,7 @@ static ssize_t osc_rpc_stats_seq_write(struct file *file, return len; } -LPROC_SEQ_FOPS(osc_rpc_stats); +LDEBUGFS_SEQ_FOPS(osc_rpc_stats); static int osc_stats_seq_show(struct seq_file *seq, void *v) { @@ -909,7 +909,7 @@ static ssize_t osc_stats_seq_write(struct file *file, return len; } -LPROC_SEQ_FOPS(osc_stats); +LDEBUGFS_SEQ_FOPS(osc_stats); void lproc_osc_attach_seqstat(struct obd_device *obd) { diff --git a/fs/lustre/ptlrpc/lproc_ptlrpc.c b/fs/lustre/ptlrpc/lproc_ptlrpc.c index 86ec1f5..4d2ae14 100644 --- a/fs/lustre/ptlrpc/lproc_ptlrpc.c +++ b/fs/lustre/ptlrpc/lproc_ptlrpc.c @@ -263,7 +263,7 @@ static const char *ll_eopcode2str(u32 opcode) return 0; } -LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_req_history_len); +LDEBUGFS_SEQ_FOPS_RO(ptlrpc_lprocfs_req_history_len); static int ptlrpc_lprocfs_req_history_max_seq_show(struct seq_file *m, void *n) @@ -325,7 +325,7 @@ static const char *ll_eopcode2str(u32 opcode) return count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_history_max); +LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_req_history_max); static int ptlrpc_lprocfs_req_buffers_max_seq_show(struct seq_file *m, void *n) @@ -362,7 +362,7 @@ static const char *ll_eopcode2str(u32 opcode) return count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_buffers_max); +LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_req_buffers_max); static ssize_t threads_min_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -753,7 +753,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, return rc < 0 ? rc : count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs); +LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs); /** @} nrs */ @@ -1050,7 +1050,7 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) return 0; } -LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_timeouts); +LDEBUGFS_SEQ_FOPS_RO(ptlrpc_lprocfs_timeouts); static ssize_t high_priority_ratio_show(struct kobject *kobj, struct attribute *attr, @@ -1133,7 +1133,7 @@ int ptlrpc_sysfs_register_service(struct kset *parent, void ptlrpc_ldebugfs_register_service(struct dentry *entry, struct ptlrpc_service *svc) { - struct lprocfs_vars lproc_vars[] = { + struct ldebugfs_vars lproc_vars[] = { { .name = "req_buffer_history_len", .fops = &ptlrpc_lprocfs_req_history_len_fops, .data = svc }, @@ -1284,8 +1284,9 @@ ssize_t ping_store(struct kobject *kobj, struct attribute *attr, * The connection UUID is a node's primary NID. For example, * "echo connection=192.168.0.1@tcp0::instance > .../import". */ -int lprocfs_wr_import(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +ssize_t +ldebugfs_import_seq_write(struct file *file, const char __user *buffer, + size_t count, loff_t *off) { struct seq_file *m = file->private_data; struct obd_device *obd = m->private; @@ -1352,9 +1353,9 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer, kfree(kbuf); return rc ?: count; } -EXPORT_SYMBOL(lprocfs_wr_import); +EXPORT_SYMBOL(ldebugfs_import_seq_write); -int lprocfs_rd_pinger_recov(struct seq_file *m, void *n) +int ldebugfs_pinger_recov_seq_show(struct seq_file *m, void *n) { struct obd_device *obd = m->private; struct obd_import *imp = obd->u.cli.cl_import; @@ -1365,10 +1366,11 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n) return rc; } -EXPORT_SYMBOL(lprocfs_rd_pinger_recov); +EXPORT_SYMBOL(ldebugfs_pinger_recov_seq_show); -int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +ssize_t +ldebugfs_pinger_recov_seq_write(struct file *file, const char __user *buffer, + size_t count, loff_t *off) { struct seq_file *m = file->private_data; struct obd_device *obd = m->private; @@ -1388,4 +1390,4 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, return rc ?: count; } -EXPORT_SYMBOL(lprocfs_wr_pinger_recov); +EXPORT_SYMBOL(ldebugfs_pinger_recov_seq_write); diff --git a/fs/lustre/ptlrpc/sec_lproc.c b/fs/lustre/ptlrpc/sec_lproc.c index b34ced4..94f77350 100644 --- a/fs/lustre/ptlrpc/sec_lproc.c +++ b/fs/lustre/ptlrpc/sec_lproc.c @@ -104,7 +104,7 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v) return 0; } -LPROC_SEQ_FOPS_RO(sptlrpc_info_lprocfs); +LDEBUGFS_SEQ_FOPS_RO(sptlrpc_info_lprocfs); static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v) { @@ -129,7 +129,7 @@ static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v) return 0; } -LPROC_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs); +LDEBUGFS_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs); #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0) static ssize_t sepol_seq_write_old(struct obd_device *obd, @@ -212,8 +212,8 @@ static ssize_t sepol_seq_write_old(struct obd_device *obd, #endif static ssize_t -lprocfs_wr_sptlrpc_sepol(struct file *file, const char __user *buffer, - size_t count, void *data) +ldebugfs_sptlrpc_sepol_seq_write(struct file *file, const char __user *buffer, + size_t count, void *data) { struct seq_file *seq = file->private_data; struct obd_device *obd = seq->private; @@ -309,7 +309,7 @@ static ssize_t sepol_seq_write_old(struct obd_device *obd, return rc ? rc : count; } -LPROC_SEQ_FOPS_WR_ONLY(srpc, sptlrpc_sepol); +LDEBUGFS_SEQ_FOPS_WR_ONLY(srpc, sptlrpc_sepol); int sptlrpc_lprocfs_cliobd_attach(struct obd_device *obd) { @@ -332,8 +332,9 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *obd) } EXPORT_SYMBOL(sptlrpc_lprocfs_cliobd_attach); -LPROC_SEQ_FOPS_RO(sptlrpc_proc_enc_pool); -static struct lprocfs_vars sptlrpc_lprocfs_vars[] = { +LDEBUGFS_SEQ_FOPS_RO(sptlrpc_proc_enc_pool); + +static struct ldebugfs_vars sptlrpc_lprocfs_vars[] = { { "encrypt_page_pools", &sptlrpc_proc_enc_pool_fops }, { NULL } }; From patchwork Tue Aug 11 12:20:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709171 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48D901392 for ; Tue, 11 Aug 2020 12:20:39 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 31076206C3 for ; Tue, 11 Aug 2020 12:20:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31076206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 5494D2F37AA; Tue, 11 Aug 2020 05:20:31 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id DBB3D21F5A4 for ; Tue, 11 Aug 2020 05:20:24 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 0A5D31005600; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id EFC6F2D1; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:03 -0400 Message-Id: <1597148419-20629-8-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 07/23] lustre: sec: atomicity of encryption context getting/setting X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Sebastien Buisson Encryption layer needs to set an encryption context on files and dirs that are encrypted. This context is stored as an extended attribute, that then needs to be fetched upon metadata ops like lookup, getattr, open, truncate, and layout. With this patch we send encryption context to the MDT along with create RPCs. This closes the insecure window between creation and setting of the encryption context, and saves a setxattr request. This patch also introduces a way to have the MDT return encryption context upon granted lock reply, making the encryption context retrieval atomic, and sparing the client an additional getxattr request. WC-bug-id: https://jira.whamcloud.com/browse/LU-12275 Lustre-commit: 40d91eafe257f ("LU-12275 sec: atomicity of encryption context getting/setting") Signed-off-by: Sebastien Buisson Reviewed-on: https://review.whamcloud.com/38430 Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/include/lustre_crypto.h | 2 + fs/lustre/include/lustre_export.h | 5 ++ fs/lustre/include/lustre_req_layout.h | 3 +- fs/lustre/include/obd.h | 4 ++ fs/lustre/llite/crypto.c | 75 ++++++++++++++++-------- fs/lustre/llite/dir.c | 16 +++-- fs/lustre/llite/llite_internal.h | 5 ++ fs/lustre/llite/llite_lib.c | 1 + fs/lustre/llite/namei.c | 104 ++++++++++++++++++++++++++++----- fs/lustre/llite/xattr_cache.c | 34 +++++++++++ fs/lustre/mdc/mdc_internal.h | 2 + fs/lustre/mdc/mdc_lib.c | 23 ++++++++ fs/lustre/mdc/mdc_locks.c | 22 +++++++ fs/lustre/mdc/mdc_reint.c | 3 + fs/lustre/mdc/mdc_request.c | 4 +- fs/lustre/ptlrpc/layout.c | 25 +++++--- fs/lustre/ptlrpc/wiretest.c | 2 + include/uapi/linux/lustre/lustre_idl.h | 3 +- 18 files changed, 279 insertions(+), 54 deletions(-) diff --git a/fs/lustre/include/lustre_crypto.h b/fs/lustre/include/lustre_crypto.h index e9091a2..b80147f 100644 --- a/fs/lustre/include/lustre_crypto.h +++ b/fs/lustre/include/lustre_crypto.h @@ -31,6 +31,8 @@ #define _LUSTRE_CRYPTO_H_ struct ll_sb_info; +int ll_set_encflags(struct inode *inode, void *encctx, u32 encctxlen, + bool preload); bool ll_sbi_has_test_dummy_encryption(struct ll_sb_info *sbi); bool ll_sbi_has_encrypt(struct ll_sb_info *sbi); void ll_sbi_set_encrypt(struct ll_sb_info *sbi, bool set); diff --git a/fs/lustre/include/lustre_export.h b/fs/lustre/include/lustre_export.h index b77605b..b5fdf8a 100644 --- a/fs/lustre/include/lustre_export.h +++ b/fs/lustre/include/lustre_export.h @@ -280,6 +280,11 @@ static inline int exp_connect_archive_id_array(struct obd_export *exp) return !!(exp_connect_flags2(exp) & OBD_CONNECT2_ARCHIVE_ID_ARRAY); } +static inline int exp_connect_encrypt(struct obd_export *exp) +{ + return !!(exp_connect_flags2(exp) & OBD_CONNECT2_ENCRYPT); +} + enum { /* archive_ids in array format */ KKUC_CT_DATA_ARRAY_MAGIC = 0x092013cea, diff --git a/fs/lustre/include/lustre_req_layout.h b/fs/lustre/include/lustre_req_layout.h index 72d9df0..54041b0 100644 --- a/fs/lustre/include/lustre_req_layout.h +++ b/fs/lustre/include/lustre_req_layout.h @@ -60,7 +60,7 @@ enum req_location { }; /* Maximal number of fields (buffers) in a request message. */ -#define REQ_MAX_FIELD_NR 11 +#define REQ_MAX_FIELD_NR 12 struct req_capsule { struct ptlrpc_request *rc_req; @@ -243,6 +243,7 @@ void req_capsule_shrink(struct req_capsule *pill, extern struct req_msg_field RMF_FILE_SECCTX_NAME; extern struct req_msg_field RMF_FILE_SECCTX; extern struct req_msg_field RMF_FID_ARRAY; +extern struct req_msg_field RMF_FILE_ENCCTX; /* * connection handle received in MDS_CONNECT request. diff --git a/fs/lustre/include/obd.h b/fs/lustre/include/obd.h index 849483f..cd3abfd 100644 --- a/fs/lustre/include/obd.h +++ b/fs/lustre/include/obd.h @@ -784,6 +784,10 @@ struct md_op_data { void *op_file_secctx; u32 op_file_secctx_size; + /* File encryption context, for creates/metadata ops */ + void *op_file_encctx; + u32 op_file_encctx_size; + u32 op_projid; u16 op_mirror_id; diff --git a/fs/lustre/llite/crypto.c b/fs/lustre/llite/crypto.c index 157017f..83ed316 100644 --- a/fs/lustre/llite/crypto.c +++ b/fs/lustre/llite/crypto.c @@ -49,50 +49,75 @@ static int ll_get_context(struct inode *inode, void *ctx, size_t len) return rc; } +int ll_set_encflags(struct inode *inode, void *encctx, u32 encctxlen, + bool preload) +{ + unsigned int ext_flags; + int rc = 0; + + /* used as encryption unit size */ + if (S_ISREG(inode->i_mode)) + inode->i_blkbits = LUSTRE_ENCRYPTION_BLOCKBITS; + ext_flags = ll_inode_to_ext_flags(inode->i_flags) | LUSTRE_ENCRYPT_FL; + ll_update_inode_flags(inode, ext_flags); + + if (encctx && encctxlen) + rc = ll_xattr_cache_insert(inode, + LL_XATTR_NAME_ENCRYPTION_CONTEXT, + encctx, encctxlen); + if (rc) + return rc; + + return preload ? llcrypt_get_encryption_info(inode) : 0; +} + +/* ll_set_context has 2 distinct behaviors, depending on the value of inode + * parameter: + * - inode is NULL: + * passed fs_data is a struct md_op_data *. We need to store enc ctx in + * op_data, so that it will be sent along to the server with the request that + * the caller is preparing, thus saving a setxattr request. + * - inode is not NULL: + * normal case in which passed fs_data is a struct dentry *, letting proceed + * with setxattr operation. + * This use case should only be used when explicitly setting a new encryption + * policy on an existing, empty directory. + */ static int ll_set_context(struct inode *inode, const void *ctx, size_t len, void *fs_data) { - unsigned int ext_flags; struct dentry *dentry; - struct md_op_data *op_data; - struct ptlrpc_request *req = NULL; int rc; - if (!inode) - return 0; + if (!inode) { + struct md_op_data *op_data = (struct md_op_data *)fs_data; - ext_flags = ll_inode_to_ext_flags(inode->i_flags) | LUSTRE_ENCRYPT_FL; - dentry = (struct dentry *)fs_data; + if (!op_data) + return -EINVAL; + + op_data->op_file_encctx = kzalloc(len, GFP_KERNEL); + if (!op_data->op_file_encctx) + return -ENOMEM; + op_data->op_file_encctx_size = len; + memcpy(op_data->op_file_encctx, ctx, len); + return 0; + } /* Encrypting the root directory is not allowed */ if (inode->i_ino == inode->i_sb->s_root->d_inode->i_ino) return -EPERM; - op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, - LUSTRE_OPC_ANY, NULL); - if (IS_ERR(op_data)) - return PTR_ERR(op_data); - - op_data->op_attr_flags = LUSTRE_ENCRYPT_FL; - op_data->op_xvalid |= OP_XVALID_FLAGS; - rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL, 0, &req); - ll_finish_md_op_data(op_data); - ptlrpc_req_finished(req); - if (rc) - return rc; - + dentry = (struct dentry *)fs_data; rc = __vfs_setxattr(dentry, inode, LL_XATTR_NAME_ENCRYPTION_CONTEXT, ctx, len, XATTR_CREATE); if (rc) return rc; - /* used as encryption unit size */ - if (S_ISREG(inode->i_mode)) - inode->i_blkbits = LUSTRE_ENCRYPTION_BLOCKBITS; - ll_update_inode_flags(inode, ext_flags); - return 0; + return ll_set_encflags(inode, (void *)ctx, len, false); } +#define llcrypto_free_ctx kfree + inline bool ll_sbi_has_test_dummy_encryption(struct ll_sb_info *sbi) { return unlikely(sbi->ll_flags & LL_SBI_TEST_DUMMY_ENCRYPTION); diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c index e3305f7..c2a75ce 100644 --- a/fs/lustre/llite/dir.c +++ b/fs/lustre/llite/dir.c @@ -448,8 +448,9 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump, if (IS_ERR(op_data)) return PTR_ERR(op_data); - if (IS_ENCRYPTED(parent) || - unlikely(llcrypt_dummy_context_enabled(parent))) { + if (ll_sbi_has_encrypt(sbi) && + (IS_ENCRYPTED(parent) || + unlikely(llcrypt_dummy_context_enabled(parent)))) { err = llcrypt_get_encryption_info(parent); if (err) goto out_op_data; @@ -474,6 +475,13 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump, goto out_op_data; } + if (encrypt) { + err = llcrypt_inherit_context(parent, NULL, op_data, false); + if (err) + 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()), @@ -501,8 +509,8 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump, } if (encrypt) - err = llcrypt_inherit_context(parent, inode, NULL, false); - + err = ll_set_encflags(inode, op_data->op_file_encctx, + op_data->op_file_encctx_size, false); out_inode: iput(inode); out_request: diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h index 31c528f..89783fb 100644 --- a/fs/lustre/llite/llite_internal.h +++ b/fs/lustre/llite/llite_internal.h @@ -402,6 +402,11 @@ static inline void ll_layout_version_set(struct ll_inode_info *lli, u32 gen) int ll_xattr_cache_get(struct inode *inode, const char *name, char *buffer, size_t size, u64 valid); +int ll_xattr_cache_insert(struct inode *inode, + const char *name, + char *buffer, + size_t size); + static inline bool obd_connect_has_secctx(struct obd_connect_data *data) { #ifdef CONFIG_SECURITY diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c index f52d2b5..4773fc1 100644 --- a/fs/lustre/llite/llite_lib.c +++ b/fs/lustre/llite/llite_lib.c @@ -2873,6 +2873,7 @@ void ll_finish_md_op_data(struct md_op_data *op_data) ll_unlock_md_op_lsm(op_data); security_release_secctx(op_data->op_file_secctx, op_data->op_file_secctx_size); + kfree(op_data->op_file_encctx); kfree(op_data); } diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c index 251d6be..3fbcbbd 100644 --- a/fs/lustre/llite/namei.c +++ b/fs/lustre/llite/namei.c @@ -48,7 +48,8 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, struct lookup_intent *it, - void *secctx, u32 secctxlen, bool encrypt); + void *secctx, u32 secctxlen, bool encrypt, + void *encctx, __u32 encctxlen); /* called from iget5_locked->find_inode() under inode_hash_lock spinlock */ static int ll_test_inode(struct inode *inode, void *opaque) @@ -606,6 +607,7 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, struct lookup_intent *it, struct inode *parent, struct dentry **de, void *secctx, u32 secctxlen, + void *encctx, u32 encctxlen, ktime_t kstart, bool encrypt) { struct inode *inode = NULL; @@ -666,8 +668,33 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, rc = security_inode_notifysecctx(inode, secctx, secctxlen); if (rc) - CWARN("cannot set security context for " DFID ": rc = %d\n", - PFID(ll_inode2fid(inode)), rc); + CWARN("%s: cannot set security context for " DFID ": rc = %d\n", + ll_i2sbi(inode)->ll_fsname, + PFID(ll_inode2fid(inode)), + rc); + } + + /* If encryption context was returned by MDT, put it in + * inode now to save an extra getxattr and avoid deadlock. + */ + if (body->mbo_valid & OBD_MD_ENCCTX) { + encctx = req_capsule_server_get(pill, &RMF_FILE_ENCCTX); + encctxlen = req_capsule_get_size(pill, + &RMF_FILE_ENCCTX, + RCL_SERVER); + + if (encctxlen) { + CDEBUG(D_SEC, + "server returned encryption ctx for " DFID "\n", + PFID(ll_inode2fid(inode))); + rc = ll_xattr_cache_insert(inode, + LL_XATTR_NAME_ENCRYPTION_CONTEXT, + encctx, encctxlen); + if (rc) + CWARN("%s: cannot set enc ctx for " DFID ": rc = %d\n", + ll_i2sbi(inode)->ll_fsname, + PFID(ll_inode2fid(inode)), rc); + } } } @@ -739,7 +766,8 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, struct lookup_intent *it, void **secctx, u32 *secctxlen, struct pcc_create_attach *pca, - bool encrypt) + bool encrypt, + void **encctx, u32 *encctxlen) { ktime_t kstart = ktime_get(); struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; @@ -816,6 +844,22 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, if (secctxlen) *secctxlen = 0; } + if (it->it_op & IT_CREAT && encrypt) { + rc = llcrypt_inherit_context(parent, NULL, op_data, false); + if (rc) { + retval = ERR_PTR(rc); + goto out; + } + if (encctx) + *encctx = op_data->op_file_encctx; + if (encctxlen) + *encctxlen = op_data->op_file_encctx_size; + } else { + if (encctx) + *encctx = NULL; + if (encctxlen) + *encctxlen = 0; + } /* ask for security context upon intent */ if (it->it_op & (IT_LOOKUP | IT_GETATTR | IT_OPEN)) { @@ -908,6 +952,8 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, rc = ll_lookup_it_finish(req, it, parent, &dentry, secctx ? *secctx : NULL, secctxlen ? *secctxlen : 0, + encctx ? *encctx : NULL, + encctxlen ? *encctxlen : 0, kstart, encrypt); if (rc != 0) { ll_intent_release(it); @@ -936,6 +982,14 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, op_data->op_file_secctx = NULL; op_data->op_file_secctx_size = 0; } + if (encctx && encctxlen && + it->it_op & IT_CREAT && encrypt) { + /* caller needs enc ctx info, so reset it in op_data to + * prevent it from being freed + */ + op_data->op_file_encctx = NULL; + op_data->op_file_encctx_size = 0; + } ll_finish_md_op_data(op_data); } @@ -966,7 +1020,8 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry, itp = NULL; else itp = ⁢ - de = ll_lookup_it(parent, dentry, itp, NULL, NULL, NULL, false); + de = ll_lookup_it(parent, dentry, itp, NULL, NULL, NULL, false, + NULL, NULL); if (itp) ll_intent_release(itp); @@ -985,6 +1040,8 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, struct lookup_intent *it; void *secctx = NULL; u32 secctxlen = 0; + void *encctx = NULL; + u32 encctxlen = 0; struct dentry *de; struct ll_sb_info *sbi = NULL; struct pcc_create_attach pca = { NULL, NULL }; @@ -1040,7 +1097,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, it->it_flags = (open_flags & ~O_ACCMODE) | OPEN_FMODE(open_flags); it->it_flags &= ~MDS_OPEN_FL_INTERNAL; - if (IS_ENCRYPTED(dir)) { + if (ll_sbi_has_encrypt(ll_i2sbi(dir)) && IS_ENCRYPTED(dir)) { /* we know that we are going to create a regular file because * we set S_IFREG bit on it->it_create_mode above */ @@ -1056,7 +1113,8 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, } /* Dentry added to dcache tree in ll_lookup_it */ - de = ll_lookup_it(dir, dentry, it, &secctx, &secctxlen, &pca, encrypt); + de = ll_lookup_it(dir, dentry, it, &secctx, &secctxlen, &pca, encrypt, + &encctx, &encctxlen); if (IS_ERR(de)) rc = PTR_ERR(de); else if (de) @@ -1066,8 +1124,9 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, if (it_disposition(it, DISP_OPEN_CREATE)) { /* Dentry instantiated in ll_create_it. */ rc = ll_create_it(dir, dentry, it, secctx, secctxlen, - encrypt); + encrypt, encctx, encctxlen); security_release_secctx(secctx, secctxlen); + kfree(encctx); if (rc) { /* We dget in ll_splice_alias. */ if (de) @@ -1098,6 +1157,15 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, * already created PCC copy. */ pcc_create_attach_cleanup(dir->i_sb, &pca); + + if (open_flags & O_CREAT && encrypt && + dentry->d_inode) { + rc = ll_set_encflags(dentry->d_inode, encctx, + encctxlen, true); + kfree(encctx); + if (rc) + goto out_release; + } } if (d_really_is_positive(dentry) && @@ -1182,7 +1250,8 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it) */ static int ll_create_it(struct inode *dir, struct dentry *dentry, struct lookup_intent *it, - void *secctx, u32 secctxlen, bool encrypt) + void *secctx, u32 secctxlen, bool encrypt, + void *encctx, __u32 encctxlen) { struct inode *inode; u64 bits = 0; @@ -1220,7 +1289,7 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, d_instantiate(dentry, inode); if (encrypt) { - rc = llcrypt_inherit_context(dir, inode, dentry, true); + rc = ll_set_encflags(inode, encctx, encctxlen, true); if (rc) return rc; } @@ -1258,7 +1327,7 @@ static int ll_new_node(struct inode *dir, struct dentry *dentry, struct inode *inode = NULL; struct ll_sb_info *sbi = ll_i2sbi(dir); int tgt_len = 0; - int encrypt = 0; + bool encrypt = false; int err; if (unlikely(tgt)) @@ -1282,9 +1351,10 @@ static int ll_new_node(struct inode *dir, struct dentry *dentry, goto err_exit; } - if ((IS_ENCRYPTED(dir) && + if (ll_sbi_has_encrypt(sbi) && + ((IS_ENCRYPTED(dir) && (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))) || - (unlikely(llcrypt_dummy_context_enabled(dir)) && S_ISDIR(mode))) { + (unlikely(llcrypt_dummy_context_enabled(dir)) && S_ISDIR(mode)))) { err = llcrypt_get_encryption_info(dir); if (err) goto err_exit; @@ -1292,7 +1362,13 @@ static int ll_new_node(struct inode *dir, struct dentry *dentry, err = -ENOKEY; goto err_exit; } - encrypt = 1; + encrypt = true; + } + + if (encrypt) { + err = llcrypt_inherit_context(dir, NULL, op_data, false); + if (err) + goto err_exit; } err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode, diff --git a/fs/lustre/llite/xattr_cache.c b/fs/lustre/llite/xattr_cache.c index c642444..fee1cf5 100644 --- a/fs/lustre/llite/xattr_cache.c +++ b/fs/lustre/llite/xattr_cache.c @@ -502,3 +502,37 @@ int ll_xattr_cache_get(struct inode *inode, const char *name, char *buffer, return rc; } + +/** + * Insert an xattr value into the cache. + * + * Add @name xattr with @buffer value and @size length for @inode. + * Init cache for @inode if necessary. + * + * Return: 0 success + * < 0 from ll_xattr_cache_add(), except -EPROTO is ignored for + * LL_XATTR_NAME_ENCRYPTION_CONTEXT xattr + */ +int ll_xattr_cache_insert(struct inode *inode, + const char *name, + char *buffer, + size_t size) +{ + struct ll_inode_info *lli = ll_i2info(inode); + int rc; + + down_read(&lli->lli_xattrs_list_rwsem); + if (!ll_xattr_cache_valid(lli)) + ll_xattr_cache_init(lli); + rc = ll_xattr_cache_add(&lli->lli_xattrs, name, buffer, + size); + up_read(&lli->lli_xattrs_list_rwsem); + + if (rc == -EPROTO && + strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT) == 0) + /* it means enc ctx was already in cache, + * ignore error as it cannot be modified + */ + rc = 0; + return rc; +} diff --git a/fs/lustre/mdc/mdc_internal.h b/fs/lustre/mdc/mdc_internal.h index a1fb5d9..065cba5 100644 --- a/fs/lustre/mdc/mdc_internal.h +++ b/fs/lustre/mdc/mdc_internal.h @@ -57,6 +57,8 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data, void mdc_file_secctx_pack(struct ptlrpc_request *req, const char *secctx_name, const void *secctx, size_t secctx_size); +void mdc_file_encctx_pack(struct ptlrpc_request *req, + const void *encctx, size_t encctx_size); void mdc_file_sepol_pack(struct ptlrpc_request *req); void mdc_unlink_pack(struct ptlrpc_request *req, struct md_op_data *op_data); diff --git a/fs/lustre/mdc/mdc_lib.c b/fs/lustre/mdc/mdc_lib.c index be77944b..6cb14c1 100644 --- a/fs/lustre/mdc/mdc_lib.c +++ b/fs/lustre/mdc/mdc_lib.c @@ -138,6 +138,23 @@ void mdc_file_secctx_pack(struct ptlrpc_request *req, const char *secctx_name, memcpy(buf, secctx, buf_size); } +void mdc_file_encctx_pack(struct ptlrpc_request *req, + const void *encctx, size_t encctx_size) +{ + void *buf; + size_t buf_size; + + if (!encctx) + return; + + buf = req_capsule_client_get(&req->rq_pill, &RMF_FILE_ENCCTX); + buf_size = req_capsule_get_size(&req->rq_pill, &RMF_FILE_ENCCTX, + RCL_CLIENT); + + LASSERT(buf_size == encctx_size); + memcpy(buf, encctx, buf_size); +} + void mdc_file_sepol_pack(struct ptlrpc_request *req) { void *buf; @@ -209,6 +226,9 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data, op_data->op_file_secctx, op_data->op_file_secctx_size); + mdc_file_encctx_pack(req, op_data->op_file_encctx, + op_data->op_file_encctx_size); + /* pack SELinux policy info if any */ mdc_file_sepol_pack(req); } @@ -286,6 +306,9 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data, op_data->op_file_secctx, op_data->op_file_secctx_size); + mdc_file_encctx_pack(req, op_data->op_file_encctx, + op_data->op_file_encctx_size); + /* pack SELinux policy info if any */ mdc_file_sepol_pack(req); } diff --git a/fs/lustre/mdc/mdc_locks.c b/fs/lustre/mdc/mdc_locks.c index 402e6e0..ea78415 100644 --- a/fs/lustre/mdc/mdc_locks.c +++ b/fs/lustre/mdc/mdc_locks.c @@ -324,6 +324,9 @@ static int mdc_save_lovea(struct ptlrpc_request *req, req_capsule_set_size(&req->rq_pill, &RMF_FILE_SECCTX, RCL_CLIENT, op_data->op_file_secctx_size); + req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX, RCL_CLIENT, + op_data->op_file_encctx_size); + /* get SELinux policy info if any */ rc = sptlrpc_get_sepol(req); if (rc < 0) { @@ -380,6 +383,15 @@ static int mdc_save_lovea(struct ptlrpc_request *req, RCL_SERVER, 0); } + if (exp_connect_encrypt(exp) && !(it->it_op & IT_CREAT) && + it->it_op & IT_OPEN) + req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX, + RCL_SERVER, + obd->u.cli.cl_max_mds_easize); + else + req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX, + RCL_SERVER, 0); + /** * Inline buffer for possible data from Data-on-MDT files. */ @@ -459,6 +471,9 @@ static int mdc_save_lovea(struct ptlrpc_request *req, /* pack the intent */ lit = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT); lit->opc = IT_GETXATTR; + /* Message below is checked in sanity-selinux test_20d + * and sanity-sec test_49 + */ CDEBUG(D_INFO, "%s: get xattrs for " DFID "\n", exp->exp_obd->obd_name, PFID(&op_data->op_fid1)); @@ -571,6 +586,13 @@ static int mdc_save_lovea(struct ptlrpc_request *req, RCL_SERVER, 0); } + if (exp_connect_encrypt(exp) && it->it_op & (IT_LOOKUP | IT_GETATTR)) + req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX, + RCL_SERVER, easize); + else + req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX, + RCL_SERVER, 0); + ptlrpc_request_set_replen(req); return req; } diff --git a/fs/lustre/mdc/mdc_reint.c b/fs/lustre/mdc/mdc_reint.c index cc09374..9e566e7 100644 --- a/fs/lustre/mdc/mdc_reint.c +++ b/fs/lustre/mdc/mdc_reint.c @@ -205,6 +205,9 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, req_capsule_set_size(&req->rq_pill, &RMF_FILE_SECCTX, RCL_CLIENT, op_data->op_file_secctx_size); + req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX, RCL_CLIENT, + op_data->op_file_encctx_size); + /* get SELinux policy info if any */ rc = sptlrpc_get_sepol(req); if (rc < 0) { diff --git a/fs/lustre/mdc/mdc_request.c b/fs/lustre/mdc/mdc_request.c index f2bca8e..40670cb 100644 --- a/fs/lustre/mdc/mdc_request.c +++ b/fs/lustre/mdc/mdc_request.c @@ -452,7 +452,9 @@ static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid, LASSERT(obd_md_valid == OBD_MD_FLXATTR || obd_md_valid == OBD_MD_FLXATTRLS); - /* The below message is checked in sanity-selinux.sh test_20d */ + /* Message below is checked in sanity-selinux test_20d + * and sanity-sec test_49 + */ CDEBUG(D_INFO, "%s: get xattr '%s' for " DFID "\n", exp->exp_obd->obd_name, name, PFID(fid)); rc = mdc_xattr_common(exp, &RQF_MDS_GETXATTR, fid, MDS_GETXATTR, diff --git a/fs/lustre/ptlrpc/layout.c b/fs/lustre/ptlrpc/layout.c index 1286547..4e37bbb 100644 --- a/fs/lustre/ptlrpc/layout.c +++ b/fs/lustre/ptlrpc/layout.c @@ -189,7 +189,8 @@ &RMF_DLM_REQ, &RMF_FILE_SECCTX_NAME, &RMF_FILE_SECCTX, - &RMF_SELINUX_POL + &RMF_SELINUX_POL, + &RMF_FILE_ENCCTX, }; static const struct req_msg_field *mds_reint_create_sym_client[] = { @@ -201,7 +202,8 @@ &RMF_DLM_REQ, &RMF_FILE_SECCTX_NAME, &RMF_FILE_SECCTX, - &RMF_SELINUX_POL + &RMF_SELINUX_POL, + &RMF_FILE_ENCCTX, }; static const struct req_msg_field *mds_reint_open_client[] = { @@ -213,7 +215,8 @@ &RMF_EADATA, &RMF_FILE_SECCTX_NAME, &RMF_FILE_SECCTX, - &RMF_SELINUX_POL + &RMF_SELINUX_POL, + &RMF_FILE_ENCCTX, }; static const struct req_msg_field *mds_reint_open_server[] = { @@ -443,7 +446,8 @@ &RMF_CAPA1, &RMF_CAPA2, &RMF_NIOBUF_INLINE, - &RMF_FILE_SECCTX + &RMF_FILE_SECCTX, + &RMF_FILE_ENCCTX, }; static const struct req_msg_field *ldlm_intent_getattr_client[] = { @@ -464,7 +468,8 @@ &RMF_ACL, &RMF_CAPA1, &RMF_FILE_SECCTX, - &RMF_DEFAULT_MDT_MD + &RMF_DEFAULT_MDT_MD, + &RMF_FILE_ENCCTX, }; static const struct req_msg_field *ldlm_intent_create_client[] = { @@ -477,7 +482,8 @@ &RMF_EADATA, &RMF_FILE_SECCTX_NAME, &RMF_FILE_SECCTX, - &RMF_SELINUX_POL + &RMF_SELINUX_POL, + &RMF_FILE_ENCCTX, }; static const struct req_msg_field *ldlm_intent_open_client[] = { @@ -491,7 +497,8 @@ &RMF_EADATA, &RMF_FILE_SECCTX_NAME, &RMF_FILE_SECCTX, - &RMF_SELINUX_POL + &RMF_SELINUX_POL, + &RMF_FILE_ENCCTX, }; static const struct req_msg_field *ldlm_intent_getxattr_client[] = { @@ -987,6 +994,10 @@ struct req_msg_field RMF_FILE_SECCTX = DEFINE_MSGF("file_secctx", RMF_F_NO_SIZE_CHECK, -1, NULL, NULL); EXPORT_SYMBOL(RMF_FILE_SECCTX); +struct req_msg_field RMF_FILE_ENCCTX = + DEFINE_MSGF("file_encctx", RMF_F_NO_SIZE_CHECK, -1, NULL, NULL); +EXPORT_SYMBOL(RMF_FILE_ENCCTX); + struct req_msg_field RMF_LLOGD_BODY = DEFINE_MSGF("llogd_body", 0, sizeof(struct llogd_body), lustre_swab_llogd_body, NULL); diff --git a/fs/lustre/ptlrpc/wiretest.c b/fs/lustre/ptlrpc/wiretest.c index 74a4e940..d1dff09 100644 --- a/fs/lustre/ptlrpc/wiretest.c +++ b/fs/lustre/ptlrpc/wiretest.c @@ -1497,6 +1497,8 @@ void lustre_assert_wire_constants(void) OBD_MD_FLLAZYSIZE); LASSERTF(OBD_MD_FLLAZYBLOCKS == (0x0800000000000000ULL), "found 0x%.16llxULL\n", OBD_MD_FLLAZYBLOCKS); + LASSERTF(OBD_MD_ENCCTX == (0x2000000000000000ULL), "found 0x%.16llxULL\n", + OBD_MD_ENCCTX); BUILD_BUG_ON(OBD_FL_INLINEDATA != 0x00000001); BUILD_BUG_ON(OBD_FL_OBDMDEXISTS != 0x00000002); BUILD_BUG_ON(OBD_FL_DELORPHAN != 0x00000004); diff --git a/include/uapi/linux/lustre/lustre_idl.h b/include/uapi/linux/lustre/lustre_idl.h index d4df989..fdeb2a3 100644 --- a/include/uapi/linux/lustre/lustre_idl.h +++ b/include/uapi/linux/lustre/lustre_idl.h @@ -1229,11 +1229,10 @@ static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic) #define OBD_MD_FLOSTLAYOUT (0x0080000000000000ULL) /* contain ost_layout */ #define OBD_MD_FLPROJID (0x0100000000000000ULL) /* project ID */ #define OBD_MD_SECCTX (0x0200000000000000ULL) /* embed security xattr */ - #define OBD_MD_FLLAZYSIZE (0x0400000000000000ULL) /* Lazy size */ #define OBD_MD_FLLAZYBLOCKS (0x0800000000000000ULL) /* Lazy blocks */ - #define OBD_MD_FLBTIME (0x1000000000000000ULL) /* birth time */ +#define OBD_MD_ENCCTX (0x2000000000000000ULL) /* embed encryption ctx */ #define OBD_MD_FLALLQUOTA (OBD_MD_FLUSRQUOTA | \ OBD_MD_FLGRPQUOTA | \ From patchwork Tue Aug 11 12:20:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709191 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 379E61392 for ; Tue, 11 Aug 2020 12:21:15 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FE362075D for ; Tue, 11 Aug 2020 12:21:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FE362075D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 24E8C2F3876; Tue, 11 Aug 2020 05:20:48 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 3EC0F21F5A4 for ; Tue, 11 Aug 2020 05:20:25 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 0BA5A100561B; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id F28932D2; Tue, 11 Aug 2020 08:20:20 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:04 -0400 Message-Id: <1597148419-20629-9-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 08/23] lustre: sec: encryption support for DoM files X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Sebastien Buisson On client side, data read from DoM files do not go through the OSC layer. So implement file decryption in ll_dom_finish_open() right after file data has been put in cache pages. On server side, DoM file size needs to be properly set on MDT when content is encrypted. Pages are full of encrypted data, but inode size must be apparent, clear text object size. For reads of DoM encrypted files to work proprely, we also need to make sure we send whole encryption units to client side. Also add sanity-sec test_50 to exercise encryption of DoM files. WC-bug-id: https://jira.whamcloud.com/browse/LU-12275 Lustre-commit: a71586d4ee8d6 ("LU-12275 sec: encryption support for DoM files") Signed-off-by: Sebastien Buisson Reviewed-on: https://review.whamcloud.com/38702 Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/crypto.c | 10 +++------- fs/lustre/llite/file.c | 20 +++++++++++++++++-- fs/lustre/llite/namei.c | 52 ++++++++++++++++++++++++++++-------------------- 3 files changed, 51 insertions(+), 31 deletions(-) diff --git a/fs/lustre/llite/crypto.c b/fs/lustre/llite/crypto.c index 83ed316..d37f0a9 100644 --- a/fs/lustre/llite/crypto.c +++ b/fs/lustre/llite/crypto.c @@ -31,17 +31,13 @@ static int ll_get_context(struct inode *inode, void *ctx, size_t len) { - struct dentry *dentry; + struct dentry *dentry = d_find_any_alias(inode); int rc; - if (hlist_empty(&inode->i_dentry)) - return -ENODATA; - - hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) - break; - rc = __vfs_getxattr(dentry, inode, LL_XATTR_NAME_ENCRYPTION_CONTEXT, ctx, len); + if (dentry) + dput(dentry); /* used as encryption unit size */ if (S_ISREG(inode->i_mode)) diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c index 757950f..7d00728 100644 --- a/fs/lustre/llite/file.c +++ b/fs/lustre/llite/file.c @@ -429,8 +429,10 @@ int ll_file_release(struct inode *inode, struct file *file) static inline int ll_dom_readpage(void *data, struct page *page) { + struct inode *inode = page2inode(page); struct niobuf_local *lnb = data; void *kaddr; + int rc = 0; kaddr = kmap_atomic(page); memcpy(kaddr, lnb->lnb_data, lnb->lnb_len); @@ -440,9 +442,22 @@ static inline int ll_dom_readpage(void *data, struct page *page) flush_dcache_page(page); SetPageUptodate(page); kunmap_atomic(kaddr); + + if (inode && IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode)) { + 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); + } unlock_page(page); - return 0; + return rc; } void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req, @@ -481,7 +496,8 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req, * buffer, in both cases total size should be equal to the file size. */ body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - if (rnb->rnb_offset + rnb->rnb_len != body->mbo_dom_size) { + if (rnb->rnb_offset + rnb->rnb_len != body->mbo_dom_size && + !(inode && IS_ENCRYPTED(inode))) { CERROR("%s: server returns off/len %llu/%u but size %llu\n", ll_i2sbi(inode)->ll_fsname, rnb->rnb_offset, rnb->rnb_len, body->mbo_dom_size); diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c index 3fbcbbd..a268c93 100644 --- a/fs/lustre/llite/namei.c +++ b/fs/lustre/llite/namei.c @@ -629,6 +629,36 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, if (rc) return rc; + /* If encryption context was returned by MDT, put it in + * inode now to save an extra getxattr and avoid deadlock. + */ + if (body->mbo_valid & OBD_MD_ENCCTX) { + encctx = req_capsule_server_get(pill, &RMF_FILE_ENCCTX); + encctxlen = req_capsule_get_size(pill, + &RMF_FILE_ENCCTX, + RCL_SERVER); + + if (encctxlen) { + CDEBUG(D_SEC, + "server returned encryption ctx for " DFID "\n", + PFID(ll_inode2fid(inode))); + rc = ll_xattr_cache_insert(inode, + LL_XATTR_NAME_ENCRYPTION_CONTEXT, + encctx, encctxlen); + if (rc) { + CWARN("%s: cannot set enc ctx for " DFID ": rc = %d\n", + ll_i2sbi(inode)->ll_fsname, + PFID(ll_inode2fid(inode)), rc); + } else if (encrypt) { + rc = llcrypt_get_encryption_info(inode); + if (rc) + CDEBUG(D_SEC, + "cannot get enc info for " DFID ": rc = %d\n", + PFID(ll_inode2fid(inode)), rc); + } + } + } + if (it->it_op & IT_OPEN) ll_dom_finish_open(inode, request, it); @@ -674,28 +704,6 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, rc); } - /* If encryption context was returned by MDT, put it in - * inode now to save an extra getxattr and avoid deadlock. - */ - if (body->mbo_valid & OBD_MD_ENCCTX) { - encctx = req_capsule_server_get(pill, &RMF_FILE_ENCCTX); - encctxlen = req_capsule_get_size(pill, - &RMF_FILE_ENCCTX, - RCL_SERVER); - - if (encctxlen) { - CDEBUG(D_SEC, - "server returned encryption ctx for " DFID "\n", - PFID(ll_inode2fid(inode))); - rc = ll_xattr_cache_insert(inode, - LL_XATTR_NAME_ENCRYPTION_CONTEXT, - encctx, encctxlen); - if (rc) - CWARN("%s: cannot set enc ctx for " DFID ": rc = %d\n", - ll_i2sbi(inode)->ll_fsname, - PFID(ll_inode2fid(inode)), rc); - } - } } alias = ll_splice_alias(inode, *de); From patchwork Tue Aug 11 12:20:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709175 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2252016B1 for ; Tue, 11 Aug 2020 12:20:47 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0ABAF206C3 for ; Tue, 11 Aug 2020 12:20:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0ABAF206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id E47382F37DF; Tue, 11 Aug 2020 05:20:34 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 956C921F5A4 for ; Tue, 11 Aug 2020 05:20:25 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 0A3BB10055FF; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 011FD2D3; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:05 -0400 Message-Id: <1597148419-20629-10-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 09/23] lustre: sec: check if page is empty with ZERO_PAGE X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Sebastien Buisson In osc_brw_fini_request(), page needs decryption only if it is not empty. To check this, use ZERO_PAGE macro available for all architectures, and compare with memcmp. It will likely be faster/more efficient than comparing the words by hand as may use optimized CPU instructions or ASM code. WC-bug-id: https://jira.whamcloud.com/browse/LU-12275 Lustre-commit: 45c26bc11b7b1e ("LU-12275 sec: check if page is empty with ZERO_PAGE") Signed-off-by: Sebastien Buisson Reviewed-on: https://review.whamcloud.com/38918 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/osc/osc_request.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/lustre/osc/osc_request.c b/fs/lustre/osc/osc_request.c index 1968d62..3bbe3d9 100644 --- a/fs/lustre/osc/osc_request.c +++ b/fs/lustre/osc/osc_request.c @@ -2075,16 +2075,11 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) } for (idx = 0; idx < aa->aa_page_count; idx++) { struct brw_page *pg = aa->aa_ppga[idx]; - u64 *p, *q; /* do not decrypt if page is all 0s */ - p = q = page_address(pg->pg); - while (p - q < PAGE_SIZE / sizeof(*p)) { - if (*p != 0) - break; - p++; - } - if (p - q == PAGE_SIZE / sizeof(*p)) { + if (memcmp(page_address(pg->pg), + page_address(ZERO_PAGE(0)), + PAGE_SIZE) == 0) { /* if page is empty forward info to upper layers * (ll_io_zero_page) by clearing PagePrivate2 */ From patchwork Tue Aug 11 12:20:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709185 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC54A14E3 for ; Tue, 11 Aug 2020 12:21:06 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D49BF206C3 for ; Tue, 11 Aug 2020 12:21:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D49BF206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 19AE22F37EE; Tue, 11 Aug 2020 05:20:44 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id D72E621F5A4 for ; Tue, 11 Aug 2020 05:20:25 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 10F1C100561C; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 0807E2AC; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:06 -0400 Message-Id: <1597148419-20629-11-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 10/23] lustre: uapi: add OBD_CONNECT2_GETATTR_PFID X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lai Siyao , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Lai Siyao Add OBD_CONNECT2_GETATTR_PFID connect flag to pack parent FID in getattr request, which will be used to check whether target is remote object, if so, don't take LOOKUP lock, otherwise client may see stale directory entries. WC-bug-id: https://jira.whamcloud.com/browse/LU-13437 Lustre-commit: f384a8733c41e4 ("LU-13437 uapi: add OBD_CONNECT2_GETATTR_PFID") Signed-off-by: Lai Siyao Reviewed-on: https://review.whamcloud.com/39289 Reviewed-by: Andreas Dilger Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/obdclass/lprocfs_status.c | 2 ++ fs/lustre/ptlrpc/wiretest.c | 4 +++- include/uapi/linux/lustre/lustre_idl.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/lustre/obdclass/lprocfs_status.c b/fs/lustre/obdclass/lprocfs_status.c index 3d16516..a3c5657 100644 --- a/fs/lustre/obdclass/lprocfs_status.c +++ b/fs/lustre/obdclass/lprocfs_status.c @@ -127,6 +127,8 @@ "crush", /* 0x2000 */ "async_discard", /* 0x4000 */ "client_encryption", /* 0x8000 */ + "fidmap", /* 0x10000 */ + "getattr_pfid", /* 0x20000 */ NULL }; diff --git a/fs/lustre/ptlrpc/wiretest.c b/fs/lustre/ptlrpc/wiretest.c index d1dff09..556aaff 100644 --- a/fs/lustre/ptlrpc/wiretest.c +++ b/fs/lustre/ptlrpc/wiretest.c @@ -1241,8 +1241,10 @@ 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", + LASSERTF(OBD_CONNECT2_FIDMAP == 0x10000ULL, "found 0x%.16llxULL\n", OBD_CONNECT2_FIDMAP); + LASSERTF(OBD_CONNECT2_GETATTR_PFID == 0x20000ULL, "found 0x%.16llxULL\n", + OBD_CONNECT2_GETATTR_PFID); 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 fdeb2a3..2cdc230 100644 --- a/include/uapi/linux/lustre/lustre_idl.h +++ b/include/uapi/linux/lustre/lustre_idl.h @@ -837,6 +837,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 */ /* 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 From patchwork Tue Aug 11 12:20:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709195 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E269B14E3 for ; Tue, 11 Aug 2020 12:21:20 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CAD0B2075D for ; Tue, 11 Aug 2020 12:21:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CAD0B2075D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id A06052F388B; Tue, 11 Aug 2020 05:20:51 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 272A721F5A4 for ; Tue, 11 Aug 2020 05:20:26 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 131AB100561D; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 0B13A2B1; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:07 -0400 Message-Id: <1597148419-20629-12-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 11/23] lustre: update version to 2.13.55 X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Oleg Drokin New tag 2.13.55 Signed-off-by: Oleg Drokin Signed-off-by: James Simmons --- include/uapi/linux/lustre/lustre_ver.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/lustre/lustre_ver.h b/include/uapi/linux/lustre/lustre_ver.h index b862cf6..f206b6c 100644 --- a/include/uapi/linux/lustre/lustre_ver.h +++ b/include/uapi/linux/lustre/lustre_ver.h @@ -3,9 +3,9 @@ #define LUSTRE_MAJOR 2 #define LUSTRE_MINOR 13 -#define LUSTRE_PATCH 54 +#define LUSTRE_PATCH 55 #define LUSTRE_FIX 0 -#define LUSTRE_VERSION_STRING "2.13.54" +#define LUSTRE_VERSION_STRING "2.13.55" #define OBD_OCD_VERSION(major, minor, patch, fix) \ (((major) << 24) + ((minor) << 16) + ((patch) << 8) + (fix)) From patchwork Tue Aug 11 12:20:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709187 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3822814E3 for ; Tue, 11 Aug 2020 12:21:09 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2085A2075D for ; Tue, 11 Aug 2020 12:21:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2085A2075D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 112092F3851; Tue, 11 Aug 2020 05:20:45 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 3B4142F36F4 for ; Tue, 11 Aug 2020 05:20:27 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 1932F1005642; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 0DDE42B4; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:08 -0400 Message-Id: <1597148419-20629-13-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 12/23] lustre: sysfs: error-check value stored in jobid_var X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown The jobid_var sysfs attribute only has 3 meaningful values. Other values cause lustre_get_jobid() to return an error which is uniformly ignored. To improve usability and resilience, check that the value written is acceptable before storing it. Reviewed-by: James Simmons Signed-off-by: Mr NeilBrown --- fs/lustre/obdclass/obd_sysfs.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/fs/lustre/obdclass/obd_sysfs.c b/fs/lustre/obdclass/obd_sysfs.c index cb2f0a9..5fc638f 100644 --- a/fs/lustre/obdclass/obd_sysfs.c +++ b/fs/lustre/obdclass/obd_sysfs.c @@ -225,16 +225,26 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr, const char *buffer, size_t count) { + static const char * const valid[] = { + JOBSTATS_DISABLE, + JOBSTATS_PROCNAME_UID, + JOBSTATS_NODELOCAL, + JOBSTATS_SESSION, + NULL + }; + int i; + if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN) return -EINVAL; - memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1); - - memcpy(obd_jobid_var, buffer, count); + for (i = 0; valid[i]; i++) + if (sysfs_streq(buffer, valid[i])) + break; + if (!valid[i]) + return -EINVAL; - /* Trim the trailing '\n' if any */ - if (obd_jobid_var[count - 1] == '\n') - obd_jobid_var[count - 1] = 0; + memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1); + strcpy(obd_jobid_var, valid[i]); return count; } From patchwork Tue Aug 11 12:20:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709179 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 464581392 for ; Tue, 11 Aug 2020 12:20:55 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E037206C3 for ; Tue, 11 Aug 2020 12:20:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E037206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 3BC782F380F; Tue, 11 Aug 2020 05:20:38 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 69D0D2F82F3 for ; Tue, 11 Aug 2020 05:20:26 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 13D9D100561E; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 10DE82B6; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:09 -0400 Message-Id: <1597148419-20629-14-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 13/23] lnet: Add param to control response tracking X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Chris Horn Add lnet_response_tracking parameter which will be used to control the behavior of LNet response tracking. HPE-bug-id: LUS-8827 WC-bug-id: https://jira.whamcloud.com/browse/LU-13502 Lustre-commit: 5b3747294a4bf ("LU-13502 lnet: Add param to control response tracking") Signed-off-by: Chris Horn Reviewed-on: https://review.whamcloud.com/38449 Reviewed-by: Neil Brown Reviewed-by: Serguei Smirnov Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- include/linux/lnet/lib-lnet.h | 1 + net/lnet/lnet/api-ni.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h index b069422..e733807 100644 --- a/include/linux/lnet/lib-lnet.h +++ b/include/linux/lnet/lib-lnet.h @@ -417,6 +417,7 @@ struct lnet_ni * struct lnet_ni *lnet_net2ni_addref(u32 net); struct lnet_net *lnet_get_net_locked(u32 net_id); +extern unsigned int lnet_response_tracking; extern unsigned int lnet_transaction_timeout; extern unsigned int lnet_retry_count; extern unsigned int lnet_lnd_timeout; diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c index 5f35468..c90ab2e 100644 --- a/net/lnet/lnet/api-ni.c +++ b/net/lnet/lnet/api-ni.c @@ -170,6 +170,20 @@ static int recovery_interval_set(const char *val, MODULE_PARM_DESC(lnet_retry_count, "Maximum number of times to retry transmitting a message"); +unsigned int lnet_response_tracking = 3; +static int response_tracking_set(const char *val, + const struct kernel_param *kp); +static struct kernel_param_ops param_ops_response_tracking = { + .set = response_tracking_set, + .get = param_get_int, +}; + +#define param_check_response_tracking(name, p) \ + __param_check(name, p, int) +module_param(lnet_response_tracking, response_tracking, 0644); +MODULE_PARM_DESC(lnet_response_tracking, + "(0|1|2|3) LNet Internal Only|GET Reply only|PUT ACK only|Full Tracking (default)"); + #define LNET_LND_TIMEOUT_DEFAULT ((LNET_TRANSACTION_TIMEOUT_HEALTH_DEFAULT - 1) / \ (LNET_RETRY_COUNT_HEALTH_DEFAULT + 1)) unsigned int lnet_lnd_timeout = LNET_LND_TIMEOUT_DEFAULT; @@ -470,6 +484,29 @@ static int lnet_discover(struct lnet_process_id id, u32 force, return 0; } +static int +response_tracking_set(const char *val, const struct kernel_param *kp) +{ + int rc; + unsigned long new_value; + + rc = kstrtoul(val, 0, &new_value); + if (rc) { + CERROR("Invalid value for 'lnet_response_tracking'\n"); + return -EINVAL; + } + + if (new_value < 0 || new_value > 3) { + CWARN("Invalid value (%lu) for 'lnet_response_tracking'\n", + new_value); + return -EINVAL; + } + + lnet_response_tracking = new_value; + + return 0; +} + static const char * lnet_get_routes(void) { From patchwork Tue Aug 11 12:20:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709199 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C5AE1392 for ; Tue, 11 Aug 2020 12:21:27 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 746912075D for ; Tue, 11 Aug 2020 12:21:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 746912075D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1C68C2F38AF; Tue, 11 Aug 2020 05:20:55 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id AB18A2F364E for ; Tue, 11 Aug 2020 05:20:26 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 1657F100561F; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 13CAB2CF; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:10 -0400 Message-Id: <1597148419-20629-15-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 14/23] lnet: Ensure LNet pings and pushes are always tracked X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Chris Horn Add the appropriate option to the MD used for LNet pings and pushes to ensure that these are always tracked via LNet's response tracking mechanism, regardless of the value of lnet_response_tracking variable. HPE-bug-id: LUS-8827 WC-bug-id: https://jira.whamcloud.com/browse/LU-13502 Lustre-commit: 9ed12d2e8f3f2 ("LU-13502 lnet: Ensure LNet pings and pushes are always tracked") Signed-off-by: Chris Horn Reviewed-on: https://review.whamcloud.com/38451 Reviewed-by: Neil Brown Reviewed-by: Serguei Smirnov Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- net/lnet/lnet/lib-move.c | 2 +- net/lnet/lnet/peer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c index c0dd30c..aa6fe37 100644 --- a/net/lnet/lnet/lib-move.c +++ b/net/lnet/lnet/lib-move.c @@ -3340,7 +3340,7 @@ struct lnet_mt_event_info { md.length = LNET_PING_INFO_SIZE(nnis); md.threshold = 2; /* GET/REPLY */ md.max_size = 0; - md.options = LNET_MD_TRUNCATE; + md.options = LNET_MD_TRUNCATE | LNET_MD_TRACK_RESPONSE; md.user_ptr = user_data; md.handler = handler; diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c index f745394..578591d 100644 --- a/net/lnet/lnet/peer.c +++ b/net/lnet/lnet/peer.c @@ -3097,7 +3097,7 @@ static int lnet_peer_send_push(struct lnet_peer *lp) md.length = LNET_PING_INFO_SIZE(pbuf->pb_nnis); md.threshold = 2; /* Put/Ack */ md.max_size = 0; - md.options = 0; + md.options = LNET_MD_TRACK_RESPONSE; md.handler = the_lnet.ln_dc_handler; md.user_ptr = lp; From patchwork Tue Aug 11 12:20:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709183 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84B771392 for ; Tue, 11 Aug 2020 12:21:02 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C79E206C3 for ; Tue, 11 Aug 2020 12:21:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C79E206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id B40AF2F37A8; Tue, 11 Aug 2020 05:20:41 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id EE1CC2F366B for ; Tue, 11 Aug 2020 05:20:26 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 1848D1005641; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 171BC2B7; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:11 -0400 Message-Id: <1597148419-20629-16-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 15/23] lnet: Preferred NI logic breaks MR routing X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Horn , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Chris Horn Edge (final-hop) routers typically use the non-multi-rail destination (NMR_DST) send case. i.e. they treat the destination as non-multi-rail. The reason for this is that we do not want routers to modify the destination peer interface selected by the message originator. As a result of using the NMR_DST send case, edge routers set a preferred NI, and then continue to use that NI, because it's preferred, even if the NI goes down and the router has other healthy interfaces available to it. Routers do not need to use the preferred NI selection logic when they are forwarding a message, so modify the NMR_DST algorithm to allow routers to select any suitable local NI. HPE-bug-id: LUS-9045 WC-bug-id: https://jira.whamcloud.com/browse/LU-13712 Lustre-commit: ef6c35877b96c ("LU-13712 lnet: Preferred NI logic breaks MR routing") Signed-off-by: Chris Horn Reviewed-on: https://review.whamcloud.com/39168 Reviewed-by: Serguei Smirnov Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- net/lnet/lnet/lib-move.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c index aa6fe37..7c14518 100644 --- a/net/lnet/lnet/lib-move.c +++ b/net/lnet/lnet/lib-move.c @@ -2107,7 +2107,7 @@ struct lnet_ni * static int lnet_handle_any_local_nmr_dst(struct lnet_send_data *sd) { - int rc; + int rc = 0; /* sd->sd_best_lpni is already set to the final destination */ @@ -2122,7 +2122,23 @@ struct lnet_ni * return -EFAULT; } - rc = lnet_select_preferred_best_ni(sd); + if (sd->sd_msg->msg_routing) { + /* If I'm forwarding this message then I can choose any NI + * on the destination peer net + */ + sd->sd_best_ni = lnet_find_best_ni_on_spec_net(NULL, + sd->sd_peer, + sd->sd_best_lpni->lpni_peer_net, + sd->sd_md_cpt, + true); + if (!sd->sd_best_ni) { + CERROR("Unable to forward message to %s. No local NI available\n", + libcfs_nid2str(sd->sd_dst_nid)); + rc = -EHOSTUNREACH; + } + } else { + rc = lnet_select_preferred_best_ni(sd); + } if (!rc) rc = lnet_handle_send(sd); From patchwork Tue Aug 11 12:20:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709203 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8CE3514E3 for ; Tue, 11 Aug 2020 12:21:35 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7503B206C3 for ; Tue, 11 Aug 2020 12:21:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7503B206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1680D2F38DF; Tue, 11 Aug 2020 05:20:59 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 8090B2F3747 for ; Tue, 11 Aug 2020 05:20:27 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 1B2D11005643; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 19E7B2D1; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:12 -0400 Message-Id: <1597148419-20629-17-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 16/23] lnet: socklnd: remove declarations of missing functions. X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown None of ksocknal_query(), ksocknal_notify(), and ksocknal_lib_bind_thread_to_cpu() exist, so don't declare them. WC-bug-id: https://jira.whamcloud.com/browse/LU-6142 Lustre-commit: 4e69e77201b4d ("LU-6142 socklnd: remove declarations of missing functions.") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/39326 Reviewed-by: James Simmons Reviewed-by: Alexey Lyashkov Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- net/lnet/klnds/socklnd/socklnd.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/lnet/klnds/socklnd/socklnd.h b/net/lnet/klnds/socklnd/socklnd.h index 350f2c8..261cbb46 100644 --- a/net/lnet/klnds/socklnd/socklnd.h +++ b/net/lnet/klnds/socklnd/socklnd.h @@ -638,7 +638,6 @@ int ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx, void ksocknal_next_tx_carrier(struct ksock_conn *conn); void ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn); void ksocknal_txlist_done(struct lnet_ni *ni, struct list_head *txlist, int error); -void ksocknal_notify(lnet_nid_t gw_nid); void ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, time64_t *when); int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name); void ksocknal_thread_fini(void); @@ -682,6 +681,5 @@ int ksocknal_lib_get_conn_tunables(struct ksock_conn *conn, int *txmem, void ksocknal_lib_csum_tx(struct ksock_tx *tx); int ksocknal_lib_memory_pressure(struct ksock_conn *conn); -int ksocknal_lib_bind_thread_to_cpu(int id); #endif /* _SOCKLND_SOCKLND_H_ */ From patchwork Tue Aug 11 12:20:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709189 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFF0B1392 for ; Tue, 11 Aug 2020 12:21:13 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 97D582075D for ; Tue, 11 Aug 2020 12:21:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97D582075D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 72D682F364F; Tue, 11 Aug 2020 05:20:47 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C2CE32F3747 for ; Tue, 11 Aug 2020 05:20:27 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 1DF5A1005644; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 1CA502AC; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:13 -0400 Message-Id: <1597148419-20629-18-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 17/23] lnet: discard unused lnet_print_hdr() X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown lnet_print_hdr() is unused, and has not been used in git history since at least 2004. So remove it. WC-bug-id: https://jira.whamcloud.com/browse/LU-6142 Lustre-commit: 58d4a4c38ab1b ("LU-6142 lnet: discard unused lnet_print_hdr()") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/39358 Reviewed-by: James Simmons Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- include/linux/lnet/lib-lnet.h | 1 - net/lnet/lnet/lib-move.c | 58 ------------------------------------------- 2 files changed, 59 deletions(-) diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h index e733807..299ecf5 100644 --- a/include/linux/lnet/lib-lnet.h +++ b/include/linux/lnet/lib-lnet.h @@ -590,7 +590,6 @@ void lnet_drop_message(struct lnet_ni *ni, int cpt, void *private, char *lnet_health_error2str(enum lnet_msg_hstatus hstatus); char *lnet_msgtyp2str(int type); -void lnet_print_hdr(struct lnet_hdr *hdr); int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold); /** \addtogroup lnet_fault_simulation @{ */ diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c index 7c14518..85b6453 100644 --- a/net/lnet/lnet/lib-move.c +++ b/net/lnet/lnet/lib-move.c @@ -3940,64 +3940,6 @@ void lnet_monitor_thr_stop(void) } } -void -lnet_print_hdr(struct lnet_hdr *hdr) -{ - struct lnet_process_id src = { 0 }; - struct lnet_process_id dst = { 0 }; - char *type_str = lnet_msgtyp2str(hdr->type); - - src.nid = hdr->src_nid; - src.pid = hdr->src_pid; - - dst.nid = hdr->dest_nid; - dst.pid = hdr->dest_pid; - - CWARN("P3 Header at %p of type %s\n", hdr, type_str); - CWARN(" From %s\n", libcfs_id2str(src)); - CWARN(" To %s\n", libcfs_id2str(dst)); - - switch (hdr->type) { - default: - break; - - case LNET_MSG_PUT: - CWARN(" Ptl index %d, ack md %#llx.%#llx, match bits %llu\n", - hdr->msg.put.ptl_index, - hdr->msg.put.ack_wmd.wh_interface_cookie, - hdr->msg.put.ack_wmd.wh_object_cookie, - hdr->msg.put.match_bits); - CWARN(" Length %d, offset %d, hdr data %#llx\n", - hdr->payload_length, hdr->msg.put.offset, - hdr->msg.put.hdr_data); - break; - - case LNET_MSG_GET: - CWARN(" Ptl index %d, return md %#llx.%#llx, match bits %llu\n", - hdr->msg.get.ptl_index, - hdr->msg.get.return_wmd.wh_interface_cookie, - hdr->msg.get.return_wmd.wh_object_cookie, - hdr->msg.get.match_bits); - CWARN(" Length %d, src offset %d\n", - hdr->msg.get.sink_length, - hdr->msg.get.src_offset); - break; - - case LNET_MSG_ACK: - CWARN(" dst md %#llx.%#llx, manipulated length %d\n", - hdr->msg.ack.dst_wmd.wh_interface_cookie, - hdr->msg.ack.dst_wmd.wh_object_cookie, - hdr->msg.ack.mlength); - break; - - case LNET_MSG_REPLY: - CWARN(" dst md %#llx.%#llx, length %d\n", - hdr->msg.reply.dst_wmd.wh_interface_cookie, - hdr->msg.reply.dst_wmd.wh_object_cookie, - hdr->payload_length); - } -} - int lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid, void *private, int rdma_req) From patchwork Tue Aug 11 12:20:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709207 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2895F1392 for ; Tue, 11 Aug 2020 12:21:43 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 10D4B206C3 for ; Tue, 11 Aug 2020 12:21:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10D4B206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 356262F37FC; Tue, 11 Aug 2020 05:21:02 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 263E52F3747 for ; Tue, 11 Aug 2020 05:20:28 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 20C821005645; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 1F7FA2B1; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:14 -0400 Message-Id: <1597148419-20629-19-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 18/23] lnet: clarify initialization of lpni_refcount X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown This refcount is not explicitly initialized, so is implicitly initialized to zero. This prohibits the use lnet_peer_ni_addref_locked() for taking the first reference, so a couple of places open-code the atomic_inc just in case. There is code in lnet_peer_add_nid() which drops a reference before accessing the structure. This isn't actually wrong, but it looks weird. lnet_destroy_peer_ni_locked() makes assumptions about the content of the structure, so it cannot be used on a partially initialized structure. All these special cases make the code harder to understand. This patch cleans this up: - lpni_refcount is now initialized to one, so the called for lnet_peer_ni_alloc() now owns a reference and must be sure to release it. - lnet_peer_attach_peer_ni() now consumes a reference to the lpni. A pointer returned by lnet_peer_ni_alloc() is most often passed to lnet_peer_attach_peer_ni() so these to changes largely cancel each other out - not completely - The two 'atomic_inc' calls are changed to 'lnet_peer_ni_addref_locked(). - A kfree is replaced by lnet_peer_ni_decref_locked(), and that function is improved to cope with lpni_hashlist being empty, or ->lpni_net being NULL. - lnet_peer_add_nid() now holds a reference on the lpni until it don't need it any more, then explicity drops it. This should make no functional change, but should make the code a little less confusing. WC-bug-id: https://jira.whamcloud.com/browse/LU-12678 Lustre-commit: 5bcb17cf1d476 ("LU-12678 lnet: clarify initialization of lpni_refcount") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/39120 Reviewed-by: Chris Horn Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- net/lnet/lnet/peer.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c index 578591d..81f908e 100644 --- a/net/lnet/lnet/peer.c +++ b/net/lnet/lnet/peer.c @@ -125,6 +125,7 @@ INIT_LIST_HEAD(&lpni->lpni_recovery); INIT_LIST_HEAD(&lpni->lpni_on_remote_peer_ni_list); LNetInvalidateMDHandle(&lpni->lpni_recovery_ping_mdh); + atomic_set(&lpni->lpni_refcount, 1); spin_lock_init(&lpni->lpni_lock); @@ -152,7 +153,7 @@ * list so it can be easily found and revisited. */ /* FIXME: per-net implementation instead? */ - atomic_inc(&lpni->lpni_refcount); + lnet_peer_ni_addref_locked(lpni); list_add_tail(&lpni->lpni_on_remote_peer_ni_list, &the_lnet.ln_remote_peer_ni_list); } @@ -1223,9 +1224,9 @@ struct lnet_peer_net * * may be attached to a different peer, in which case it will be * properly detached first. The whole operation is done atomically. * - * Always returns 0. This is the last function called from functions - * that do return an int, so returning 0 here allows the compiler to - * do a tail call. + * This function consumes the reference on lpni and Always returns 0. + * This is the last function called from functions that do return an + * int, so returning 0 here allows the compiler to do a tail call. */ static int lnet_peer_attach_peer_ni(struct lnet_peer *lp, @@ -1244,8 +1245,7 @@ struct lnet_peer_net * ptable = the_lnet.ln_peer_tables[lpni->lpni_cpt]; list_add_tail(&lpni->lpni_hashlist, &ptable->pt_hash[hash]); ptable->pt_version++; - /* This is the 1st refcount on lpni. */ - atomic_inc(&lpni->lpni_refcount); + lnet_peer_ni_addref_locked(lpni); } /* Detach the peer_ni from an existing peer, if necessary. */ @@ -1293,11 +1293,12 @@ struct lnet_peer_net * spin_unlock(&lp->lp_lock); lp->lp_nnis++; - lnet_net_unlock(LNET_LOCK_EX); CDEBUG(D_NET, "peer %s NID %s flags %#x\n", libcfs_nid2str(lp->lp_primary_nid), libcfs_nid2str(lpni->lpni_nid), flags); + lnet_peer_ni_decref_locked(lpni); + lnet_net_unlock(LNET_LOCK_EX); return 0; } @@ -1418,17 +1419,16 @@ struct lnet_peer_net * * it is not connected to this peer and was configured * by DLC. */ - lnet_peer_ni_decref_locked(lpni); if (lpni->lpni_peer_net->lpn_peer == lp) - goto out; + goto out_free_lpni; if (lnet_peer_ni_is_configured(lpni)) { rc = -EEXIST; - goto out; + goto out_free_lpni; } /* If this is the primary NID, destroy the peer. */ if (lnet_peer_ni_is_primary(lpni)) { struct lnet_peer *rtr_lp = - lpni->lpni_peer_net->lpn_peer; + lpni->lpni_peer_net->lpn_peer; int rtr_refcount = rtr_lp->lp_rtr_refcount; /* if we're trying to delete a router it means @@ -1440,17 +1440,18 @@ struct lnet_peer_net * lnet_rtr_transfer_to_peer(rtr_lp, lp); } lnet_peer_del(lpni->lpni_peer_net->lpn_peer); + lnet_peer_ni_decref_locked(lpni); lpni = lnet_peer_ni_alloc(nid); if (!lpni) { rc = -ENOMEM; - goto out; + goto out_free_lpni; } } } else { lpni = lnet_peer_ni_alloc(nid); if (!lpni) { rc = -ENOMEM; - goto out; + goto out_free_lpni; } } @@ -1473,9 +1474,7 @@ struct lnet_peer_net * return lnet_peer_attach_peer_ni(lp, lpn, lpni, flags); out_free_lpni: - /* If the peer_ni was allocated above its peer_net pointer is NULL */ - if (!lpni->lpni_peer_net) - kfree(lpni); + lnet_peer_ni_decref_locked(lpni); out: CDEBUG(D_NET, "peer %s NID %s flags %#x: %d\n", libcfs_nid2str(lp->lp_primary_nid), libcfs_nid2str(nid), @@ -1699,18 +1698,21 @@ struct lnet_peer_net * lpni->lpni_peer_net = NULL; lpni->lpni_net = NULL; - /* remove the peer ni from the zombie list */ - ptable = the_lnet.ln_peer_tables[lpni->lpni_cpt]; - spin_lock(&ptable->pt_zombie_lock); - list_del_init(&lpni->lpni_hashlist); - ptable->pt_zombies--; - spin_unlock(&ptable->pt_zombie_lock); + if (!list_empty(&lpni->lpni_hashlist)) { + /* remove the peer ni from the zombie list */ + ptable = the_lnet.ln_peer_tables[lpni->lpni_cpt]; + spin_lock(&ptable->pt_zombie_lock); + list_del_init(&lpni->lpni_hashlist); + ptable->pt_zombies--; + spin_unlock(&ptable->pt_zombie_lock); + } if (lpni->lpni_pref_nnids > 1) kfree(lpni->lpni_pref.nids); kfree(lpni); - lnet_peer_net_decref_locked(lpn); + if (lpn) + lnet_peer_net_decref_locked(lpn); } struct lnet_peer_ni * From patchwork Tue Aug 11 12:20:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709193 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B76A14E3 for ; Tue, 11 Aug 2020 12:21:20 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13BBA2075D for ; Tue, 11 Aug 2020 12:21:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13BBA2075D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 4B3B12F3885; Tue, 11 Aug 2020 05:20:51 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 7E1842F82F8 for ; Tue, 11 Aug 2020 05:20:28 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 24B401005646; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 2248D2B6; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:15 -0400 Message-Id: <1597148419-20629-20-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 19/23] lnet: Allow duplicate nets in ip2nets syntax X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Horn , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Chris Horn Before the MR feature was implemented, it was not possible to configure multiple interfaces on the same LNet, so the ip2nets syntax did not allow for this. Now that we have MR feature, we should allow it to be configured via ip2nets syntax. e.g. o2ib(ib0) 10.10.10.1 o2ib(ib1) 10.10.10.2 A test is added for configuring LNet with kernel ip2nets parameter. setup_netns() refactored to facilitate the new test. cleanup_lnet() is modified to check whether lnet module is loaded before attempting lnetctl lnet unconfigured otherwise sanity-lnet.sh could exit with rc 234 on cleanup. HPE-bug-id: LUS-9046 WC-bug-id: https://jira.whamcloud.com/browse/LU-13734 Lustre-commit: 6203ed821ffac ("LU-13734 lnet: Allow duplicate nets in ip2nets syntax") Signed-off-by: Chris Horn Reviewed-on: https://review.whamcloud.com/39227 Reviewed-by: James Simmons Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- net/lnet/lnet/config.c | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/net/lnet/lnet/config.c b/net/lnet/lnet/config.c index 9f36c82..6ddd9d6 100644 --- a/net/lnet/lnet/config.c +++ b/net/lnet/lnet/config.c @@ -349,10 +349,10 @@ struct lnet_net * { struct lnet_net *net; - if (!lnet_net_unique(net_id, net_list, NULL)) { - CERROR("Duplicate net %s. Ignore\n", - libcfs_net2str(net_id)); - return NULL; + if (!lnet_net_unique(net_id, net_list, &net)) { + CDEBUG(D_NET, "Returning duplicate net %p %s\n", net, + libcfs_net2str(net->net_id)); + return net; } net = kzalloc(sizeof(*net), GFP_NOFS); @@ -1450,12 +1450,8 @@ struct lnet_ni * struct list_head *t; struct list_head *t2; struct lnet_text_buf *tb; - struct lnet_text_buf *tb2; - u32 net1; - u32 net2; int len; int count; - int dup; int rc; if (lnet_str2tbs_sep(&raw_entries, ip2nets) < 0) { @@ -1494,30 +1490,6 @@ struct lnet_ni * if (rc < 0) break; - dup = 0; - list_for_each_entry(tb, ¤t_nets, ltb_list) { - net1 = lnet_netspec2net(tb->ltb_text); - LASSERT(net1 != LNET_NIDNET(LNET_NID_ANY)); - - list_for_each_entry(tb2, &matched_nets, ltb_list) { - net2 = lnet_netspec2net(tb2->ltb_text); - LASSERT(net2 != LNET_NIDNET(LNET_NID_ANY)); - - if (net1 == net2) { - dup = 1; - break; - } - } - - if (dup) - break; - } - - if (dup) { - lnet_free_text_bufs(¤t_nets); - continue; - } - list_for_each_safe(t, t2, ¤t_nets) { tb = list_entry(t, struct lnet_text_buf, ltb_list); From patchwork Tue Aug 11 12:20:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709209 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 747B514E3 for ; Tue, 11 Aug 2020 12:21:48 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5BEFD206C3 for ; Tue, 11 Aug 2020 12:21:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BEFD206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 89C012F37AC; Tue, 11 Aug 2020 05:21:05 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id BFBDC21F67E for ; Tue, 11 Aug 2020 05:20:28 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 2760E1005647; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 25A352B4; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:16 -0400 Message-Id: <1597148419-20629-21-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 20/23] lustre: llite: pack parent FID in getattr X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lai Siyao , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Lai Siyao Pack parent FID in getattr request if OBD_CONNECT2_GETATTR_PFID is enabled, otherwise fill it with target FID for backward compatibility. Fixes: e11fdb90 ("lustre: mdt: don't fetch LOOKUP lock for remot...") WC-bug-id: https://jira.whamcloud.com/browse/LU-13437 Lustre-commit: 5f2c44bf626b ("U-13437 llite: pack parent FID in getattr") Signed-off-by: Lai Siyao Reviewed-on: https://review.whamcloud.com/39290 Reviewed-by: Neil Brown Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/file.c | 10 ++++++++-- fs/lustre/llite/llite_lib.c | 3 ++- fs/lustre/lmv/lmv_intent.c | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c index 7d00728..17c2d88 100644 --- a/fs/lustre/llite/file.c +++ b/fs/lustre/llite/file.c @@ -4533,6 +4533,7 @@ static int ll_inode_revalidate_fini(struct inode *inode, int rc) static int ll_inode_revalidate(struct dentry *dentry, enum ldlm_intent_flags op) { + struct inode *parent; struct inode *inode = d_inode(dentry); struct obd_export *exp = ll_i2mdexp(inode); struct lookup_intent oit = { @@ -4545,9 +4546,14 @@ static int ll_inode_revalidate(struct dentry *dentry, enum ldlm_intent_flags op) 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) + parent = dentry->d_parent->d_inode; + else + parent = inode; + /* Call getattr by fid, so do not provide name at all. */ - op_data = ll_prep_md_op_data(NULL, dentry->d_parent->d_inode, inode, - NULL, 0, 0, LUSTRE_OPC_ANY, NULL); + op_data = ll_prep_md_op_data(NULL, parent, inode, NULL, 0, 0, + LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) return PTR_ERR(op_data); diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c index 4773fc1..e732a82 100644 --- a/fs/lustre/llite/llite_lib.c +++ b/fs/lustre/llite/llite_lib.c @@ -261,7 +261,8 @@ 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_GETATTR_PFID; if (sbi->ll_flags & LL_SBI_LRU_RESIZE) data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE; diff --git a/fs/lustre/lmv/lmv_intent.c b/fs/lustre/lmv/lmv_intent.c index 4af449e..3960b93 100644 --- a/fs/lustre/lmv/lmv_intent.c +++ b/fs/lustre/lmv/lmv_intent.c @@ -197,7 +197,10 @@ int lmv_revalidate_slaves(struct obd_export *exp, * which is not needed here. */ memset(op_data, 0, sizeof(*op_data)); - op_data->op_fid1 = *pfid; + if (exp_connect_flags2(exp) & OBD_CONNECT2_GETATTR_PFID) + op_data->op_fid1 = *pfid; + else + op_data->op_fid1 = fid; op_data->op_fid2 = fid; tgt = lmv_tgt(lmv, lsm->lsm_md_oinfo[i].lmo_mds); From patchwork Tue Aug 11 12:20:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709197 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC97C1392 for ; Tue, 11 Aug 2020 12:21:25 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3C9C2075D for ; Tue, 11 Aug 2020 12:21:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3C9C2075D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 47DB32F38A4; Tue, 11 Aug 2020 05:20:54 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 218D12F82FB for ; Tue, 11 Aug 2020 05:20:29 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 2B8E01005648; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 28CA02AC; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:17 -0400 Message-Id: <1597148419-20629-22-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 21/23] lnet: Clear lp_dc_error when discovery completes X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Horn , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Chris Horn If discovery completes successfully then we can clear the lp_dc_error. HPE-bug-id: LUS-9081 WC-bug-id: https://jira.whamcloud.com/browse/LU-13764 Lustre-commit: d3fa46705225f ("LU-13764 lnet: Clear lp_dc_error when discovery completes") Signed-off-by: Chris Horn Reviewed-on: https://review.whamcloud.com/39348 Reviewed-by: Amir Shehata Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- net/lnet/lnet/peer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c index 81f908e..5ca6f68 100644 --- a/net/lnet/lnet/peer.c +++ b/net/lnet/lnet/peer.c @@ -3058,6 +3058,8 @@ static int lnet_peer_discovered(struct lnet_peer *lp) lp->lp_state &= ~(LNET_PEER_DISCOVERING | LNET_PEER_REDISCOVER); + lp->lp_dc_error = 0; + CDEBUG(D_NET, "peer %s\n", libcfs_nid2str(lp->lp_primary_nid)); return 0; From patchwork Tue Aug 11 12:20:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709205 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 890F514E3 for ; Tue, 11 Aug 2020 12:21:39 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 71233206C3 for ; Tue, 11 Aug 2020 12:21:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71233206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 91A062F38F0; Tue, 11 Aug 2020 05:21:00 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 62BBE21F2CD for ; Tue, 11 Aug 2020 05:20:29 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 2D7471005649; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 2BCD62B1; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:18 -0400 Message-Id: <1597148419-20629-23-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 22/23] lnet: Have LNet routers monitor the ni_fatal flag X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Horn , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Chris Horn Have the LNet monitor thread on LNet routers check the ni_fatal_error_on flag to set local NI status appropriately. When this results in a status change, perform a discovery push to all peers. This allows peers to update their route status appropriately. HPE-bug-id: LUS-9068 WC-bug-id: https://jira.whamcloud.com/browse/LU-13782 Lustre-commit: 7e0ec0f809ea1 ("LU-13782 lnet: Have LNet routers monitor the ni_fatal flag") Signed-off-by: Chris Horn Reviewed-on: https://review.whamcloud.com/39353 Reviewed-by: Neil Brown Reviewed-by: Amir Shehata Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- include/linux/lnet/lib-lnet.h | 29 +++++++++++++++++++++++++++++ net/lnet/lnet/lib-move.c | 6 +----- net/lnet/lnet/router.c | 35 ++++++++++++++++++++++++----------- 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h index 299ecf5..d2a39f6 100644 --- a/include/linux/lnet/lib-lnet.h +++ b/include/linux/lnet/lib-lnet.h @@ -98,6 +98,35 @@ extern struct kmem_cache *lnet_rspt_cachep; extern struct kmem_cache *lnet_msg_cachep; +static inline bool +lnet_ni_set_status_locked(struct lnet_ni *ni, u32 status) +__must_hold(&ni->ni_lock) +{ + bool update = false; + + if (ni->ni_status && ni->ni_status->ns_status != status) { + CDEBUG(D_NET, "ni %s status changed from %#x to %#x\n", + libcfs_nid2str(ni->ni_nid), + ni->ni_status->ns_status, status); + ni->ni_status->ns_status = status; + update = true; + } + + return update; +} + +static inline bool +lnet_ni_set_status(struct lnet_ni *ni, u32 status) +{ + bool update; + + spin_lock(&ni->ni_lock); + update = lnet_ni_set_status_locked(ni, status); + spin_unlock(&ni->ni_lock); + + return update; +} + bool lnet_is_route_alive(struct lnet_route *route); bool lnet_is_gateway_alive(struct lnet_peer *gw); diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c index 85b6453..f521817 100644 --- a/net/lnet/lnet/lib-move.c +++ b/net/lnet/lnet/lib-move.c @@ -4012,11 +4012,7 @@ void lnet_monitor_thr_stop(void) spin_lock(&ni->ni_net->net_lock); ni->ni_net->net_last_alive = ktime_get_real_seconds(); spin_unlock(&ni->ni_net->net_lock); - if (ni->ni_status && - ni->ni_status->ns_status == LNET_NI_STATUS_DOWN) { - ni->ni_status->ns_status = LNET_NI_STATUS_UP; - push = true; - } + push = lnet_ni_set_status_locked(ni, LNET_NI_STATUS_UP); lnet_ni_unlock(ni); } diff --git a/net/lnet/lnet/router.c b/net/lnet/lnet/router.c index e3b3e71..1253e4c 100644 --- a/net/lnet/lnet/router.c +++ b/net/lnet/lnet/router.c @@ -1014,15 +1014,9 @@ int lnet_get_rtr_pool_cfg(int cpt, struct lnet_ioctl_pool_cfg *pool_cfg) struct lnet_ni *ni; bool update = false; - list_for_each_entry(ni, &net->net_ni_list, ni_netlist) { - lnet_ni_lock(ni); - if (ni->ni_status && - ni->ni_status->ns_status != status) { - ni->ni_status->ns_status = status; + list_for_each_entry(ni, &net->net_ni_list, ni_netlist) + if (lnet_ni_set_status(ni, status)) update = true; - } - lnet_ni_unlock(ni); - } return update; } @@ -1031,6 +1025,7 @@ int lnet_get_rtr_pool_cfg(int cpt, struct lnet_ioctl_pool_cfg *pool_cfg) lnet_update_ni_status_locked(void) { struct lnet_net *net; + struct lnet_ni *ni; bool push = false; time64_t now; time64_t timeout; @@ -1045,13 +1040,13 @@ int lnet_get_rtr_pool_cfg(int cpt, struct lnet_ioctl_pool_cfg *pool_cfg) continue; if (now < net->net_last_alive + timeout) - continue; + goto check_ni_fatal; spin_lock(&net->net_lock); /* re-check with lock */ if (now < net->net_last_alive + timeout) { spin_unlock(&net->net_lock); - continue; + goto check_ni_fatal; } spin_unlock(&net->net_lock); @@ -1059,7 +1054,25 @@ int lnet_get_rtr_pool_cfg(int cpt, struct lnet_ioctl_pool_cfg *pool_cfg) * timeout on any of its constituent NIs, then mark all * the NIs down. */ - push = lnet_net_set_status_locked(net, LNET_NI_STATUS_DOWN); + if (lnet_net_set_status_locked(net, LNET_NI_STATUS_DOWN)) { + push = true; + continue; + } + +check_ni_fatal: + list_for_each_entry(ni, &net->net_ni_list, ni_netlist) { + /* lnet_ni_set_status() will perform the same check of + * ni_status while holding the ni lock. We can safely + * check ni_status without that lock because it is only + * written to under net_lock/EX and our caller is + * holding a net lock. + */ + if (atomic_read(&ni->ni_fatal_error_on) && + ni->ni_status && + ni->ni_status->ns_status != LNET_NI_STATUS_DOWN && + lnet_ni_set_status(ni, LNET_NI_STATUS_DOWN)) + push = true; + } } return push; From patchwork Tue Aug 11 12:20:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11709201 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 815E91392 for ; Tue, 11 Aug 2020 12:21:31 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 69A092075D for ; Tue, 11 Aug 2020 12:21:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69A092075D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 2B6AF2F3785; Tue, 11 Aug 2020 05:20:57 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id B90E32F82FF for ; Tue, 11 Aug 2020 05:20:29 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 2FEE81005658; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 2E9C82B7; Tue, 11 Aug 2020 08:20:21 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 11 Aug 2020 08:20:19 -0400 Message-Id: <1597148419-20629-24-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> References: <1597148419-20629-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 23/23] lnet: socklnd: NID to interface mapping issues X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Serguei Smirnov , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Serguei Smirnov Fix the NID to interface mapping in ksocknal_startup to make sure the messages go out the interface assigned by LNet on a system with multiple interfaces configured. Fixes: 3aa523159321 ("lnet: consoldate secondary IP address handling") WC-bug-id: https://jira.whamcloud.com/browse/LU-13790 Lustre-commit: 00f672da3ba9a ("LU-13790 socklnd: NID to interface mapping issues") Signed-off-by: Serguei Smirnov Reviewed-on: https://review.whamcloud.com/39408 Reviewed-by: Amir Shehata Reviewed-by: James Simmons Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- net/lnet/klnds/socklnd/socklnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/lnet/klnds/socklnd/socklnd.c b/net/lnet/klnds/socklnd/socklnd.c index 91925475..a7c0b65 100644 --- a/net/lnet/klnds/socklnd/socklnd.c +++ b/net/lnet/klnds/socklnd/socklnd.c @@ -2694,7 +2694,7 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id) ni->ni_interfaces[i]) != 0) continue; - ksi = &net->ksnn_interfaces[j]; + ksi = &net->ksnn_interfaces[net->ksnn_ninterfaces]; ni->ni_dev_cpt = ifaces[j].li_cpt; ksi->ksni_ipaddr = ifaces[j].li_ipaddr; ksi->ksni_index =