Received: by 10.223.164.202 with SMTP id h10csp1377753wrb; Mon, 27 Nov 2017 01:49:22 -0800 (PST) X-Google-Smtp-Source: AGs4zMZwwNxIbfqieBTnE3ncvVDEiM2fEbtv/Sqd+FhQ4su7+BrbU2LnjxRBoYR+W+IxNUw/GREf X-Received: by 10.84.229.79 with SMTP id d15mr37148390pln.397.1511776162089; Mon, 27 Nov 2017 01:49:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511776162; cv=none; d=google.com; s=arc-20160816; b=OSroeQw0rct0yaP/y5ZI0B4ZaBBdsTvvspaNs1/3Q35xA6Md+2TAbDFZwtdFTWjKn7 mx0SMxWB9z2zv7Jhl+A/4OFyzamW07XcHGXg8Drgdbr8ZX8hylR9GvjngbYBhYJ7KA+o PFjvadscza1SIoaRmDWCsWmEokyF9s/prNAukJZ/pZbwTkfZGs0AxTP+e4/ZGf+d9c9m a6/56fEAbMM51m74N0xaKUORnwIs7lfTiJOGwcggrpBMgsgaOx8/GlqQZSgaTEYrVrKV uPY/sQHaUCF5Szm+UiOlpHCvvbuqa8xBPzmAGP+7CdKd1y85N//0luQ0zoaRVl/BumJf t5iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=EQURiy3F4wVKm8xkx55yq7BhfYMlPp14Ym+71mjyjnw=; b=B+ckC+ptyREfRDAw/f99Z3Uc8L/ZV2Z+LeNIQqvRnuGhRKSzoBXx6S+AM1HYnGQsUt QXoMG9B4b9DOVmTTJGuURCXBXbrOnBtOMTsoxwDQLSuQtTMAc5iLIHnKjtwf9fAD0MyI GJ8Q+qgQLoK+t0hqDNQ8IgLsv/yhUMQtVEtjEfZBEioSa5/gEgmanQybT9viRNzPtqGx KhnThAjUqVzZCS+NR5NYEWNYf1o/XgI19FYfIfwSw1KTX/MxqwQWI4xumIhfPFRJwDT9 snLR3u0pfUZ8l1FjNHw36fPLyTqLZ03Q7RD8jppsGaVp9prnwTrr5+uV/l9h/H6WKrcb Q7NA== 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 g12si22780229pll.378.2017.11.27.01.49.10; Mon, 27 Nov 2017 01:49:22 -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 S1751608AbdK0Jry (ORCPT + 78 others); Mon, 27 Nov 2017 04:47:54 -0500 Received: from prv3-mh.provo.novell.com ([137.65.250.26]:38710 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751511AbdK0JrN (ORCPT ); Mon, 27 Nov 2017 04:47:13 -0500 Received: from ghe-pc.suse.asia (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (TLS encrypted); Mon, 27 Nov 2017 02:46:58 -0700 From: Gang He To: mfasheh@versity.com, jlbec@evilplan.org, rgoldwyn@suse.com, hch@lst.de Cc: Gang He , linux-kernel@vger.kernel.org, ocfs2-devel@oss.oracle.com, akpm@linux-foundation.org Subject: [PATCH 1/3] ocfs2: add ocfs2_try_rw_lock and ocfs2_try_inode_lock Date: Mon, 27 Nov 2017 17:46:25 +0800 Message-Id: <1511775987-841-2-git-send-email-ghe@suse.com> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1511775987-841-1-git-send-email-ghe@suse.com> References: <1511775987-841-1-git-send-email-ghe@suse.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 22 ++++++++++++++++++++++ fs/ocfs2/dlmglue.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 4689940..5cfbd04 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -1742,6 +1742,28 @@ 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(OCFS2_SB(inode->i_sb), lockres, level, + DLM_LKF_NOQUEUE, 0); + 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, -- 1.8.5.6 From 1585861620318266562@xxx Mon Dec 04 13:51:36 +0000 2017 X-GM-THRID: 1585861620318266562 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread