From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA053C433EF for ; Thu, 23 Jun 2022 18:08:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 354D38E0175; Thu, 23 Jun 2022 14:08:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 329668E0144; Thu, 23 Jun 2022 14:08:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C8A88E0175; Thu, 23 Jun 2022 14:08:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0CDC48E0144 for ; Thu, 23 Jun 2022 14:08:17 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D1DCA60E91 for ; Thu, 23 Jun 2022 18:08:16 +0000 (UTC) X-FDA: 79610284992.29.7E33DDD Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf24.hostedemail.com (Postfix) with ESMTP id 53440180033 for ; Thu, 23 Jun 2022 18:08:16 +0000 (UTC) Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25NHumGr015920 for ; Thu, 23 Jun 2022 11:08:15 -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=KS1xFKQqVwoSACeYU9DEyyuaT6PkVs/zrO98r3Io/rM=; b=MwqMjStCOZv8f/liIHA0oXhGf7tRXGnB+GR0sJrR1fXE93libJ6tqbnu6U2IZaGOBjRo yFw1wMB1o9XAEgemaHbGQu36YB5vhjcBkm9HwBsknRDDgihq8mMfWGgXUwTFRbgbc4sL G+NX5bWaIFKgvXP9m3DnhKZPt7Oz4pU/plw= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3gv51n919b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 23 Jun 2022 11:08:15 -0700 Received: from twshared14818.18.frc3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 23 Jun 2022 11:08:13 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 80EC910C5DC5B; Thu, 23 Jun 2022 10:52:00 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , , , , , Christoph Hellwig , Christian Brauner Subject: [RESEND PATCH v9 07/14] fs: Add check for async buffered writes to generic_write_checks Date: Thu, 23 Jun 2022 10:51:50 -0700 Message-ID: <20220623175157.1715274-8-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220623175157.1715274-1-shr@fb.com> References: <20220623175157.1715274-1-shr@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: KxVkfGHsDtNZ9ouSY34e2Bv6F83KesGj X-Proofpoint-ORIG-GUID: KxVkfGHsDtNZ9ouSY34e2Bv6F83KesGj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-23_07,2022-06-23_01,2022-06-22_01 ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=MwqMjStC; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf24.hostedemail.com: domain of "prvs=71737354e2=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=71737354e2=shr@fb.com" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656007696; a=rsa-sha256; cv=none; b=4GNOzw1rnqHdWqsOjf1R0eu4wEjRIHAn+UP+Vozh9ZEStJ5iENpwZ9Rj9EovZX266aCjfC CJEbyt/xtYtyUlIV+nq481gj+ekcIAq8rcgayuSl0BVJYAjrtDrnM33zqNngiLUj4DnhCY li+31DwJUY8o8ch+Z8ifP2rOYJpXJFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656007696; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KS1xFKQqVwoSACeYU9DEyyuaT6PkVs/zrO98r3Io/rM=; b=HVMCouXJg6gznZmgMbntt2RcFHi7QSxsZcFK1VQy+p11mp3c+NvSX5jZHWMHs95Rv7DDvw cVlSPUVU9RqQlzthhXAuPnuozm+pgoJCpfBrruwohFrtNKCa6X0nqXeOQKTo2SqnSuXM+b WLu15VRcQaZbE8aCE+v3kbvJbnpof68= X-Stat-Signature: ygu7odfpb9fyawn61mhme5nxp6oye6by X-Rspamd-Server: rspam08 X-Rspam-User: X-Rspamd-Queue-Id: 53440180033 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=MwqMjStC; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf24.hostedemail.com: domain of "prvs=71737354e2=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=71737354e2=shr@fb.com" X-HE-Tag: 1656007696-500802 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: Christian Brauner (Microsoft) --- 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 b1b1cdfee9d3..a1f4d45c2406 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1649,7 +1649,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 9ad5e3520fae..bc84847c201e 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