From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CC94CCA473 for ; Wed, 1 Jun 2022 21:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231232AbiFAVHN (ORCPT ); Wed, 1 Jun 2022 17:07:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231133AbiFAVHM (ORCPT ); Wed, 1 Jun 2022 17:07:12 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E8F36B7CA for ; Wed, 1 Jun 2022 14:07:11 -0700 (PDT) Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 251J2w3e008379 for ; Wed, 1 Jun 2022 14:07:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=Yt6TEqCrJwA/g0p7FZ8GGE3PH7HsqaIrUF33gFTVMx4=; b=h6jD3sBZFnEGkI/etm+Lugt7k80ZUCeu0gtuZGp8f4QKXCk6kbJPx6hEP8r6h/IMHpOX wzJN+WtbiTYVTCBt6r/LCo3tZ7Q2XWSpeJH73CN9CicjIsp14nZKnqsPWLRaqKUSY8/Y 1jJLjTHIGzAIab7++CunsZfg/LVlVuyXH0M= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3ge5vcma46-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 01 Jun 2022 14:07:10 -0700 Received: from twshared10560.18.frc3.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:21d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 1 Jun 2022 14:07:09 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id DBCE5FEB23A3; Wed, 1 Jun 2022 14:01:42 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , , , , Christoph Hellwig Subject: [PATCH v7 07/15] fs: Add check for async buffered writes to generic_write_checks Date: Wed, 1 Jun 2022 14:01:33 -0700 Message-ID: <20220601210141.3773402-8-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220601210141.3773402-1-shr@fb.com> References: <20220601210141.3773402-1-shr@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: Lrkp87_SvKFiooYu-Xgv1TW1qmG88a4Q X-Proofpoint-ORIG-GUID: Lrkp87_SvKFiooYu-Xgv1TW1qmG88a4Q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-01_08,2022-06-01_01,2022-02-23_01 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This introduces the flag FMODE_BUF_WASYNC. If devices support async buffered writes, this flag can be set. It also modifies the check in generic_write_checks to take async buffered writes into consideration. Signed-off-by: Stefan Roesch Reviewed-by: Christoph Hellwig --- fs/read_write.c | 4 +++- include/linux/fs.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/read_write.c b/fs/read_write.c index e643aec2b0ef..175d98713b9a 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1633,7 +1633,9 @@ int generic_write_checks_count(struct kiocb *iocb, = loff_t *count) if (iocb->ki_flags & IOCB_APPEND) iocb->ki_pos =3D i_size_read(inode); =20 - if ((iocb->ki_flags & IOCB_NOWAIT) && !(iocb->ki_flags & IOCB_DIRECT)) + if ((iocb->ki_flags & IOCB_NOWAIT) && + !((iocb->ki_flags & IOCB_DIRECT) || + (file->f_mode & FMODE_BUF_WASYNC))) return -EINVAL; =20 return generic_write_check_limits(iocb->ki_filp, iocb->ki_pos, count); diff --git a/include/linux/fs.h b/include/linux/fs.h index 01403e637271..bdf1ce48a458 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -180,6 +180,9 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t= offset, /* File supports async buffered reads */ #define FMODE_BUF_RASYNC ((__force fmode_t)0x40000000) =20 +/* File supports async nowait buffered writes */ +#define FMODE_BUF_WASYNC ((__force fmode_t)0x80000000) + /* * Attribute flags. These should be or-ed together to figure out what * has been changed! --=20 2.30.2