Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1329033ybl; Wed, 4 Dec 2019 22:46:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwg3Tj4ouwNOkKU6ECKGWPtCeYlto/0vajvi936c5cMlIaETxNbvg6W+Q/ZJ1z3Gh6u9n4V X-Received: by 2002:aca:c415:: with SMTP id u21mr6035337oif.49.1575528416840; Wed, 04 Dec 2019 22:46:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575528416; cv=none; d=google.com; s=arc-20160816; b=oA2us5S7WYnsJyqlbOkQbEsc8rD609TnwPRnXXq/knjYtXAN42RcuXrqfxT1B/6vmw YHi9q2xYPvGfSXzKRLlbFXrOxnIC0H1IzVRaQb63zajqlRXrrgUlfn9R4Xsdzsva962E NBhUeaI+XSh69lIfR1k8HdwDkU1ArMc7h9KvNzqZqCsb/ldtlCdMtsSWHHMNOT7ZEd4C LHbcSuGQNkUCyGdCK8epNaxg0mtON+YCipb81jE4fZu9oLaILrAUdbbYxXTZjZ0mKww2 XCCBUi/tYXi1op13yW6LocP1PxZifrmtITu4fMOHlyuDHdBCSBT6rhBSHwyrGb9U39AF +SAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from; bh=EPSN1i+U9GfTDSi5TjsVLnpQcGp8yGAZd3d4CmBJlc0=; b=r3PzZNTyQED5DRSVdj7mOVT+KNm5lsHGhF4ko3j6i7z88DxyE5zUWvHnd1JPWlxZYg NUdA9XWIRcdEpbr2Y1jrok+gnVbqO+znfvaV7oqlEpbfqtSZUjyqzrjUwMsqm4xnTN3u kx6Y82166Ls3Qe8txTWIakOSEonAJ05Dq+syxYpyRYBNvLNFL/L3kUvxm9iwbVRGfWuC OUtW5kqdXghacbt/pUF0YFbhn+RHRplMAeiL8KJJ0qY8pxHEbT82jI7CIX3vCj2lpPug MhVSgkkf03Q0vjoK1IZDhTDHg3exHP9lBjMgnPxxoBgLJ+QnPHlUvKnYRtdYPBSjkB0c Nhvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e103si4570076ote.305.2019.12.04.22.46.46; Wed, 04 Dec 2019 22:46:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726069AbfLEGqh (ORCPT + 99 others); Thu, 5 Dec 2019 01:46:37 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44032 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725974AbfLEGqg (ORCPT ); Thu, 5 Dec 2019 01:46:36 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xB56hN3o152468 for ; Thu, 5 Dec 2019 01:46:35 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wpuhv39yc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 05 Dec 2019 01:46:35 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Dec 2019 06:46:33 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 5 Dec 2019 06:46:31 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xB56kUiC46268802 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Dec 2019 06:46:30 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AFF7CA4040; Thu, 5 Dec 2019 06:46:30 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 039D9A4051; Thu, 5 Dec 2019 06:46:29 +0000 (GMT) Received: from dhcp-9-199-159-163.in.ibm.com (unknown [9.199.159.163]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 5 Dec 2019 06:46:28 +0000 (GMT) From: Ritesh Harjani To: jack@suse.cz, tytso@mit.edu, linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, mbobrowski@mbobrowski.org, riteshh@linux.ibm.com, joseph.qi@linux.alibaba.com Subject: [PATCHv4 1/3] ext4: fix ext4_dax_read/write inode locking sequence for IOCB_NOWAIT Date: Thu, 5 Dec 2019 12:16:22 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191205064624.13419-1-riteshh@linux.ibm.com> References: <20191205064624.13419-1-riteshh@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19120506-0028-0000-0000-000003C52B07 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120506-0029-0000-0000-000024884BE9 Message-Id: <20191205064624.13419-2-riteshh@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-12-05_01:2019-12-04,2019-12-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 mlxlogscore=928 phishscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 suspectscore=3 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912050052 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Apparently our current rwsem code doesn't like doing the trylock, then lock for real scheme. So change our dax read/write methods to just do the trylock for the RWF_NOWAIT case. This seems to fix AIM7 regression in some scalable filesystems upto ~25% in some cases. Claimed in commit 942491c9e6d6 ("xfs: fix AIM7 regression") Reviewed-by: Jan Kara Reviewed-by: Matthew Bobrowski Signed-off-by: Ritesh Harjani --- fs/ext4/file.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 6a7293a5cda2..977ac58dc718 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -88,9 +88,10 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) struct inode *inode = file_inode(iocb->ki_filp); ssize_t ret; - if (!inode_trylock_shared(inode)) { - if (iocb->ki_flags & IOCB_NOWAIT) + if (iocb->ki_flags & IOCB_NOWAIT) { + if (!inode_trylock_shared(inode)) return -EAGAIN; + } else { inode_lock_shared(inode); } /* @@ -487,9 +488,10 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) bool extend = false; struct inode *inode = file_inode(iocb->ki_filp); - if (!inode_trylock(inode)) { - if (iocb->ki_flags & IOCB_NOWAIT) + if (iocb->ki_flags & IOCB_NOWAIT) { + if (!inode_trylock(inode)) return -EAGAIN; + } else { inode_lock(inode); } -- 2.21.0