From patchwork Mon Feb 3 17:58:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Reichl X-Patchwork-Id: 11363149 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 9A8D7139A for ; Mon, 3 Feb 2020 17:59:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7A4DA21741 for ; Mon, 3 Feb 2020 17:59:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Qa5nmNgl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728520AbgBCR7E (ORCPT ); Mon, 3 Feb 2020 12:59:04 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:22206 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728278AbgBCR7D (ORCPT ); Mon, 3 Feb 2020 12:59:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580752742; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kb1ZKLe1vwyJjKT/TOSZp+t3g+vXgBPuwBJOmIPkxp8=; b=Qa5nmNglZt7IDKCplgGy2QJAvW91K0SrIqm+zIiQWVZo4Jg+nYCNVsRrUK9iAlVsvfXyEp alsp0jRClEizwkxS+eMW6NAz5TJenLF4eQ2dTdXvbSXE7Nql6lIDyMVjAz8YJ/HX5+2Z61 JODL2VkM0ZIu3R2Dw751pQhB0O4buks= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-gj8kyoaqNAScHe-dhwMS8Q-1; Mon, 03 Feb 2020 12:59:00 -0500 X-MC-Unique: gj8kyoaqNAScHe-dhwMS8Q-1 Received: by mail-wr1-f70.google.com with SMTP id u8so7667093wrp.10 for ; Mon, 03 Feb 2020 09:58:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kb1ZKLe1vwyJjKT/TOSZp+t3g+vXgBPuwBJOmIPkxp8=; b=W6xIGU/s+qBhqndFIy7562HIvq2d1rtvdeEksOmlv8Aogk2/Z+HiRCn7rca5ZYg1Am FNIjxCEK/2kveedzwTI+FKdjiH95mPbxQavlskQZbgS+aDwXppPFesoypfBfjzyP0vz8 YsBgJvNAQJ3H1dVwH/WuazT9gcYRTT4XLw+k5MM8bFAjJqjIHXjIqOX4IhPIIxs00VBQ lIIhIAQSD9uf1/C01JLWEbWMCXpEhFVs7B2364sHMP6Xww24tAdT+u97cIsGkje3kq76 r1ujbkyx+EWy0q9wRRgP0nLWYLOiR+n8Y2ck+QG2zb7orxDZap6TYllFadQN9LPTMrMy eiUA== X-Gm-Message-State: APjAAAVbfR+9yvrFGoLTZxZvXLTo+iojZVU7bcsZDX0tojQxW7JBdGO5 EBqatACoWBFkvuXMnIQ8rLmWsfJ3R5E0o+6TL6ChAj7Em8o4dqcpCU55n9ef8GFmsrTHH1YIGvx BaqeNF7TvO9pcyfrOLAdT X-Received: by 2002:a7b:c14d:: with SMTP id z13mr226687wmi.71.1580752738855; Mon, 03 Feb 2020 09:58:58 -0800 (PST) X-Google-Smtp-Source: APXvYqxVXX6//tzX7ic1lo9f4H6+QiuVELOF2ibRaypY6n37KJCqLWonHjNDIweqqqP+J3Hf7RNaqQ== X-Received: by 2002:a7b:c14d:: with SMTP id z13mr226661wmi.71.1580752738674; Mon, 03 Feb 2020 09:58:58 -0800 (PST) Received: from localhost.localdomain.com (243.206.broadband12.iol.cz. [90.179.206.243]) by smtp.gmail.com with ESMTPSA id a132sm212274wme.3.2020.02.03.09.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 09:58:58 -0800 (PST) From: Pavel Reichl To: linux-xfs@vger.kernel.org Cc: Pavel Reichl , Dave Chinner Subject: [PATCH v2 1/7] xfs: Add xfs_is_{i,io,mmap}locked functions Date: Mon, 3 Feb 2020 18:58:44 +0100 Message-Id: <20200203175850.171689-2-preichl@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200203175850.171689-1-preichl@redhat.com> References: <20200203175850.171689-1-preichl@redhat.com> MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add xfs_is_ilocked(), xfs_is_iolocked() and xfs_is_mmaplocked() Signed-off-by: Pavel Reichl Suggested-by: Dave Chinner --- fs/xfs/xfs_inode.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_inode.h | 3 +++ 2 files changed, 56 insertions(+) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index c5077e6326c7..80874c80df6d 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -372,6 +372,59 @@ xfs_isilocked( ASSERT(0); return 0; } + +static inline bool +__xfs_is_ilocked( + struct rw_semaphore *rwsem, + bool shared, + bool excl) +{ + bool locked = false; + + if (!rwsem_is_locked(rwsem)) + return false; + + if (!debug_locks) + return true; + + if (shared) + locked = lockdep_is_held_type(rwsem, 0); + + if (excl) + locked |= lockdep_is_held_type(rwsem, 1); + + return locked; +} + +bool +xfs_is_ilocked( + struct xfs_inode *ip, + int lock_flags) +{ + return __xfs_is_ilocked(&ip->i_lock.mr_lock, + (lock_flags & XFS_ILOCK_SHARED), + (lock_flags & XFS_ILOCK_EXCL)); +} + +bool +xfs_is_mmaplocked( + struct xfs_inode *ip, + int lock_flags) +{ + return __xfs_is_ilocked(&ip->i_mmaplock.mr_lock, + (lock_flags & XFS_MMAPLOCK_SHARED), + (lock_flags & XFS_MMAPLOCK_EXCL)); +} + +bool +xfs_is_iolocked( + struct xfs_inode *ip, + int lock_flags) +{ + return __xfs_is_ilocked(&VFS_I(ip)->i_rwsem, + (lock_flags & XFS_IOLOCK_SHARED), + (lock_flags & XFS_IOLOCK_EXCL)); +} #endif /* diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 492e53992fa9..6ba575f35c1f 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -417,6 +417,9 @@ int xfs_ilock_nowait(xfs_inode_t *, uint); void xfs_iunlock(xfs_inode_t *, uint); void xfs_ilock_demote(xfs_inode_t *, uint); int xfs_isilocked(xfs_inode_t *, uint); +bool xfs_is_ilocked(struct xfs_inode *, int); +bool xfs_is_mmaplocked(struct xfs_inode *, int); +bool xfs_is_iolocked(struct xfs_inode *, int); uint xfs_ilock_data_map_shared(struct xfs_inode *); uint xfs_ilock_attr_map_shared(struct xfs_inode *); From patchwork Mon Feb 3 17:58:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Reichl X-Patchwork-Id: 11363151 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 EECB214B4 for ; Mon, 3 Feb 2020 17:59:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9E8D21741 for ; Mon, 3 Feb 2020 17:59:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="f+4nul8t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728468AbgBCR7F (ORCPT ); Mon, 3 Feb 2020 12:59:05 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:21383 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728474AbgBCR7F (ORCPT ); Mon, 3 Feb 2020 12:59:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580752743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1EjJz5KdVbkA6I6TdN9r6hpvijYX4ZdASjtTvSKLcdU=; b=f+4nul8th2kcc4xF/i3dHGFevozWZ1xjpEflwaDCdMLFK8g51Pxfw4ovol42FMlJw32YCZ cCzace8UKzD1wk0bEJolZaHeetnqFq3Ef0N1vvu1yWoDf3LTGzNLSOPBOWLGFR8DJEb95S X5VeRj8G5czru0BdE825jxTz2Aru6F8= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-220-S1TEvqMvNeaQF0Fieu90Qw-1; Mon, 03 Feb 2020 12:59:01 -0500 X-MC-Unique: S1TEvqMvNeaQF0Fieu90Qw-1 Received: by mail-wm1-f72.google.com with SMTP id p26so84377wmg.5 for ; Mon, 03 Feb 2020 09:59:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1EjJz5KdVbkA6I6TdN9r6hpvijYX4ZdASjtTvSKLcdU=; b=oysi/ta0Hwo0jxD0lfnk9oitNk8lOwAld0GDw8GUEbyDx5G6cKJ3/Cqy8jBtaTW7tk nFSRP5K/RJ8o6EQ6bPewa0iMlXfzBWIZAjWpN/69qYo8zLkYRdVWIpaCILUMBf7uzKZr LJDtD2BIAF+HjZq9c191XFSmfMxUZa/Fd/+pFrnNwMtxlRfoHyF5EGz+zoPC6Gg8GjjH fMuUavgZ0TQTbWn/HfamKMEfUh3VVjKAGqElCbUhkChJCJjGZVqUA9WeQlpyRyKWxYAt kBkq5Q8tJHC2cqnEI3XZXgbscRSHlt7BfF4/kspKiOUeAP2viRpsYlGfczKa0++RE+Yi ITKw== X-Gm-Message-State: APjAAAX2HB2wJzvx3ldrNuTKnKENKF2UsR32EZyJSBVc12ZGr40ykPCw bGMDr+yv5ZsGWXEyBCNcApSTer5ozc6HeqT8H4isoLSmCRCvbAo7kRu7FEQfoB1oOVHReiVptTC zV6ocYeXOA0hA8YAz8MOr X-Received: by 2002:a7b:cf12:: with SMTP id l18mr273950wmg.66.1580752740134; Mon, 03 Feb 2020 09:59:00 -0800 (PST) X-Google-Smtp-Source: APXvYqxAaAKR+3K1KM/0QLOYkkbJdz3UKgUIWE9/+Fx1kvUnp7+oEArzxUFQ35dZ4NdKdm9FC6rN/Q== X-Received: by 2002:a7b:cf12:: with SMTP id l18mr273914wmg.66.1580752739643; Mon, 03 Feb 2020 09:58:59 -0800 (PST) Received: from localhost.localdomain.com (243.206.broadband12.iol.cz. [90.179.206.243]) by smtp.gmail.com with ESMTPSA id a132sm212274wme.3.2020.02.03.09.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 09:58:59 -0800 (PST) From: Pavel Reichl To: linux-xfs@vger.kernel.org Cc: Pavel Reichl , Dave Chinner Subject: [PATCH v2 2/7] xfs: Update checking excl. locks for ilock Date: Mon, 3 Feb 2020 18:58:45 +0100 Message-Id: <20200203175850.171689-3-preichl@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200203175850.171689-1-preichl@redhat.com> References: <20200203175850.171689-1-preichl@redhat.com> MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Signed-off-by: Pavel Reichl Suggested-by: Dave Chinner Reviewed-by: Dave Chinner --- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_bmap.c | 10 +++++----- fs/xfs/libxfs/xfs_rtbitmap.c | 2 +- fs/xfs/libxfs/xfs_trans_inode.c | 6 +++--- fs/xfs/xfs_dquot.c | 4 ++-- fs/xfs/xfs_inode.c | 4 ++-- fs/xfs/xfs_inode_item.c | 4 ++-- fs/xfs/xfs_iops.c | 4 ++-- fs/xfs/xfs_qm.c | 10 +++++----- fs/xfs/xfs_reflink.c | 2 +- fs/xfs/xfs_rtalloc.c | 4 ++-- fs/xfs/xfs_trans_dquot.c | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 8b7f74b3bea2..5607c5551095 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -577,7 +577,7 @@ xfs_attr_rmtval_stale( struct xfs_mount *mp = ip->i_mount; struct xfs_buf *bp; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); if (XFS_IS_CORRUPT(mp, map->br_startblock == DELAYSTARTBLOCK) || XFS_IS_CORRUPT(mp, map->br_startblock == HOLESTARTBLOCK)) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 9a6d7a84689a..318c006b4b50 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -1238,7 +1238,7 @@ xfs_iread_extents( struct xfs_btree_cur *cur; int error; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); if (XFS_IS_CORRUPT(mp, XFS_IFORK_FORMAT(ip, whichfork) != @@ -4402,7 +4402,7 @@ xfs_bmapi_write( ASSERT(tp != NULL); ASSERT(len > 0); ASSERT(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL); - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT(!(flags & XFS_BMAPI_REMAP)); /* zeroing is for currently only for data extents, not metadata */ @@ -4678,7 +4678,7 @@ xfs_bmapi_remap( ifp = XFS_IFORK_PTR(ip, whichfork); ASSERT(len > 0); ASSERT(len <= (xfs_filblks_t)MAXEXTLEN); - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT(!(flags & ~(XFS_BMAPI_ATTRFORK | XFS_BMAPI_PREALLOC | XFS_BMAPI_NORMAP))); ASSERT((flags & (XFS_BMAPI_ATTRFORK | XFS_BMAPI_PREALLOC)) != @@ -5329,7 +5329,7 @@ __xfs_bunmapi( if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT(len > 0); ASSERT(nexts >= 0); @@ -5700,7 +5700,7 @@ xfs_bmse_merge( blockcount = left->br_blockcount + got->br_blockcount; ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT(xfs_bmse_can_merge(left, got, shift)); new = *left; diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c index f42c74cb8be5..4ba9dea9bdf0 100644 --- a/fs/xfs/libxfs/xfs_rtbitmap.c +++ b/fs/xfs/libxfs/xfs_rtbitmap.c @@ -974,7 +974,7 @@ xfs_rtfree_extent( mp = tp->t_mountp; ASSERT(mp->m_rbmip->i_itemp != NULL); - ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); error = xfs_rtcheck_alloc_range(mp, tp, bno, len); if (error) diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c index 2b8ccb5b975d..bac474d97574 100644 --- a/fs/xfs/libxfs/xfs_trans_inode.c +++ b/fs/xfs/libxfs/xfs_trans_inode.c @@ -29,7 +29,7 @@ xfs_trans_ijoin( { xfs_inode_log_item_t *iip; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); if (ip->i_itemp == NULL) xfs_inode_item_init(ip, ip->i_mount); iip = ip->i_itemp; @@ -58,7 +58,7 @@ xfs_trans_ichgtime( struct timespec64 tv; ASSERT(tp); - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); tv = current_time(inode); @@ -88,7 +88,7 @@ xfs_trans_log_inode( struct inode *inode = VFS_I(ip); ASSERT(ip->i_itemp != NULL); - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); /* * Don't bother with i_lock for the I_DIRTY_TIME check here, as races diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index d223e1ae90a6..74d9d00d45ef 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -862,7 +862,7 @@ xfs_qm_dqget_inode( if (error) return error; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT(xfs_inode_dquot(ip, type) == NULL); id = xfs_qm_id_for_quotatype(ip, type); @@ -919,7 +919,7 @@ xfs_qm_dqget_inode( } dqret: - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); trace_xfs_dqget_miss(dqp); *O_dqpp = dqp; return 0; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 80874c80df6d..a19c6ddaea6f 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1574,7 +1574,7 @@ xfs_itruncate_extents_flags( xfs_filblks_t unmap_len; int error = 0; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT(!atomic_read(&VFS_I(ip)->i_count) || xfs_isilocked(ip, XFS_IOLOCK_EXCL)); ASSERT(new_size <= XFS_ISIZE(ip)); @@ -2805,7 +2805,7 @@ xfs_ifree( int error; struct xfs_icluster xic = { 0 }; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT(VFS_I(ip)->i_nlink == 0); ASSERT(ip->i_d.di_nextents == 0); ASSERT(ip->i_d.di_anextents == 0); diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 8bd5d0de6321..6396d7b2038c 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -440,7 +440,7 @@ xfs_inode_item_pin( { struct xfs_inode *ip = INODE_ITEM(lip)->ili_inode; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); trace_xfs_inode_pin(ip, _RET_IP_); atomic_inc(&ip->i_pincount); @@ -574,7 +574,7 @@ xfs_inode_item_release( unsigned short lock_flags; ASSERT(ip->i_itemp != NULL); - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); lock_flags = iip->ili_lock_flags; iip->ili_lock_flags = 0; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 81f2f93caec0..eba2ec2a59f1 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -598,7 +598,7 @@ xfs_setattr_mode( struct inode *inode = VFS_I(ip); umode_t mode = iattr->ia_mode; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); inode->i_mode &= S_IFMT; inode->i_mode |= mode & ~S_IFMT; @@ -611,7 +611,7 @@ xfs_setattr_time( { struct inode *inode = VFS_I(ip); - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); if (iattr->ia_valid & ATTR_ATIME) inode->i_atime = iattr->ia_atime; diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 0b0909657bad..dfe155cbaa55 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -253,7 +253,7 @@ xfs_qm_dqattach_one( struct xfs_dquot *dqp; int error; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); error = 0; /* @@ -323,7 +323,7 @@ xfs_qm_dqattach_locked( if (!xfs_qm_need_dqattach(ip)) return 0; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); if (XFS_IS_UQUOTA_ON(mp) && !ip->i_udquot) { error = xfs_qm_dqattach_one(ip, ip->i_d.di_uid, XFS_DQ_USER, @@ -354,7 +354,7 @@ xfs_qm_dqattach_locked( * Don't worry about the dquots that we may have attached before any * error - they'll get detached later if it has not already been done. */ - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); return error; } @@ -1754,7 +1754,7 @@ xfs_qm_vop_chown( XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount)); /* old dquot */ @@ -1915,7 +1915,7 @@ xfs_qm_vop_create_dqattach( if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) return; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT(XFS_IS_QUOTA_RUNNING(mp)); if (udqp && XFS_IS_UQUOTA_ON(mp)) { diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index b0ce04ffd3cd..1d570ad1cfc9 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -359,7 +359,7 @@ xfs_reflink_allocate_cow( xfs_filblks_t resaligned; xfs_extlen_t resblks = 0; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); if (!ip->i_cowfp) { ASSERT(!xfs_is_reflink_inode(ip)); xfs_ifork_init_cow(ip); diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 6209e7b6b895..35906b3c2825 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -1121,7 +1121,7 @@ xfs_rtallocate_extent( xfs_fsblock_t sb; /* summary file block number */ xfs_buf_t *sumbp; /* summary file block buffer */ - ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); ASSERT(minlen > 0 && minlen <= maxlen); /* @@ -1278,7 +1278,7 @@ xfs_rtpick_extent( uint64_t seq; /* sequence number of file creation */ uint64_t *seqp; /* pointer to seqno in inode */ - ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); seqp = (uint64_t *)&VFS_I(mp->m_rbmip)->i_atime; if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) { diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index d1b9869bc5fa..ed3a78e6a295 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -808,7 +808,7 @@ xfs_trans_reserve_quota_nblks( ASSERT(!xfs_is_quota_inode(&mp->m_sb, ip->i_ino)); - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == XFS_TRANS_DQ_RES_RTBLKS || (flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == From patchwork Mon Feb 3 17:58:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Reichl X-Patchwork-Id: 11363153 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 C00E014B4 for ; Mon, 3 Feb 2020 17:59:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96E6321741 for ; Mon, 3 Feb 2020 17:59:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XvWiZH68" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728594AbgBCR7G (ORCPT ); Mon, 3 Feb 2020 12:59:06 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:39376 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728278AbgBCR7F (ORCPT ); Mon, 3 Feb 2020 12:59:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580752744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NGRmFzCW9EzSzTykkNFuSP5Yv9tuXzFPXb7FKqe7oIg=; b=XvWiZH68mUB+JOgcDG+3dEobFCJzk7UwMBMY1xP9ItTwFWCcikOf5A7lll9hmPdzEKh+Vd ejXQBRpVOeIANeYgPm4BXjUoOKFzCeDVdZGoo8Bgth8tiLPHy/k0SJqvo1ygjRbNGmcbTR CsoMJokFPtP9Mc8l+Ql6xY29xA6Ew1s= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-379-G_BOR8u4OJOCyLb-N3ClnA-1; Mon, 03 Feb 2020 12:59:03 -0500 X-MC-Unique: G_BOR8u4OJOCyLb-N3ClnA-1 Received: by mail-wr1-f71.google.com with SMTP id n23so2111622wra.20 for ; Mon, 03 Feb 2020 09:59:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NGRmFzCW9EzSzTykkNFuSP5Yv9tuXzFPXb7FKqe7oIg=; b=XZ7/g45Q3EeZ0spQr+4bbYjCaphHpXV2zfc2RL9vWpAwcPzClnHF0CatvJLw9HQPWX Ppx9moV7/TbQsSQko1gq786z6+r8csi/JWHe7Qgj3n+MmiDTaVe5VNX4KAyhFAPkMBDn Y5jiQC1IvBPvAKXsKEgZ5CdkMIvMISA3ZQMeyezJSG379F8InLOqa7zj4tVQbsqEf6nX fngW1NXr+gs7X1wCBZdrId7Q2AK0n/GsVd0cVWBbZRoa/zlbyNlignSenqmU18qqQkjo Rr9CUYD4B8dAoeX/ymrINffUfTQUvUG1BfEvqzbk1aL2ArHgywJwFSHfJ5aFWjkzLQfA doIA== X-Gm-Message-State: APjAAAV3eFhrqbDgnJANUONxTKzhnRvE6xOsDKssAXC55xtD32Ta8/lG II7nyCpkyZ2up5+W+Us2xHhw+sTcFjS7dwVwhnVM/CJF9mtu7v+5g9dAe+zA3sM3eR0r5n85RqH EZHea7lyug/dClJx0rBgy X-Received: by 2002:a05:600c:2c06:: with SMTP id q6mr254611wmg.154.1580752741599; Mon, 03 Feb 2020 09:59:01 -0800 (PST) X-Google-Smtp-Source: APXvYqzUGowvOj3mN9Oqt7uHtd344sI3cDRX3HqYaDqrXlduWCAcsqm85GhM7ypRcdv9d1R/igEkWg== X-Received: by 2002:a05:600c:2c06:: with SMTP id q6mr254594wmg.154.1580752741391; Mon, 03 Feb 2020 09:59:01 -0800 (PST) Received: from localhost.localdomain.com (243.206.broadband12.iol.cz. [90.179.206.243]) by smtp.gmail.com with ESMTPSA id a132sm212274wme.3.2020.02.03.09.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 09:59:00 -0800 (PST) From: Pavel Reichl To: linux-xfs@vger.kernel.org Cc: Pavel Reichl , Dave Chinner Subject: [PATCH v2 3/7] xfs: Update checking read or write locks for ilock Date: Mon, 3 Feb 2020 18:58:46 +0100 Message-Id: <20200203175850.171689-4-preichl@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200203175850.171689-1-preichl@redhat.com> References: <20200203175850.171689-1-preichl@redhat.com> MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Signed-off-by: Pavel Reichl Suggested-by: Dave Chinner Reviewed-by: Dave Chinner --- fs/xfs/libxfs/xfs_attr.c | 2 +- fs/xfs/libxfs/xfs_bmap.c | 2 +- fs/xfs/libxfs/xfs_inode_fork.c | 2 +- fs/xfs/xfs_attr_list.c | 2 +- fs/xfs/xfs_inode.c | 6 +++--- fs/xfs/xfs_qm.c | 2 +- fs/xfs/xfs_symlink.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index e6149720ce02..e692225d2e64 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -107,7 +107,7 @@ xfs_attr_get_ilocked( struct xfs_inode *ip, struct xfs_da_args *args) { - ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); if (!xfs_inode_hasattr(ip)) return -ENOATTR; diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 318c006b4b50..86a9fe2a7629 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3906,7 +3906,7 @@ xfs_bmapi_read( ASSERT(*nmap >= 1); ASSERT(!(flags & ~(XFS_BMAPI_ATTRFORK|XFS_BMAPI_ENTIRE| XFS_BMAPI_COWFORK))); - ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ip, whichfork)) || XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) { diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index ad2b9c313fd2..ffb5731a73da 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c @@ -560,7 +560,7 @@ xfs_iextents_copy( struct xfs_bmbt_irec rec; int64_t copied = 0; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL | XFS_ILOCK_SHARED)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); ASSERT(ifp->if_bytes > 0); for_each_xfs_iext(ifp, &icur, &rec) { diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index d37743bdf274..a52539a0fd63 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -511,7 +511,7 @@ xfs_attr_list_int_ilocked( { struct xfs_inode *dp = context->dp; - ASSERT(xfs_isilocked(dp, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(dp, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); /* * Decide on what work routines to call based on the inode size. diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index a19c6ddaea6f..d7cb2886ca81 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2859,7 +2859,7 @@ static void xfs_iunpin( struct xfs_inode *ip) { - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); trace_xfs_inode_unpin_nowait(ip, _RET_IP_); @@ -3723,7 +3723,7 @@ xfs_iflush( XFS_STATS_INC(mp, xs_iflush_count); - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); ASSERT(xfs_isiflocked(ip)); ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || ip->i_d.di_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)); @@ -3855,7 +3855,7 @@ xfs_iflush_int( struct xfs_dinode *dip; struct xfs_mount *mp = ip->i_mount; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); ASSERT(xfs_isiflocked(ip)); ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || ip->i_d.di_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)); diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index dfe155cbaa55..757c8cc00e39 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -1802,7 +1802,7 @@ xfs_qm_vop_chown_reserve( int error; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); ASSERT(XFS_IS_QUOTA_RUNNING(mp)); delblks = ip->i_delayed_blks; diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index d762d42ed0ff..20179f173688 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -41,7 +41,7 @@ xfs_readlink_bmap_ilocked( int fsblocks = 0; int offset; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); fsblocks = xfs_symlink_blocks(mp, pathlen); error = xfs_bmapi_read(ip, 0, fsblocks, mval, &nmaps, 0); From patchwork Mon Feb 3 17:58:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Reichl X-Patchwork-Id: 11363155 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 4D10E139A for ; Mon, 3 Feb 2020 17:59:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D4DD2166E for ; Mon, 3 Feb 2020 17:59:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IXJzKh/e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728884AbgBCR7G (ORCPT ); Mon, 3 Feb 2020 12:59:06 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:36614 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728474AbgBCR7G (ORCPT ); Mon, 3 Feb 2020 12:59:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580752745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CM4C13QnWi5L1OqqBneEKswNuLP9I1IEei57QnAzrDc=; b=IXJzKh/eTS0AKMxEBYA2DWFXSEtvW66YsjCLpDRNcmJJlmnVKHQXiEozlu8eKAjU4FhRxE dpnRN4R4q0SYFkWatLtidz/2d/R6YNMigTpfNb8Wvk8owl4UGktTnR4jZxjpddOmWYERNG 7YPo+eYFJvcplDDOhU6Bs1ilL3M2zCo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-OJb8cD21Plug90hT3NIyug-1; Mon, 03 Feb 2020 12:59:04 -0500 X-MC-Unique: OJb8cD21Plug90hT3NIyug-1 Received: by mail-wr1-f70.google.com with SMTP id 50so7819597wrc.2 for ; Mon, 03 Feb 2020 09:59:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CM4C13QnWi5L1OqqBneEKswNuLP9I1IEei57QnAzrDc=; b=CWtW2obC0KPQLBbBpHMbncxBMjGJTO8+EemBgbO2SrLYPYb2iUjCdJKPdE72s/RaNE JxE0rw8C2v2ssOO0iLNYLvjX8Sm1KsIzN0AFZ9PgnFzFHM/GmYIEpFcFyhy7NofdzLPF RFw45w5Nk283Cu+UPIRxDva/FFkEqevdtLDZRT/uT0mKXQdznLvHMgOTm7RJV0svr7Q1 sdPnMz8yUAFvNH6pbYl8ApfBQlpqncBPoWkq2dABp6q++gwYqPu9ZleLoBz5ZUGib72D B5AlSaV9+DYkA+qmKq5kLJquVxH00XhVJnFW+YGae6CxWAi7VcfIvpJ5O3tshH6wpymq sfww== X-Gm-Message-State: APjAAAUDKXHuyuHZLOLhbzbuim0JPdZJkOXPx9XgYznYYv0Y3zaJkSXj S+c9iVXm1gzKuxr+F2ph9NXVaStS1a9iEr3bhxXjXXpRV/bM51fG9SyiOENRLrLTAbJ3AFdI+ra LQx0crFKO7ds6HsXyKVP3 X-Received: by 2002:a5d:678f:: with SMTP id v15mr11593312wru.27.1580752742901; Mon, 03 Feb 2020 09:59:02 -0800 (PST) X-Google-Smtp-Source: APXvYqw1R6H/IQN85qamfpegBxe27QpTXPXJEvxk3gr+tgNOshX901sLJ5jGCfJjvs5l3PmCvHNqLA== X-Received: by 2002:a5d:678f:: with SMTP id v15mr11593299wru.27.1580752742751; Mon, 03 Feb 2020 09:59:02 -0800 (PST) Received: from localhost.localdomain.com (243.206.broadband12.iol.cz. [90.179.206.243]) by smtp.gmail.com with ESMTPSA id a132sm212274wme.3.2020.02.03.09.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 09:59:02 -0800 (PST) From: Pavel Reichl To: linux-xfs@vger.kernel.org Cc: Pavel Reichl , Dave Chinner Subject: [PATCH v2 4/7] xfs: Update checking for iolock Date: Mon, 3 Feb 2020 18:58:47 +0100 Message-Id: <20200203175850.171689-5-preichl@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200203175850.171689-1-preichl@redhat.com> References: <20200203175850.171689-1-preichl@redhat.com> MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Signed-off-by: Pavel Reichl Suggested-by: Dave Chinner Reviewed-by: Dave Chinner --- fs/xfs/libxfs/xfs_bmap.c | 4 ++-- fs/xfs/xfs_bmap_util.c | 4 ++-- fs/xfs/xfs_file.c | 3 ++- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_iops.c | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 86a9fe2a7629..c3638552b3c0 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5699,7 +5699,7 @@ xfs_bmse_merge( blockcount = left->br_blockcount + got->br_blockcount; - ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); + ASSERT(xfs_is_iolocked(ip, XFS_IOLOCK_EXCL)); ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT(xfs_bmse_can_merge(left, got, shift)); @@ -5904,7 +5904,7 @@ xfs_bmap_can_insert_extents( int is_empty; int error = 0; - ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); + ASSERT(xfs_is_iolocked(ip, XFS_IOLOCK_EXCL)); if (XFS_FORCED_SHUTDOWN(ip->i_mount)) return -EIO; diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index e62fb5216341..ae0bccb2288f 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1065,7 +1065,7 @@ xfs_collapse_file_space( uint resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0); bool done = false; - ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); + ASSERT(xfs_is_iolocked(ip, XFS_IOLOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL)); trace_xfs_collapse_file_space(ip); @@ -1133,7 +1133,7 @@ xfs_insert_file_space( xfs_fileoff_t shift_fsb = XFS_B_TO_FSB(mp, len); bool done = false; - ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); + ASSERT(xfs_is_iolocked(ip, XFS_IOLOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL)); trace_xfs_insert_file_space(ip); diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index b8a4a3f29b36..9b3958ca73d9 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -770,7 +770,8 @@ xfs_break_layouts( bool retry; int error; - ASSERT(xfs_isilocked(XFS_I(inode), XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL)); + ASSERT(xfs_is_iolocked(XFS_I(inode), + XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL)); do { retry = false; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index d7cb2886ca81..328a3b4ffbd2 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1576,7 +1576,7 @@ xfs_itruncate_extents_flags( ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); ASSERT(!atomic_read(&VFS_I(ip)->i_count) || - xfs_isilocked(ip, XFS_IOLOCK_EXCL)); + xfs_is_iolocked(ip, XFS_IOLOCK_EXCL)); ASSERT(new_size <= XFS_ISIZE(ip)); ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); ASSERT(ip->i_itemp != NULL); diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index eba2ec2a59f1..aad255521514 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -865,7 +865,7 @@ xfs_setattr_size( uint lock_flags = 0; bool did_zeroing = false; - ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); + ASSERT(xfs_is_iolocked(ip, XFS_IOLOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL)); ASSERT(S_ISREG(inode->i_mode)); ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET| From patchwork Mon Feb 3 17:58:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Reichl X-Patchwork-Id: 11363157 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 30D87139A for ; Mon, 3 Feb 2020 17:59:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10D4F2166E for ; Mon, 3 Feb 2020 17:59:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dhGMIBfO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729216AbgBCR7Q (ORCPT ); Mon, 3 Feb 2020 12:59:16 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:32633 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729170AbgBCR7Q (ORCPT ); Mon, 3 Feb 2020 12:59:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580752755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Vk6Afv9yzZW8kjnafcJvt8ARcFdxjMpB5HqOy2tLYDI=; b=dhGMIBfONEyR+fNtMctkvZiclzRyvruQvnQuCMhudZkHQqZ9JSBtR0U5xMIbM5m0X9UXTh 33qEe7xzlOQg8LckgF3O7DdoKAGRSCNq7Z2bIy+ZcWmNa1prVBmXTRdmZGmwuFlIDgev7j ebe2JKhv2YIFNFGHn7gn9+eOLYACzrI= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-195-tnPFZbnoNSmi1ahpub-uIQ-1; Mon, 03 Feb 2020 12:59:06 -0500 X-MC-Unique: tnPFZbnoNSmi1ahpub-uIQ-1 Received: by mail-wr1-f71.google.com with SMTP id f10so8702871wro.14 for ; Mon, 03 Feb 2020 09:59:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vk6Afv9yzZW8kjnafcJvt8ARcFdxjMpB5HqOy2tLYDI=; b=isX6p+pwWnnWkreH+ePoDi4Y02UKmslPi6bAwcPPb7IMfAR8BTYhPoGgPv98XgJcIw JgghWtlNRg3UeOzmfIOqdExantNP6PzOnQV+VQluP3wryBqlmWuzl+caXrMoj3r9Yl8W DZ/UD5sq97aKXE1zYYnNR7zVObtYFvVPaPtiEJmDiNMYb0p8rOLfiGkaV3nEMAgz0z4D K8IYBdvBCFEJdHitR+/Kg2Hroz6QtRn9aWCNOwTLatICYJcjwdtIJEa8ZdtIuL7rdyUg PS5f1Y7bX3wqi1i5tDjQB5o8oI3EIkGLzDaM7pJ5+hDRO6t3bOSCCoJZqND3oUx27TPm Xblw== X-Gm-Message-State: APjAAAXzkJLgvMfz0AJP3/NvSjzCh5N6WAjaPTrPhvmESgUVcCqEJtgi rsXbnXT5Vd0BHTySzsXhaCbaeqGnJkFanEd05ZlD3IgtqFzpYCCEn5EathSumm7kTtR0KMKT+Q5 Vx6JZdFWpqHG4E17iYmX5 X-Received: by 2002:adf:f7c6:: with SMTP id a6mr16995334wrq.164.1580752744915; Mon, 03 Feb 2020 09:59:04 -0800 (PST) X-Google-Smtp-Source: APXvYqwYoT42YbOkJAH7NDum4bSb5vo/YTPA5RCwx+2gy3+9odcgRNMDl3Vxpo0y64kaM2ianRBoMw== X-Received: by 2002:adf:f7c6:: with SMTP id a6mr16995325wrq.164.1580752744802; Mon, 03 Feb 2020 09:59:04 -0800 (PST) Received: from localhost.localdomain.com (243.206.broadband12.iol.cz. [90.179.206.243]) by smtp.gmail.com with ESMTPSA id a132sm212274wme.3.2020.02.03.09.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 09:59:04 -0800 (PST) From: Pavel Reichl To: linux-xfs@vger.kernel.org Cc: Pavel Reichl , Dave Chinner Subject: [PATCH v2 5/7] xfs: Update checking for mmaplock Date: Mon, 3 Feb 2020 18:58:48 +0100 Message-Id: <20200203175850.171689-6-preichl@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200203175850.171689-1-preichl@redhat.com> References: <20200203175850.171689-1-preichl@redhat.com> MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Signed-off-by: Pavel Reichl Suggested-by: Dave Chinner Reviewed-by: Dave Chinner --- fs/xfs/xfs_bmap_util.c | 4 ++-- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_iops.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index ae0bccb2288f..377389fadf5a 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1066,7 +1066,7 @@ xfs_collapse_file_space( bool done = false; ASSERT(xfs_is_iolocked(ip, XFS_IOLOCK_EXCL)); - ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL)); + ASSERT(xfs_is_mmaplocked(ip, XFS_MMAPLOCK_EXCL)); trace_xfs_collapse_file_space(ip); @@ -1134,7 +1134,7 @@ xfs_insert_file_space( bool done = false; ASSERT(xfs_is_iolocked(ip, XFS_IOLOCK_EXCL)); - ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL)); + ASSERT(xfs_is_mmaplocked(ip, XFS_MMAPLOCK_EXCL)); trace_xfs_insert_file_space(ip); diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 9b3958ca73d9..a4dbd9a6f45a 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -749,7 +749,7 @@ xfs_break_dax_layouts( { struct page *page; - ASSERT(xfs_isilocked(XFS_I(inode), XFS_MMAPLOCK_EXCL)); + ASSERT(xfs_is_mmaplocked(XFS_I(inode), XFS_MMAPLOCK_EXCL)); page = dax_layout_busy_page(inode->i_mapping); if (!page) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index aad255521514..67a0f940b30e 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -866,7 +866,7 @@ xfs_setattr_size( bool did_zeroing = false; ASSERT(xfs_is_iolocked(ip, XFS_IOLOCK_EXCL)); - ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL)); + ASSERT(xfs_is_mmaplocked(ip, XFS_MMAPLOCK_EXCL)); ASSERT(S_ISREG(inode->i_mode)); ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET| ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0); From patchwork Mon Feb 3 17:58:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Reichl X-Patchwork-Id: 11363159 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 8A42217E0 for ; Mon, 3 Feb 2020 17:59:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A1FF21741 for ; Mon, 3 Feb 2020 17:59:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M3LPLwhU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729170AbgBCR7Q (ORCPT ); Mon, 3 Feb 2020 12:59:16 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37357 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728278AbgBCR7Q (ORCPT ); Mon, 3 Feb 2020 12:59:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580752755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vW1g6s+HBcI0J8HGyOEdASKggJmBfc4o86wIy8hvv6s=; b=M3LPLwhUwFmJj5ZxUucKZvfBtvNZme+zEPd5UJUXXHPPyPJnDhOz6aDGHmpmmEJANYBsbB 5eGUBsI/OBE3qhzhfqHQuLsyq3Zd+JPm0D8i50mLDyt6Xq/8Ti2T+lnbxgWdBmw6tb1Pzk wpxpCWWSsb6VparNafD2d7HBuX7uYpA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-219-X-e_HdVnOAW801JzIX1olw-1; Mon, 03 Feb 2020 12:59:13 -0500 X-MC-Unique: X-e_HdVnOAW801JzIX1olw-1 Received: by mail-wm1-f70.google.com with SMTP id m4so71656wmi.5 for ; Mon, 03 Feb 2020 09:59:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vW1g6s+HBcI0J8HGyOEdASKggJmBfc4o86wIy8hvv6s=; b=ZXsQJxOy80GkPtzN3F+Ibg6lhD8ScaSMvXiW05DvtI5f7PJhOc0Y9xK1oiXHdZ7Dgc yaEWikco/OKx3qIZRTK88hxasJbNYMRdGppeBApBm1ZqpE5wKj0uYsLAsaNTbs+lNIVj NooJlHfaaB28BrIgQfG1RrB7dhP+vAbVRJbsv9oaX9WPV8bOwRukCwQD1+akCZk8xyhI V/ky0MUeUC6v1OE5C3AGFuRBgYizj8PoYhDuoWMlxEsqGV4qVv1BBQcvpQBh76kx3dA6 1H301ywXYN4O7EdVVY18wL87Tp/d/GDiwfYDd4zurt17S9uLgB/HMfAkV7XIqPrg3Bm+ 4lxA== X-Gm-Message-State: APjAAAWv3m8eIIYgewN2lMdFG2sz7lVr8xRq+yaMeC87cA/smiaevncD EJHtAWxWGDEMdwJhv9B9u61kUy20ALWk0cjpx89Y6yJvc8J4il16PVG53EovsNiTZvCnOBNm7fc U/lryr83fLsuWxYbCNQ5O X-Received: by 2002:adf:cd03:: with SMTP id w3mr17446972wrm.191.1580752752037; Mon, 03 Feb 2020 09:59:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwsRwpqT+D64C9O7XOhKblckDEGo1ljqhutKTbpj38iQPTgW7FvqpjKRRgBfR6bF3+6q3dsCg== X-Received: by 2002:adf:cd03:: with SMTP id w3mr17446964wrm.191.1580752751931; Mon, 03 Feb 2020 09:59:11 -0800 (PST) Received: from localhost.localdomain.com (243.206.broadband12.iol.cz. [90.179.206.243]) by smtp.gmail.com with ESMTPSA id a132sm212274wme.3.2020.02.03.09.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 09:59:11 -0800 (PST) From: Pavel Reichl To: linux-xfs@vger.kernel.org Cc: Pavel Reichl , Dave Chinner Subject: [PATCH v2 6/7] xfs: update excl. lock check for IOLOCK and ILOCK Date: Mon, 3 Feb 2020 18:58:49 +0100 Message-Id: <20200203175850.171689-7-preichl@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200203175850.171689-1-preichl@redhat.com> References: <20200203175850.171689-1-preichl@redhat.com> MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Signed-off-by: Pavel Reichl Suggested-by: Dave Chinner --- fs/xfs/libxfs/xfs_bmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index c3638552b3c0..2d371f87e890 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5829,7 +5829,8 @@ xfs_bmap_collapse_extents( if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; - ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL)); + ASSERT(xfs_is_iolocked(ip, XFS_IOLOCK_EXCL) || + xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, whichfork); @@ -5946,7 +5947,8 @@ xfs_bmap_insert_extents( if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; - ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL)); + ASSERT(xfs_is_iolocked(ip, XFS_IOLOCK_EXCL) || + xfs_is_ilocked(ip, XFS_ILOCK_EXCL)); if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, whichfork); From patchwork Mon Feb 3 17:58:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Reichl X-Patchwork-Id: 11363161 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 90315139A for ; Mon, 3 Feb 2020 17:59:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6614021741 for ; Mon, 3 Feb 2020 17:59:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QxYpmoIb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728278AbgBCR7S (ORCPT ); Mon, 3 Feb 2020 12:59:18 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:37899 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728722AbgBCR7R (ORCPT ); Mon, 3 Feb 2020 12:59:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580752756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c8gyV17fF8ny0rn0MOR+xxMzw+a9FLeaFcxuS3lcHc8=; b=QxYpmoIbVhZp5biHicsRPcfA0g7rXajDumy31H202fmuXCuqJ+fWAWoNi+w9tCDVW8zrKk 9GAv6OShwUuHt9GcQcs/zKkFXxVUsVIhDHlKBreUmyE9YZGxMmsHNILbNKvDOgIzZeTwc3 hyv65V4pnUKnpzPzxJDFWyBHWZ4NN4o= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-397-i6G47d6BPBWUhBlJXx3prg-1; Mon, 03 Feb 2020 12:59:14 -0500 X-MC-Unique: i6G47d6BPBWUhBlJXx3prg-1 Received: by mail-wr1-f69.google.com with SMTP id t3so8602737wrm.23 for ; Mon, 03 Feb 2020 09:59:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c8gyV17fF8ny0rn0MOR+xxMzw+a9FLeaFcxuS3lcHc8=; b=GOdep/oiVnTv4XmgPr0RFXK27+C0oG5uc0AREyHErdpFvKHcKh+kYPOUcShOCtt1iv j6GNSl/AKVuAD0YYIZGIRVVSyTWVV12YHkiCqYT1SUvCV7QD8zy1tzSCVdhkVZcC9Wft p6Xd/3Os5jxpj6uKGKySAXEA+d09dD9vQnzqmFpqc95UKPOBc9GAkuwSJm4k0fMhAgQQ Q1ZkXKO8SO83M9AyvrhBtf6XqtuBnjyX46pkV1HRA16IPLb76derlqqPjC1VmLVIpCZF +gllLb8mFmhxeEXupjG4dTp6xR6/8J8wNFrdbm2EAeP6yZD9XSWw0OI7vA7RgaTG1d2X qdlg== X-Gm-Message-State: APjAAAV239hN5fNdehSGvEYYE5G0cPEgcNCPA+A9OjnDomUALIANf4TP a9T0xxTYUWFkLhOGH7x1UJQed0sH9L4ZOKRzJ8fdLnos48AwNpcg2jCqYQ+T2O+QrrSb85CKQYr 9jECEU1BuNRzBvIHSWhBT X-Received: by 2002:adf:eb46:: with SMTP id u6mr17306122wrn.239.1580752753052; Mon, 03 Feb 2020 09:59:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzvLUL6idXGwJB6JXJdQf31crio5Mp8JxWn4LfHoRogMKPiVgrySa5w8F2H9yZoLKvMwbEzSw== X-Received: by 2002:adf:eb46:: with SMTP id u6mr17306102wrn.239.1580752752794; Mon, 03 Feb 2020 09:59:12 -0800 (PST) Received: from localhost.localdomain.com (243.206.broadband12.iol.cz. [90.179.206.243]) by smtp.gmail.com with ESMTPSA id a132sm212274wme.3.2020.02.03.09.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 09:59:12 -0800 (PST) From: Pavel Reichl To: linux-xfs@vger.kernel.org Cc: Pavel Reichl , Dave Chinner Subject: [PATCH v2 7/7] xfs: Replace mrlock_t by rw_semaphore Date: Mon, 3 Feb 2020 18:58:50 +0100 Message-Id: <20200203175850.171689-8-preichl@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200203175850.171689-1-preichl@redhat.com> References: <20200203175850.171689-1-preichl@redhat.com> MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Remove mrlock_t as it does not provide any extra value over rw_semaphores. Make i_lock and i_mmaplock native rw_semaphores and replace mr*() functions with native rwsem calls. Signed-off-by: Pavel Reichl Suggested-by: Dave Chinner --- fs/xfs/mrlock.h | 78 ---------------------------------------------- fs/xfs/xfs_inode.c | 65 +++++++++++--------------------------- fs/xfs/xfs_inode.h | 7 +++-- fs/xfs/xfs_iops.c | 4 +-- fs/xfs/xfs_linux.h | 1 - fs/xfs/xfs_super.c | 6 ++-- 6 files changed, 27 insertions(+), 134 deletions(-) delete mode 100644 fs/xfs/mrlock.h diff --git a/fs/xfs/mrlock.h b/fs/xfs/mrlock.h deleted file mode 100644 index 79155eec341b..000000000000 --- a/fs/xfs/mrlock.h +++ /dev/null @@ -1,78 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2000-2006 Silicon Graphics, Inc. - * All Rights Reserved. - */ -#ifndef __XFS_SUPPORT_MRLOCK_H__ -#define __XFS_SUPPORT_MRLOCK_H__ - -#include - -typedef struct { - struct rw_semaphore mr_lock; -#if defined(DEBUG) || defined(XFS_WARN) - int mr_writer; -#endif -} mrlock_t; - -#if defined(DEBUG) || defined(XFS_WARN) -#define mrinit(mrp, name) \ - do { (mrp)->mr_writer = 0; init_rwsem(&(mrp)->mr_lock); } while (0) -#else -#define mrinit(mrp, name) \ - do { init_rwsem(&(mrp)->mr_lock); } while (0) -#endif - -#define mrlock_init(mrp, t,n,s) mrinit(mrp, n) -#define mrfree(mrp) do { } while (0) - -static inline void mraccess_nested(mrlock_t *mrp, int subclass) -{ - down_read_nested(&mrp->mr_lock, subclass); -} - -static inline void mrupdate_nested(mrlock_t *mrp, int subclass) -{ - down_write_nested(&mrp->mr_lock, subclass); -#if defined(DEBUG) || defined(XFS_WARN) - mrp->mr_writer = 1; -#endif -} - -static inline int mrtryaccess(mrlock_t *mrp) -{ - return down_read_trylock(&mrp->mr_lock); -} - -static inline int mrtryupdate(mrlock_t *mrp) -{ - if (!down_write_trylock(&mrp->mr_lock)) - return 0; -#if defined(DEBUG) || defined(XFS_WARN) - mrp->mr_writer = 1; -#endif - return 1; -} - -static inline void mrunlock_excl(mrlock_t *mrp) -{ -#if defined(DEBUG) || defined(XFS_WARN) - mrp->mr_writer = 0; -#endif - up_write(&mrp->mr_lock); -} - -static inline void mrunlock_shared(mrlock_t *mrp) -{ - up_read(&mrp->mr_lock); -} - -static inline void mrdemote(mrlock_t *mrp) -{ -#if defined(DEBUG) || defined(XFS_WARN) - mrp->mr_writer = 0; -#endif - downgrade_write(&mrp->mr_lock); -} - -#endif /* __XFS_SUPPORT_MRLOCK_H__ */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 328a3b4ffbd2..ca54e2e151c0 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -191,14 +191,15 @@ xfs_ilock( } if (lock_flags & XFS_MMAPLOCK_EXCL) - mrupdate_nested(&ip->i_mmaplock, XFS_MMAPLOCK_DEP(lock_flags)); + down_write_nested(&ip->i_mmaplock, + XFS_MMAPLOCK_DEP(lock_flags)); else if (lock_flags & XFS_MMAPLOCK_SHARED) - mraccess_nested(&ip->i_mmaplock, XFS_MMAPLOCK_DEP(lock_flags)); + down_read_nested(&ip->i_mmaplock, XFS_MMAPLOCK_DEP(lock_flags)); if (lock_flags & XFS_ILOCK_EXCL) - mrupdate_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); + down_write_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); else if (lock_flags & XFS_ILOCK_SHARED) - mraccess_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); + down_read_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); } /* @@ -242,27 +243,27 @@ xfs_ilock_nowait( } if (lock_flags & XFS_MMAPLOCK_EXCL) { - if (!mrtryupdate(&ip->i_mmaplock)) + if (!down_write_trylock(&ip->i_mmaplock)) goto out_undo_iolock; } else if (lock_flags & XFS_MMAPLOCK_SHARED) { - if (!mrtryaccess(&ip->i_mmaplock)) + if (!down_read_trylock(&ip->i_mmaplock)) goto out_undo_iolock; } if (lock_flags & XFS_ILOCK_EXCL) { - if (!mrtryupdate(&ip->i_lock)) + if (!down_write_trylock(&ip->i_lock)) goto out_undo_mmaplock; } else if (lock_flags & XFS_ILOCK_SHARED) { - if (!mrtryaccess(&ip->i_lock)) + if (!down_read_trylock(&ip->i_lock)) goto out_undo_mmaplock; } return 1; out_undo_mmaplock: if (lock_flags & XFS_MMAPLOCK_EXCL) - mrunlock_excl(&ip->i_mmaplock); + up_write(&ip->i_mmaplock); else if (lock_flags & XFS_MMAPLOCK_SHARED) - mrunlock_shared(&ip->i_mmaplock); + up_read(&ip->i_mmaplock); out_undo_iolock: if (lock_flags & XFS_IOLOCK_EXCL) up_write(&VFS_I(ip)->i_rwsem); @@ -309,14 +310,14 @@ xfs_iunlock( up_read(&VFS_I(ip)->i_rwsem); if (lock_flags & XFS_MMAPLOCK_EXCL) - mrunlock_excl(&ip->i_mmaplock); + up_write(&ip->i_mmaplock); else if (lock_flags & XFS_MMAPLOCK_SHARED) - mrunlock_shared(&ip->i_mmaplock); + up_read(&ip->i_mmaplock); if (lock_flags & XFS_ILOCK_EXCL) - mrunlock_excl(&ip->i_lock); + up_write(&ip->i_lock); else if (lock_flags & XFS_ILOCK_SHARED) - mrunlock_shared(&ip->i_lock); + up_read(&ip->i_lock); trace_xfs_iunlock(ip, lock_flags, _RET_IP_); } @@ -335,9 +336,9 @@ xfs_ilock_demote( ~(XFS_IOLOCK_EXCL|XFS_MMAPLOCK_EXCL|XFS_ILOCK_EXCL)) == 0); if (lock_flags & XFS_ILOCK_EXCL) - mrdemote(&ip->i_lock); + downgrade_write(&ip->i_lock); if (lock_flags & XFS_MMAPLOCK_EXCL) - mrdemote(&ip->i_mmaplock); + downgrade_write(&ip->i_mmaplock); if (lock_flags & XFS_IOLOCK_EXCL) downgrade_write(&VFS_I(ip)->i_rwsem); @@ -345,34 +346,6 @@ xfs_ilock_demote( } #if defined(DEBUG) || defined(XFS_WARN) -int -xfs_isilocked( - xfs_inode_t *ip, - uint lock_flags) -{ - if (lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) { - if (!(lock_flags & XFS_ILOCK_SHARED)) - return !!ip->i_lock.mr_writer; - return rwsem_is_locked(&ip->i_lock.mr_lock); - } - - if (lock_flags & (XFS_MMAPLOCK_EXCL|XFS_MMAPLOCK_SHARED)) { - if (!(lock_flags & XFS_MMAPLOCK_SHARED)) - return !!ip->i_mmaplock.mr_writer; - return rwsem_is_locked(&ip->i_mmaplock.mr_lock); - } - - if (lock_flags & (XFS_IOLOCK_EXCL|XFS_IOLOCK_SHARED)) { - if (!(lock_flags & XFS_IOLOCK_SHARED)) - return !debug_locks || - lockdep_is_held_type(&VFS_I(ip)->i_rwsem, 0); - return rwsem_is_locked(&VFS_I(ip)->i_rwsem); - } - - ASSERT(0); - return 0; -} - static inline bool __xfs_is_ilocked( struct rw_semaphore *rwsem, @@ -401,7 +374,7 @@ xfs_is_ilocked( struct xfs_inode *ip, int lock_flags) { - return __xfs_is_ilocked(&ip->i_lock.mr_lock, + return __xfs_is_ilocked(&ip->i_lock, (lock_flags & XFS_ILOCK_SHARED), (lock_flags & XFS_ILOCK_EXCL)); } @@ -411,7 +384,7 @@ xfs_is_mmaplocked( struct xfs_inode *ip, int lock_flags) { - return __xfs_is_ilocked(&ip->i_mmaplock.mr_lock, + return __xfs_is_ilocked(&ip->i_mmaplock, (lock_flags & XFS_MMAPLOCK_SHARED), (lock_flags & XFS_MMAPLOCK_EXCL)); } diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 6ba575f35c1f..d7c77d1d7930 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -9,6 +9,8 @@ #include "xfs_inode_buf.h" #include "xfs_inode_fork.h" +#include + /* * Kernel only inode definitions */ @@ -39,8 +41,8 @@ typedef struct xfs_inode { /* Transaction and locking information. */ struct xfs_inode_log_item *i_itemp; /* logging information */ - mrlock_t i_lock; /* inode lock */ - mrlock_t i_mmaplock; /* inode mmap IO lock */ + struct rw_semaphore i_lock; /* inode lock */ + struct rw_semaphore i_mmaplock; /* inode mmap IO lock */ atomic_t i_pincount; /* inode pin count */ /* @@ -416,7 +418,6 @@ void xfs_ilock(xfs_inode_t *, uint); int xfs_ilock_nowait(xfs_inode_t *, uint); void xfs_iunlock(xfs_inode_t *, uint); void xfs_ilock_demote(xfs_inode_t *, uint); -int xfs_isilocked(xfs_inode_t *, uint); bool xfs_is_ilocked(struct xfs_inode *, int); bool xfs_is_mmaplocked(struct xfs_inode *, int); bool xfs_is_iolocked(struct xfs_inode *, int); diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 67a0f940b30e..bb3a2a57f04a 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1319,9 +1319,9 @@ xfs_setup_inode( */ lockdep_set_class(&inode->i_rwsem, &inode->i_sb->s_type->i_mutex_dir_key); - lockdep_set_class(&ip->i_lock.mr_lock, &xfs_dir_ilock_class); + lockdep_set_class(&ip->i_lock, &xfs_dir_ilock_class); } else { - lockdep_set_class(&ip->i_lock.mr_lock, &xfs_nondir_ilock_class); + lockdep_set_class(&ip->i_lock, &xfs_nondir_ilock_class); } /* diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index 8738bb03f253..921a3eb093ed 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h @@ -22,7 +22,6 @@ typedef __u32 xfs_nlink_t; #include "xfs_types.h" #include "kmem.h" -#include "mrlock.h" #include #include diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 760901783944..1289ce1f4e9e 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -661,10 +661,8 @@ xfs_fs_inode_init_once( atomic_set(&ip->i_pincount, 0); spin_lock_init(&ip->i_flags_lock); - mrlock_init(&ip->i_mmaplock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER, - "xfsino", ip->i_ino); - mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER, - "xfsino", ip->i_ino); + init_rwsem(&ip->i_mmaplock); + init_rwsem(&ip->i_lock); } /*