From patchwork Tue Sep 10 17:30:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxiao Bi X-Patchwork-Id: 11139949 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 28805112B for ; Tue, 10 Sep 2019 17:31:41 +0000 (UTC) Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (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 E741D2082C for ; Tue, 10 Sep 2019 17:31:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="pIm5F2Fx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E741D2082C Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=ocfs2-devel-bounces@oss.oracle.com Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x8AHT0ae147987; Tue, 10 Sep 2019 17:31:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : date : message-id : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : mime-version : content-type : content-transfer-encoding : sender; s=corp-2019-08-05; bh=8SIs8If3xrDSzJq2/F54Cgb6V25Wa3unO6j23sTjOfc=; b=pIm5F2FxYQI+oP6J4J3Tm97vNe4/QqvhEOCoyA2uYLxyBrK+K+PsSWx4EyP6nE00Nj+f qER7ZCwA8lT6aqK/1C8lAEHcjzSIVKrIMR20obML6tRlkbFelVv/2dwCphFuqoPDYpAy 8D/H8Z+OS3cZqYl/08zNPVfYnkN6NSHPxtD5ys/SqS3GYl8/CqLgQmGRJH5uChaUIYKZ jy7nXiaaKMXAEmXXLynEAsmCQOh/7bHsr7sWaHRXzZuAN4f2t2UAd5aR4ARki7VToiw9 6HHDZcTb7FhpBiW54GwKMZKvjDl262rRdTdEkn861ljR7X64aVFKdfJFLyJHwShbnXsf yw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2uw1jkcyw5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Sep 2019 17:31:09 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x8AHO1aD185356; Tue, 10 Sep 2019 17:31:08 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userp3030.oracle.com with ESMTP id 2uxd6csqgy-1 (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO); Tue, 10 Sep 2019 17:31:08 +0000 Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1i7jyt-0003rR-1M; Tue, 10 Sep 2019 10:31:07 -0700 Received: from aserp3020.oracle.com ([141.146.126.70]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1i7jyW-0003qa-A1 for ocfs2-devel@oss.oracle.com; Tue, 10 Sep 2019 10:30:44 -0700 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x8AHNu9H150739 for ; Tue, 10 Sep 2019 17:30:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3020.oracle.com with ESMTP id 2uwqku132k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 10 Sep 2019 17:30:44 +0000 Received: from aserp3020.oracle.com (aserp3020.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x8AHUhX5171356 for ; Tue, 10 Sep 2019 17:30:43 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2uwqku1321-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Sep 2019 17:30:43 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x8AHUhLA027065; Tue, 10 Sep 2019 17:30:43 GMT Received: from jubi-laptop.us.oracle.com (/10.11.36.22) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Sep 2019 10:30:42 -0700 From: Junxiao Bi To: ocfs2-devel@oss.oracle.com Date: Tue, 10 Sep 2019 10:30:46 -0700 Message-Id: <20190910173046.27360-1-junxiao.bi@oracle.com> X-Mailer: git-send-email 2.17.1 Subject: [Ocfs2-devel] [PATCH] ocfs2: protect get_block with inode cluster lock X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9376 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909100168 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9376 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909100169 Inode cluster lock should be acquired to avoid extent tree changed by other cluster nodes. Signed-off-by: Junxiao Bi --- fs/ocfs2/aops.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index a4c905d6b575..5ae7253d04b0 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -127,9 +127,15 @@ static int ocfs2_lock_get_block(struct inode *inode, sector_t iblock, int ret = 0; struct ocfs2_inode_info *oi = OCFS2_I(inode); + ret = ocfs2_inode_lock(inode, NULL, 0); + if (ret) { + mlog_errno(ret); + return ret; + } down_read(&oi->ip_alloc_sem); ret = ocfs2_get_block(inode, iblock, bh_result, create); up_read(&oi->ip_alloc_sem); + ocfs2_inode_unlock(inode, 0); return ret; }