From patchwork Wed Feb 28 11:17:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 10247289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4C5E260211 for ; Wed, 28 Feb 2018 11:19:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F40928BAD for ; Wed, 28 Feb 2018 11:19:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32ACB28CAA; Wed, 28 Feb 2018 11:19:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5FDA928BAD for ; Wed, 28 Feb 2018 11:19:00 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1SBH8Xw124971; Wed, 28 Feb 2018 11:18:18 GMT Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2gdqnk1050-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Feb 2018 11:18:18 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w1SBIHJu017976 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 28 Feb 2018 11:18:17 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1eqzkX-0000fL-6E; Wed, 28 Feb 2018 03:18:17 -0800 Received: from userv0021.oracle.com ([156.151.31.71]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1eqzkV-0000dk-2F for ocfs2-devel@oss.oracle.com; Wed, 28 Feb 2018 03:18:15 -0800 Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w1SBIET4031302 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL) for ; Wed, 28 Feb 2018 11:18:14 GMT Received: from pps.filterd (userp2040.oracle.com [127.0.0.1]) by userp2040.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1SBGvJX007715 for ; Wed, 28 Feb 2018 11:18:14 GMT Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by userp2040.oracle.com with ESMTP id 2gdtur8hww-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 28 Feb 2018 11:18:13 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B1BE9AD98; Wed, 28 Feb 2018 11:18:10 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 986DA1E0501; Wed, 28 Feb 2018 12:18:09 +0100 (CET) From: Jan Kara To: ocfs2-devel@oss.oracle.com Date: Wed, 28 Feb 2018 12:17:59 +0100 Message-Id: <20180228111802.23967-4-jack@suse.cz> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228111802.23967-1-jack@suse.cz> References: <20180228111802.23967-1-jack@suse.cz> X-CLX-Shades: MLX X-CLX-Response: 1TFkXGxMYEQpMehccGhEKWU0XZ2ZyEQpZSRcacRoQGncGGx0YcRsaHhAadwY YGgYaEQpZXhdobnkRCklGF0VYS0lGT3VaWEVOX0leQ0VEGXVPSxEKQ04XYkhIc2RPckkbEktAUh xsQRNbXW0TZ38cbW5kbE5jbFwRClhcFx8EGgQbGBwHS0sYGB8eTxkFGxoEGxoaBB4SBBsQGx4aH xoRCl5ZF3hQbnl4EQpNXBcZHhkRCkxaF2hpQk1dEQpNThdoEQpMRhdsa2sRCkNaFxsTHwQbGR8E GBgaBBsfEQpCXhcbEQpESRcfEQpCRhdmE15pGmMTbmIdfREKQlwXGhEKQkUXYAFhe1tae0ABYm0 RCkJOF2UaeBsFBXBze1NZEQpCTBdtZHhifE97YUNfXxEKQmwXaX4YfEBfSBxOa1IRCkJAF29MYW JdfWhSb0liEQpCWBdifW95AU8YGXBwexEKWlgXGxEKcGcXbV8dSRoYTX9abHMQGRoRCnBoF2hkZ R5JYn8cBWZOEBkaEQpwaBdjeU9/a1paSEddUxAZGhEKcGgXbF5nQ0FGYWVYXU8QGRoRCnBoF29r QUlNem5pZ0FCEBkaEQpwaBdlQmZTWh1OU3p9GhAZGhEKcGwXYkBabVBBQ2NwX20QGRoRCm1+Fxo RClhNF0sRIA== X-PDR: PASS X-Source-IP: 195.135.220.15 X-ServerName: mx2.suse.de X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:137.65.0.0/16 ip4:151.155.28.0/17 ip4:149.44.0.0/16 ip4:147.2.0.0/16 ip4:164.99.0.0/16 ip4:130.57.0.0/16 ip4:192.31.114.0/24 ip4:195.135.221.0/24 ip4:195.135.220.0/24 ip4:69.7.179.0/24 ip4:150.215.214.0/24 include:mailcontrol.com ~all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8817 signatures=668681 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=60 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=192 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=679 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802280137 X-Spam: Clean Cc: Jan Kara Subject: [Ocfs2-devel] [PATCH 3/6] ocfs2: Fix deadlock during umount 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=5900 definitions=8817 signatures=668681 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 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-1711220000 definitions=main-1802280137 X-Virus-Scanned: ClamAV using ClamSMTP When ocfs2 quota recovery races with umount, it can happen that umount waits for recovery to finish while quota recovery waits to grab s_umount semaphore held by umount. This results in a deadlock. Fix the problem by not grabbing s_umount semaphore during quota recovery. We are protected from disabling of quotas by the fact that quotas gets disabled only on umount and that happens after recovery is disabled. Reported-by: Shichangkuo Signed-off-by: Jan Kara --- fs/ocfs2/quota_local.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c index 16c42ed0dca8..d60d744bbcb2 100644 --- a/fs/ocfs2/quota_local.c +++ b/fs/ocfs2/quota_local.c @@ -454,8 +454,10 @@ struct ocfs2_quota_recovery *ocfs2_begin_quota_recovery( /* Sync changes in local quota file into global quota file and * reinitialize local quota file. - * The function expects local quota file to be already locked and - * s_umount locked in shared mode. */ + * The function expects local quota file to be already locked. Quota is + * disabled only during umount after disabling recovery so we are protected + * against that. + */ static int ocfs2_recover_local_quota_file(struct inode *lqinode, int type, struct ocfs2_quota_recovery *rec) @@ -586,7 +588,6 @@ int ocfs2_finish_quota_recovery(struct ocfs2_super *osb, { unsigned int ino[OCFS2_MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE, LOCAL_GROUP_QUOTA_SYSTEM_INODE }; - struct super_block *sb = osb->sb; struct ocfs2_local_disk_dqinfo *ldinfo; struct buffer_head *bh; handle_t *handle; @@ -598,7 +599,6 @@ int ocfs2_finish_quota_recovery(struct ocfs2_super *osb, printk(KERN_NOTICE "ocfs2: Finishing quota recovery on device (%s) for " "slot %u\n", osb->dev_str, slot_num); - down_read(&sb->s_umount); for (type = 0; type < OCFS2_MAXQUOTAS; type++) { if (list_empty(&(rec->r_list[type]))) continue; @@ -675,7 +675,6 @@ int ocfs2_finish_quota_recovery(struct ocfs2_super *osb, break; } out: - up_read(&sb->s_umount); kfree(rec); return status; } @@ -837,9 +836,10 @@ static int ocfs2_local_free_info(struct super_block *sb, int type) ocfs2_release_local_quota_bitmaps(&oinfo->dqi_chunk); /* - * s_umount held in exclusive mode protects us against racing with - * recovery thread... + * Recovery should be already disabled at this point so that we cannot + * race with quota recovery. */ + WARN_ON(!OCFS2_SB(sb)->disable_recovery); if (oinfo->dqi_rec) { ocfs2_free_quota_recovery(oinfo->dqi_rec); mark_clean = 0;