Received: by 10.223.164.202 with SMTP id h10csp4391461wrb; Wed, 29 Nov 2017 05:46:27 -0800 (PST) X-Google-Smtp-Source: AGs4zMZAnAA9WyWkcopJHuqqZS3EgM1Tgw59fwz6shBSkoDh+yawljRtlgrFNxL8oreEp9tOT5Ye X-Received: by 10.98.138.149 with SMTP id o21mr3032119pfk.225.1511963187446; Wed, 29 Nov 2017 05:46:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511963187; cv=none; d=google.com; s=arc-20160816; b=mtEZR6/LwOPj2FpKc5RZqvAnn3KinRDSz6WZxzohFUV2kalDL34kGmAGBkqiubjzoU 6pmZxgdWHiWm4ep01v8GKiJLt0fqRmQAL6dihy0+McMahFRAG3hq0J9gEOBNsd5/TNuM lDko2rtT4Y7pOcYvkcEWQ2Kwum8+C83BIYAz8LgIj8QYapBdmmnxrPsadrxOMLyvOIku N57YCdkPBRyNTlDgW+OQPFDvdDq45dBBUwAeZUvl63GfVweInbb5X4jQQLz0S3tvC+se UJW6DdvJ/kQyHZNriJK+XkVs84KDoSZA+iOI3udOIIiDITbsoxEvhhIY6r7ofrN1Og2r a82A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=jOFJ0c80v+ghDmpsGfA7ABCv+IhBhR4ruN+suVhcbdw=; b=oKdostYeBQuSDl/X2f6qGabBOUCMOBq1dqewXq2gOlQNSWGWD7lCLdP8O0At1w96/9 P8YtFv6Vplntmv0lMzQoN+dulSOdMJ101gZnzOsDuggpqMFjFVeQOD+Mj+u5qvUfxdmh GVaUhgRcHYJRl887EZr92nrU5gyuFoSoSrPqCubObXYSqMGlcuLswz1GzHF9eZ2WJYar 9G/RaMxbAGlt6FYv5Xk39VohNWUHKBYMslkPKSataqb35Jtv4JUa9mOAJPBtS0D7JoRJ wQiRNRiNCoHSImBASq2b/0+dLaWbWC0X5z6+U+FlrRKnQP87SAhbjX5JYU/gR70ndWeu m2zA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si1297972plz.646.2017.11.29.05.46.17; Wed, 29 Nov 2017 05:46:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753671AbdK2MGI convert rfc822-to-8bit (ORCPT + 70 others); Wed, 29 Nov 2017 07:06:08 -0500 Received: from smtp.h3c.com ([60.191.123.56]:43100 "EHLO h3cmg01-ex.h3c.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751783AbdK2MGG (ORCPT ); Wed, 29 Nov 2017 07:06:06 -0500 Received: from BJHUB01-EX.srv.huawei-3com.com (unknown [10.63.20.169]) by h3cmg01-ex.h3c.com with smtp id 5bc0_018c_e6ddc629_a84e_4c05_aa7e_9af7dd21ef7e; Wed, 29 Nov 2017 20:03:15 +0800 Received: from H3CMLB14-EX.srv.huawei-3com.com ([fe80::f804:6772:bd71:f07f]) by BJHUB01-EX.srv.huawei-3com.com ([::1]) with mapi id 14.03.0248.002; Wed, 29 Nov 2017 20:02:58 +0800 From: Changwei Ge To: Gang He , "mfasheh@versity.com" , "jlbec@evilplan.org" , "rgoldwyn@suse.com" , "hch@lst.de" CC: "linux-kernel@vger.kernel.org" , "ocfs2-devel@oss.oracle.com" Subject: Re: [Ocfs2-devel] [PATCH v2 1/3] ocfs2: add ocfs2_try_rw_lock and ocfs2_try_inode_lock Thread-Topic: [Ocfs2-devel] [PATCH v2 1/3] ocfs2: add ocfs2_try_rw_lock and ocfs2_try_inode_lock Thread-Index: AQHTaQn+nx4TZchGSkq+SGn4Y3At8w== Date: Wed, 29 Nov 2017 12:02:56 +0000 Message-ID: <63ADC13FD55D6546B7DECE290D39E373F147CA86@H3CMLB14-EX.srv.huawei-3com.com> References: <1511944612-9629-1-git-send-email-ghe@suse.com> <1511944612-9629-2-git-send-email-ghe@suse.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.125.136.231] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/11/29 16:38, Gang He wrote: > Add ocfs2_try_rw_lock and ocfs2_try_inode_lock functions, which > will be used in non-block IO scenarios. > > Signed-off-by: Gang He > --- > fs/ocfs2/dlmglue.c | 21 +++++++++++++++++++++ > fs/ocfs2/dlmglue.h | 4 ++++ > 2 files changed, 25 insertions(+) > > diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c > index 4689940..a68efa3 100644 > --- a/fs/ocfs2/dlmglue.c > +++ b/fs/ocfs2/dlmglue.c > @@ -1742,6 +1742,27 @@ int ocfs2_rw_lock(struct inode *inode, int write) > return status; > } > > +int ocfs2_try_rw_lock(struct inode *inode, int write) > +{ > + int status, level; > + struct ocfs2_lock_res *lockres; > + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); > + > + mlog(0, "inode %llu try to take %s RW lock\n", > + (unsigned long long)OCFS2_I(inode)->ip_blkno, > + write ? "EXMODE" : "PRMODE"); > + > + if (ocfs2_mount_local(osb)) > + return 0; > + > + lockres = &OCFS2_I(inode)->ip_rw_lockres; > + > + level = write ? DLM_LOCK_EX : DLM_LOCK_PR; > + > + status = ocfs2_cluster_lock(osb, lockres, level, DLM_LKF_NOQUEUE, 0); Hi Gang, Should we consider about passing a flag - OCFS2_LOCK_NONBLOCK to ocfs2_cluster_lock. Otherwise a cluster locking progress may be waiting for accomplishment of DC, which I think violates _NO_WAIT_ semantics. Thanks, Changwei. > + return status; > +} > + > void ocfs2_rw_unlock(struct inode *inode, int write) > { > int level = write ? DLM_LOCK_EX : DLM_LOCK_PR; > diff --git a/fs/ocfs2/dlmglue.h b/fs/ocfs2/dlmglue.h > index a7fc18b..05910fc 100644 > --- a/fs/ocfs2/dlmglue.h > +++ b/fs/ocfs2/dlmglue.h > @@ -116,6 +116,7 @@ void ocfs2_refcount_lock_res_init(struct ocfs2_lock_res *lockres, > int ocfs2_create_new_inode_locks(struct inode *inode); > int ocfs2_drop_inode_locks(struct inode *inode); > int ocfs2_rw_lock(struct inode *inode, int write); > +int ocfs2_try_rw_lock(struct inode *inode, int write); > void ocfs2_rw_unlock(struct inode *inode, int write); > int ocfs2_open_lock(struct inode *inode); > int ocfs2_try_open_lock(struct inode *inode, int write); > @@ -140,6 +141,9 @@ int ocfs2_inode_lock_with_page(struct inode *inode, > /* 99% of the time we don't want to supply any additional flags -- > * those are for very specific cases only. */ > #define ocfs2_inode_lock(i, b, e) ocfs2_inode_lock_full_nested(i, b, e, 0, OI_LS_NORMAL) > +#define ocfs2_try_inode_lock(i, b, e)\ > + ocfs2_inode_lock_full_nested(i, b, e, OCFS2_META_LOCK_NOQUEUE,\ > + OI_LS_NORMAL) > void ocfs2_inode_unlock(struct inode *inode, > int ex); > int ocfs2_super_lock(struct ocfs2_super *osb, > From 1585403247542750758@xxx Wed Nov 29 12:25:58 +0000 2017 X-GM-THRID: 1585212200939154586 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread