From patchwork Mon Sep 30 12:54:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13816293 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 937AA18F2EF; Mon, 30 Sep 2024 12:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700989; cv=fail; b=HRKFt6s6Le1KQgdaXnyg573MhL9cPVZamkiuB96jiGIR9wdJOzq5W+VHi/JaQrPMOpzfiHZVR+0qlkFAwQTUDxkElj046IFFbA7pbcKn9oCq1fycFrbPmZQ4ecpSvCYN6f3+vW8bm0OXMwSA3ZtYOZUP4DLqGkqXiWD1FF+cmuQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700989; c=relaxed/simple; bh=FHkVaPHUZqBl4IpCmhMM+Bp+V3PLQFqG7g969l6GUNQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=g/DZWbo/mQZ3cZj0rNkFf+TgxIq/PO3gDnQQzMaTnwumhbEW1095Iiih7nf+fv+86B0Xbm/us4Qkuh83QJ3kLUlhTgbKXTnNepyVQXm+Wig7UVKFEauazKREobGwl1HlM9ABIYVAnOaigrGZa4fjez8rxQm5cFCmyywlN3/Omr0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=IQvPc4BS; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=MecyCjAG; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="IQvPc4BS"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="MecyCjAG" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48UCS4NO024759; Mon, 30 Sep 2024 12:54:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=iws4QJnNk7qazHfaWJ4rEIt4BmfzF9We8vbjjiddLNU=; b= IQvPc4BSD9MwEme67R0fIyofIzEavNtBa4R8ncM1owDCPyTbOPZmziJ9Jfqzk8tV oyPwsvUMfsL5L9c7G7QHfwQh/yTjQvhwL9WtKFlWK7S6XTPgpPvrXvuN8o4glBcl Ki1bIhyIrb/m9vq6WHftFxKnQsccYHfEfu+xciBUYeebaN1HAD/r78dPaPJvzEza vNO6p3f5Y/P1bcGkQDfOlKWOx0k1xW1GXKVGNED/G1jXA4FRfAb5C2eeTY93yecc Ww8rdhcyFE0iB4usJ80SkJJ8mUWoKqyexvq8CyGQordLrnAFsX4CcQexNSA6+apM l09sDqD5Hs0GvMwj0EEPfA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x87d37tq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:54:55 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48UCFfhS012508; Mon, 30 Sep 2024 12:54:55 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2040.outbound.protection.outlook.com [104.47.70.40]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x885r6sm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:54:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t7kERpwEOZfJLf0OdLNAx7CBK29i5ckdhgEVLXrIpm+VvJrcz4LglK3ILD4EMvmx64tpbiJLUgLpGHFXbPZ0dHY6394o4OB2PEQCEXB/ud/ust2mGGpXVPXuBavuS0DPwtPpBrOnhQyKlMhof+lsYzIPh31lQ+PEXaw7nm7jlHDWl/MCyj3dqG8C6fWJEdit5qLZkX0+SXb2IFAlYk4hP6/2kyhcKNgY98t6JMWq1QQI9ZeAlPRoAyOHLrucqQiqjgAPi3n71ZBXEo+vgUOWiznGs6pigYLfVIPxWsuZ2wqlArzUXb8old3ThyVkQwCtr5jhyqo97DtdpYcTLZemzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iws4QJnNk7qazHfaWJ4rEIt4BmfzF9We8vbjjiddLNU=; b=tfOP6EzIYKQa8Jmz2ehOwgO+BElsrRB34NSckn7IzMWyzs6vHYvCq/IYQRVPgW2pk6vFrvnVZF9sWVH75ub/gc2QK2oo7ggrlRZ+cCPy5PGbtr5Q5JZe6oRsyvA8OCYwz//ncWGuivU90LdSwJNYC6/P/S6zLbCmV2132YKA301aKMcuwrk5qqoYoxsaufJCbhluc9vASQQiYo8R6FzG1lQ1UWvDRa3NE3s+bu6o8BtHEgnwGmqEAcQJjGglSm/a3EmN9fqHwq7N9q39cC8F/CwlxJqCsI72wK4eCjCDqdvyBp/9poV9PaqdXOD/idcD6I7AUIbMXgJXJbznZ1w4Qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iws4QJnNk7qazHfaWJ4rEIt4BmfzF9We8vbjjiddLNU=; b=MecyCjAGVSyv5zZTSKbGYJhuGjZwqgk7g5aUKgMRns0xVlzQKLsmHY5E5lOFLLi9tiiSCpfXvAqmbvATIa5Pf84vQg3puKkIeszUggEH/Iw3K8yTPH9QCnNnGr9kThZYEMuuVKpeC2O+uQmQuXtzGTi9wNiKMOIZDX9hfQsuxi0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by BL3PR10MB6116.namprd10.prod.outlook.com (2603:10b6:208:3bb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Mon, 30 Sep 2024 12:54:52 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.005; Mon, 30 Sep 2024 12:54:52 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v6 1/7] block/fs: Pass an iocb to generic_atomic_write_valid() Date: Mon, 30 Sep 2024 12:54:32 +0000 Message-Id: <20240930125438.2501050-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240930125438.2501050-1-john.g.garry@oracle.com> References: <20240930125438.2501050-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR05CA0041.namprd05.prod.outlook.com (2603:10b6:a03:74::18) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|BL3PR10MB6116:EE_ X-MS-Office365-Filtering-Correlation-Id: db4e2afe-67c2-4d19-20d2-08dce14f1385 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: tG/jYAKr+YUsm0J0a6fUifwpdGj1i+1YWO+SIhb83jjuXvMSUimL0k7r2VfiEPX9MEfaHyPcarNQV3lQdpECcBsIdSKevbjhpLBV/YIAe1iv6N7zZHEKYeDwaiIJJD3KYTW/PrlKpHKTxqmCdgD2JUf6RBMt3zk2ADrokqdRvmNtKbLkSoTiE+e5sAmpU7xOxNo1LL54SvTMcpSTHzRf6CYCd41lmMtSWlPgZ2Ul6WojzsiD4C4eheYmKKRtDf8BKEekOlCX84myxUNr7lwvlKk3onyN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L:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5spyshRV3O2B7pfkwEa0UPVXSmMlWlL1DEu04YrwrEXSs4Qc2pKKRgdB4uXr/UKpG1ShqFgjwaK3gWU7Tu/sNBo62S9ke4BmOjgbY/8A/MVFxjLgkTPtpcORdv+UYaw8/3F7dYjX2PAIj5NSyQw5gVvXJTdau7+M91F6JZfwPFCxtCe1HGNZMfOho3ziIPncQaC8HjttWntqZpBx3Ze2tg94QqqOyTv13YGapoU6TK0t7r88hbyH3fxaSPbmZm/T/wov25UTGX95oU63pnHUdr31ATadEWQAaolbySM24Q4TBROATiAKSlCFffjXerRO/k8m/zOVNqDaNtKTFXI8lrUfq8KjRLZoVv+PMgJsqOTv+L69FI+LBRWUBoL2Nb4F1fP/Jj5ejQTSONDHOi/PgzkRUJ6WMHmFV64iUQRxIif9xmfEsGdWrkAxIgoCG+aRGFNzOeRs7FP7zcHMVaW6OnyRoli2rXLaqosf3Z1RWvwDOziOkCF7qPe3ZChmL725lC+cebNxmBmzD7mxXwdSHUuHYPhzdtbIp98JT8Txxq1LpLt1vlm7a4Qd+SYjrD0q4FCyAiKDzrAoJq9mU5oX/GZElRYPknpXAqvOLcSNlbcPEK0kDh16MQcJjTDI1Py513/1erWbWV0azzpy0pxj9DL8Ups9d1NVDOJLd1u5fAREYwpek0vO0sQ0DQORAcrM3HGB0SeV5QFVjBe1Rc4cVQr35aXSCDosPaD2jVuVqPmjh+yXT1TxqgQwcxrmkoP+bq+yASz4dzd/kZykQGsyKYYFNA2WD5iWkrUcz4uvlT0izag2VJSoALRpIpQkrmlwR/iLzBb1nOTTzD/GvwwD7bDWC24jJv52qbZFNX2QWwwH/Nghh2JDLVOhEBboi1xq4espSaU+lgiut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++55rQ0w3Bo5wLW6yIghcvY5nIx9m+LBgB9LLzxK0sJRWR8zvfUWp7YMskb4A0uQdMLqxqvq2RaRzkRFu3AxsuvJq8k9T+yK8oHmfBP19vGflacCipUEmubQj9YUv4duIpZRe7zGxDFr4CahthhR4bXGtAY4kRsrTRHhu3rVrv0it5TmFaom1LVN2y977b5M6N2Y8/xYglKBO5Hxs75pQs3SHCJfOUqfLZyJxvRhxsUYoRS3Tdv9TvC2aG5gGCPVPcw71dcT4TJvfq/uexR7JrOm9OfhLaZM9fGne2/lxRF3tCICYYhI3znbeXAodBqf/IGA4TB0iegOQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: db4e2afe-67c2-4d19-20d2-08dce14f1385 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 12:54:52.7585 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PiLDnWiZ9U5ajZbVK4eYjWKFsXsEw/0GEn+GlF/gsjfUCb+0I+SxiFh67xBV/ufmVedg2id3icQQGo6h5861fw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6116 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-09-30_10,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409300093 X-Proofpoint-GUID: D74Y11sVSREoQhx5ber9N6MritbrWR7U X-Proofpoint-ORIG-GUID: D74Y11sVSREoQhx5ber9N6MritbrWR7U Darrick and Hannes both thought it better that generic_atomic_write_valid() should be passed a struct iocb, and not just the member of that struct which is referenced; see [0] and [1]. I think that makes a more generic and clean API, so make that change. [0] https://lore.kernel.org/linux-block/680ce641-729b-4150-b875-531a98657682@suse.de/ [1] https://lore.kernel.org/linux-xfs/20240620212401.GA3058325@frogsfrogsfrogs/ Suggested-by: "Darrick J. Wong" Suggested-by: Hannes Reinecke Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry Reviewed-by: Christoph Hellwig --- block/fops.c | 8 ++++---- fs/read_write.c | 4 ++-- include/linux/fs.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/block/fops.c b/block/fops.c index e696ae53bf1e..968b47b615c4 100644 --- a/block/fops.c +++ b/block/fops.c @@ -35,13 +35,13 @@ static blk_opf_t dio_bio_write_op(struct kiocb *iocb) return opf; } -static bool blkdev_dio_invalid(struct block_device *bdev, loff_t pos, +static bool blkdev_dio_invalid(struct block_device *bdev, struct kiocb *iocb, struct iov_iter *iter, bool is_atomic) { - if (is_atomic && !generic_atomic_write_valid(iter, pos)) + if (is_atomic && !generic_atomic_write_valid(iocb, iter)) return true; - return pos & (bdev_logical_block_size(bdev) - 1) || + return iocb->ki_pos & (bdev_logical_block_size(bdev) - 1) || !bdev_iter_is_aligned(bdev, iter); } @@ -374,7 +374,7 @@ static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) if (!iov_iter_count(iter)) return 0; - if (blkdev_dio_invalid(bdev, iocb->ki_pos, iter, is_atomic)) + if (blkdev_dio_invalid(bdev, iocb, iter, is_atomic)) return -EINVAL; nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS + 1); diff --git a/fs/read_write.c b/fs/read_write.c index 64dc24afdb3a..2c3263530828 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1830,7 +1830,7 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out) return 0; } -bool generic_atomic_write_valid(struct iov_iter *iter, loff_t pos) +bool generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter) { size_t len = iov_iter_count(iter); @@ -1840,7 +1840,7 @@ bool generic_atomic_write_valid(struct iov_iter *iter, loff_t pos) if (!is_power_of_2(len)) return false; - if (!IS_ALIGNED(pos, len)) + if (!IS_ALIGNED(iocb->ki_pos, len)) return false; return true; diff --git a/include/linux/fs.h b/include/linux/fs.h index e3c603d01337..fbfa032d1d90 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3721,6 +3721,6 @@ static inline bool vfs_empty_path(int dfd, const char __user *path) return !c; } -bool generic_atomic_write_valid(struct iov_iter *iter, loff_t pos); +bool generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter); #endif /* _LINUX_FS_H */ From patchwork Mon Sep 30 12:54:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13816287 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E116618F2D4; Mon, 30 Sep 2024 12:55:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700923; cv=fail; b=BU+oIVqLze+GGr06aK0zx86/197CnxcLhH/xx9qJpTp3t5iOpCghJFkamTUSNKBxUz2lPqvsY1GSG3qUieLap1iPwoRV9xGIQxapf09BXOfkJlWi5uIAKlwWoEh9p4uBatoSwRo/cAPHgpCXu57bZtHYGj3v/7FUNEkHTTv6MnU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700923; c=relaxed/simple; bh=wGM+4OH899Or67C4IM4hVY5UHwUQQ1QwtZQPWYOAgOI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=p7jOlUhftweMQiJk7XCHR9ZVjcQXIk3+OhrslzwJPhTQ+WQF4K1UF1sxG8XdD3U+sXME4nQgDTElTnXz6ADCuHC67fak0mhx+KbR28A/C5/3X92DnFb7dH8XkJtbr18wnIwRuLIjx7I3RiqIxB7X2s+uwTCof/jIX+5yII2adUo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=Y9clzkpy; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=AjEHNRMZ; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Y9clzkpy"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="AjEHNRMZ" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48UCSwnu024634; Mon, 30 Sep 2024 12:54:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=qd7RpKbCyqRzKeltI/Gx0fICIwkxogjEJMxet5EbvYw=; b= Y9clzkpyJOnBWCsGxC2G9uAiGTV/YQz4X5VUZ0Z48wavbHmf0Gp+apapKw/bYvoU UaJXDK1XY1pqkWo5sngTEzGlLfRe1H32AsCZZHZjkTL3L7sx3D5wNWXoxYaDG6WZ 5pYY7MXMJ4LL29CCCxh2/eqYaqQx3INs0nyypMCTBv1IA3zbgzz9l/CKZZkwJfhH jxwUMDf1cNBXLBPJGZHevIaOSFEAeWLhxWLjYumowlWgsBH+nDldZMhhsvsyPnZl VixHVxWyiAjEOUhCtdpBcKw5cYiPInT3/O6k/Kp6LBBtKH0RU00u0Xdl+K0ce6T0 zFcKz7JrOet3VCTsElPA8A== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x87d37tv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:54:58 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48UCXPEV017246; Mon, 30 Sep 2024 12:54:57 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2044.outbound.protection.outlook.com [104.47.55.44]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x8860b6b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:54:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MROBKj7MYHOiffi/aWa0Ltpq7pRBcsuhR7lFsxP3KPuZr+MbIg0IhBGbxEhhKNwOUQFlaOZjNqgn1OjliEj0RzYBC13LbZXs9acLxXXWGhjSFVx8RAKje7NaUnmoimsSkSoRTXlkus0ceRJ1REsWklmJIBryWSG4lND/55z0hanKMy6UFjpisl4iMt2IhoZzAo+N866w95avEZE+MkxEjlCfi9yntEcXg7Cr3IPgpa4FM08XfamvA4pSRp+PFzZGkAKckbxO5Rze7DfQWbpcWnyjWFdYi/Non5Z2dW0vJIzr4aO+IB+btTZLVO8oVGu3t7pOUC8wmAqMMusvWOjqvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qd7RpKbCyqRzKeltI/Gx0fICIwkxogjEJMxet5EbvYw=; b=S5h8XFbgnalLRtAEB01NZ6rDacJn/vMhObdZJon327N93hLSL2YcqK0/3OZFVXqj5KGCkqmkGdiOA7to7c7uT0a/2a8KPZn/TLIcwRJWS+hsoGumZufOzvHW1ODVC59/TwQBzibXglZJwf243/o23NDKj5PTt6wJ7Wscg+9zoE9/I7Ux81r0eGvULyBPQBkWu7f8ugxBVZa896W8ulu+v4Y8/7SUcM1CSeWmbDAimUiIcY57XK30cQyp4cHYkTTOMed1Ajy7+DU/qwwkfSF6LFz4gZCrT21KmMgb5+LyddXOKOvwRaElrtiLasY1rM01mUdTWCfoofnG8tmqkTmlwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qd7RpKbCyqRzKeltI/Gx0fICIwkxogjEJMxet5EbvYw=; b=AjEHNRMZDOPYY/mXNpZxXfAvJI92c8tES3MEnl15WKgKlhAGswIkMtF5yEme4Hq8H+nYhOnmQlVxlEq3umUedZa33LPeXfuBwPs4PKM9AXyXDReHiPpkXSsKkUagNr6833lEsQ/Qglq3S/lAuqLcB5iBg212nWjLQuHVzChVcsc= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by BL3PR10MB6116.namprd10.prod.outlook.com (2603:10b6:208:3bb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Mon, 30 Sep 2024 12:54:54 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.005; Mon, 30 Sep 2024 12:54:54 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v6 2/7] fs: Export generic_atomic_write_valid() Date: Mon, 30 Sep 2024 12:54:33 +0000 Message-Id: <20240930125438.2501050-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240930125438.2501050-1-john.g.garry@oracle.com> References: <20240930125438.2501050-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0065.namprd03.prod.outlook.com (2603:10b6:a03:331::10) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|BL3PR10MB6116:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e4472b1-3f49-4857-8429-08dce14f14bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: 8C85gkQmDrOdXDb+r94rv4jMyaDpr9EX5Pfsyu040y4XKdPo4tH23XD/fH4tIAguKh0NhqfG054nU4jwvDYxcvxY8Iyh6Z2J2PrynnhmCCKldTcNQXqXCgncS9xBOzK3jkmbJVDHOhBC5D1fR71GzhTzrs+C1vjpmWrlmJw42mZQD5whTlXQ9IZfr/bJkWHML6PK+LMRPzDj/5fQHMONaiARjR0WDdPsbDTOj4XwaAst8kH57+VyoDuI3V9n0A7o2Lz7X3ptiE0bCegXDwm8A4Kz8+b1bfESmEWNmznHFHN/VJ2UCakQI4EkXuXeu2s1xAl65120EiAIOsT27rtqfPg5hPoFvAfQAGi/OJFoMBdSS6n6/IY6npxt2dHMO22vdDbfWPbnA7RLVJcAhgTB42kNdxL/+5u4IjfTrlqGgtt6y+Vn17SrCauWHDjoGUVx2LkE4DajjTx96eZKueiUrCau2wVtL8ZTrbz7wpBt3ZJte3gRoo0l7LVIMHidXFOW2E7KjQdvUPi6ttnoW0C9qoEHDlfwMl//xXefZNGKo2ZdOPI/YdkSa9+07CDuIctztEqAdnZB6puN7jIINhrsmt86qQxiN37dC91uZtloVz2kEHqpFfTX3+ZjpQ97RQO4FPgFe7zG6uFiHnZG892fPe+55f9psQP9HoXcsPVpSHQnj3uQ+yX5QmzkDgaqdBekoPU9wtYvPmnhTGxl5cToIqcZon/AK0i9sJ1V6m/aN/ckyEJRElm/w/PWma0NckY0BN7TzXfhv/xqYOyH9UuBxaExWoCC2I2K9HIiJlkIx2SAYBiA/xjSLc0vknMjXzOYue9DJPYhs3Rh5Bxx68RFcfVSIqDHITc4tRyBbnp/QfL7YBrsz14pt+KwWEWPvHskV+bL9RAYTmwz33Mc8gUZpZMz/oTL4UnZEJnoYcvz2T16ETZshQf4qmt+R84OVeCssgAATvozklXFk/JQ69XvAtUY9LDx7LXgvxBlEDJz7EqPdGxmzRmCQX5vT3TeUomt4uTH2KLEO3EfJ9KtZTbHyTorGjMFUx0fg/vrt4S4d+7Ka7qEq/V6JUM/q4Q8D8uinTSIptROZ4PYttIial3GnfgQzQq7YuRbwQSaI6v0XIpeH+vIr3WCJe+DT8++EGqjsQVG2emyDzyg1kkOWXnS93lKgTMs3AjH0Q4Q7WEyn63vqddXzBzqUxQ6tEeap9LEVzhVy9VZQxRq1VcnkkGawbwjwSKtHTfc79t8j+zu7+AIEtUP5Hm3bA4Gcd40E/4Is54+V0go0LsZyu9PLOeUfQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y9KMLmtAS/0sviLpe4XHPk9i6+H5p1prdB43YXHhMcQMILJYcfj1EgZWG9qR/5zYS5u4z0MB/OYv55K1TTdjAiBFE/EroxTjb9BU5vyoRNqBYl1qrC1ZhLx94tuu626LquR5HViBdg/ch4anVOO4EyUM2m2xWL9Nu7XXX7mw7c588pkmZ+etv9ecQVEXxAQEcN8do9dEmP2vFYNWxRg5EzPpycOidgFzpYCNkzN26e+taImimlyZkbvO4S1X8rwWY+PwCCUL9eXRaUW0m4bxZU10GiTB2YdIEGHNbw/lzrANXF6TK/77gF3TGk9vyYINDxhUy2MMDZemH6e43bOtIKVd5BiKHtPxFTJnIyFZyCQ3l5ST3r1/CJYEQFfQqUP2gOJBjFsCI6EhXkW42l0XVKehf+AoWuNV/yrwFmsL/JkUjskQ4S6ie/ha1APbH3eGs8EuNOLTRrF7FzUZlMChpFWQYvu8s0Nm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vbDCYzNJNaTpTAECHVyg8DARZQbmJ2PLCprnVobr9VLktVY1gK/RavV1KqVxd2zXnVhLagA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: JgmEsYgilxTcNyU8+91cU9FAX9wMA15U68JxSWTquUbR6n5eIxqV5JDmG/UMBs8Z0yznVzgAqZ/AqNV4qlBOKQ54D4dV1X+/AgVZuqXA3yrTvPoL2ZCZw8VVakHB/uNJPzIN2dcI3bP18BmyBWYJP+T1guC5MnXrkturUBpbd2yIodThBEoWl4XzCkxyCnMCIGr5lhzgmmsWPgEG0492+J66osYEarbJH7bx604B6cF2V4uGxHNqNAHUGC/58CRhYMnlUWxGfBJkW5kXWD/xFvveKXU+2AV31n/QgtgbrAloiUIv1m0CsLafHRuz1/v2l8jANAdiRXU9zN0Ma8c0tnlWjAwAUr+E3CuvdaLn1TXpzynBIIbKYBmYMoBek3c9/i56Q9tfoVp7VzmQ3OvfAnyYeOxGLqP7TvZdr6n9HORWTu7FkLVq8H50DVLZYp8cFj6aq/z3aam1yGeVgD3EHK2wa0yseD/tZ8sGqFHnp5pW/HOhWOfjjT+EUdiMSeL2jJNByxAfZDvQgt74ghEqPKvg8xnf8Ws/UP0Oe9zWVqOjgSYiwmfNoSq0LrxJQBNog3KDa3Zq4xGtjkkdmLMc8qjuqR8qRfgcBsUj7Z0ug2s= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e4472b1-3f49-4857-8429-08dce14f14bb X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 12:54:54.7256 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SMfLAdk1uPBaCBtJVmpyQfz2YwyPim6PfM9yTWjDd4ym6kjJPqXs8OjerJU1+eN+m3rj13RX31thv/sMikN1Hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6116 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-09-30_10,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409300093 X-Proofpoint-GUID: 0BdEKGFLlJNVn7hChRfW1zbFp2Q5Q2rF X-Proofpoint-ORIG-GUID: 0BdEKGFLlJNVn7hChRfW1zbFp2Q5Q2rF The XFS code will need this. Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry Reviewed-by: Christoph Hellwig --- fs/read_write.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/read_write.c b/fs/read_write.c index 2c3263530828..32b476bf9be0 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1845,3 +1845,4 @@ bool generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter) return true; } +EXPORT_SYMBOL_GPL(generic_atomic_write_valid); From patchwork Mon Sep 30 12:54:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13816286 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54A9818DF60; Mon, 30 Sep 2024 12:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700916; cv=fail; b=dJUpayNRfjGcFgAhKdmHm/Biu+vUL85eOZWVtR5gEWE9iQ0oj8MkzHkHR19Nsz1dyaTvH+MXDJo245gke4VqM85I+ImVEgfDc7spyc0U1RoQywy8V/Bchd2gZtXwMu6Rc04/Tl0TzbkvL4NoxxGQ91mWAba08pYS1KyFydtbBRg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700916; c=relaxed/simple; bh=4y+aBRSSwUP+bluyyGBumPMTLP/ee6J3f/u9WXq3rt8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=VQ42sYn6lsNMStPJtEaucF01P3ykiQIUNiRAlkbg5Bt+MrpvK0ghzynYAGC5OqP4oLbbfjQ//pIV34toeP6hkXUys4I8A+vVbrgZdf+UNcj35NBJJLeHvJ98Blp515mNpyzCLX1/vgQpvBABjQnWnQ52YYxVVaBmhbSiqFsf/iM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=cSR5iW8Z; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=w/uV0eox; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="cSR5iW8Z"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="w/uV0eox" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48UCTdo0019500; Mon, 30 Sep 2024 12:55:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=FUOhCn0Njr+8xziK/5aS0j4Dp+pPlpxhwIK9zNn7GvM=; b= cSR5iW8ZPYdTjvp+uXjjij6XuX2K9JTUAOL+OMVda6J5DR9j8NwGxNcGO8LQwywB 20SnWvNJUqYGFcZ+TGYjzb5f1VQITF2UuURZR7eTIs3NSFv+B5woOQblmLUHT5iL 4iMAVS5udgoRAkFwcQusVJzszRa++vuhuQzsolMyXwClIZQeCdK7N1wS93anYB2q xYmZjAcM/sz3kdw0PagQsEv+eOaQn1KlMrADGSfsnixDSMF4xr25epbpm507cAea AKLmuRxBej8hMeUWpLb3GKPDfkjhJNzaBqmbHnqaGPJCNbGbtV/Ig0+cC8GcW2Bu KLlZR6KOqZU8/i6xUToymg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x9dsu6qp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:55:01 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48UBv00l017265; Mon, 30 Sep 2024 12:55:00 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x8860b7n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:55:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TRoMBlQ4AfAcu0ePUolg1nps54Qnyhjcqwl+p9buijCAhNkxHYT8CXMUxfFaTXXO5cFXKh621TXYY2SX8TTpfXmdKEXTRSUkcGvJr8hO7EfotHlhQjUsGfVgHSepvkBOenSlovobXjmUDKHs9d/MueTQKXkuZS+RM71dyyRF6tNx2Ttxsjf70eV2PCDjwb0rzFiBRESoPhMcLWjzFXvrjh7T0rlQyPIjZrddYNjeSHNpS5F6y2vRDnu/tzCKG+KnjOBeTL5OaX1pDeOpR2saFGRUsimcBBIplG3XR7GMY/NW5fk06AeUEs/9kwiqZHTZGZ91aEynULzedy/Rz4WaDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FUOhCn0Njr+8xziK/5aS0j4Dp+pPlpxhwIK9zNn7GvM=; b=hLSoUK9cr8hpwzGXfXWuT/AbNseXsnxv5pT5e2Tnu487B2PRzC3FuWgs9d9DFMoSFBt+1nYMbefH0G/QvN/v4s3FVHIIN+k1J5Jngqt+2qwgNskHfjKWf/TIl3woHAT2Q0jYTnd9uvx+CaBDBzZL8Nrgwdfp9JnTaD6mwOdtwPc3BgbnMqhnztX6RA+eDz0h8LMPMSLHfZUTQywY2aptitntEO9Yn9VDUQj9b4nHNRpOFUVn77oPSqpF5pZUCLh92lpNzXpngyKkyS2dF++r9rOkp7OWAkF6vIIUSEnjeNIh9BQEJ2USILn45dzRzz1LXXu+4hv5Re7z+DBpIQ7H0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FUOhCn0Njr+8xziK/5aS0j4Dp+pPlpxhwIK9zNn7GvM=; b=w/uV0eoxPMxEdY1Av5SmwUEbXZxTX2Mn63gH9XTjNyE7KB0yiVf+/b2gOKTNJRa8iYSh7VNuvdzykDer1j7sK/CVRvxkK710/I4mafRwTcQLx8gAg1zQ2MuWaDxlein+c18cr28eK6mnBPKfeyYMEl3y40B+o/Fc6dURw4lYjH4= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by BL3PR10MB6116.namprd10.prod.outlook.com (2603:10b6:208:3bb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Mon, 30 Sep 2024 12:54:57 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.005; Mon, 30 Sep 2024 12:54:57 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v6 3/7] fs: iomap: Atomic write support Date: Mon, 30 Sep 2024 12:54:34 +0000 Message-Id: <20240930125438.2501050-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240930125438.2501050-1-john.g.garry@oracle.com> References: <20240930125438.2501050-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0022.namprd03.prod.outlook.com (2603:10b6:a03:33a::27) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|BL3PR10MB6116:EE_ X-MS-Office365-Filtering-Correlation-Id: abbcbcb7-f9e7-4422-29cf-08dce14f1615 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: tlMkXzFl7GUTc1chowxXoXXyzhYIOb88zPx5m4GydQW08nsjdzPgxogR4ScQcmz4X5kmfT2b7nw6oq/W4n7ZZwfAPZ20ZIL07HCO4mq4AFCpAQOxgzZDTOnabc87TF7tn6OsDVs5LkXIkIOVog6Ch7kRZo9s9xeHN5om+7Cvxbl45sCOkOmyZZWPNcwV2sQtqQ5jzf5zU3EHb6zCilrQDslGfMzD8S4Xr+NosdAAQbn44CU2VaP/9wLBw5JieYF14FsLDB55c9ggPfxW+dQHy1C1rHFx8EzuOripFEs5Xh0BRCW/6JlkOc1s+ejR7E9h6XE1qw87RsYuQIPfS33XHzNnpC/zIMuFppalgbwbGkecWdU/Wj44n2LAzxLta1YXpOkLCNnvxbqRYCEucGI6V8pzT6ZeNG49jLRydkfBvLHbx18t6Gpqf4Kz8LaJI4Z6zOslnZerzMxUnxOMZvI8NWsUyfYj7Jr4laMfzjLEIsNnQi0H7rWQswaT5gDUwaKpEwQ7mjGl6FXjXo7rk4U64PSWUnM7wlsE34Q7mfXQf3eUfG7so2SrPDqOCOpb6lBHzKAXXGp2HjS5Ja0n4x7iHZecWfp66F/nfO+XFyyEvtv9LVKbx6Z9qz45X7LMNX2aFed+eAAxaG881nKhg2ioHp3Z7V9MIi2To5G8+SpEys3MPgPxWHe6OtkxrFmTcehSmKvkaFcjv0RyzTngqFNDu5VDJUOkKaL4zndexszoDX6gZ5WW0jTVm4kc9kcfJZJISavzcG6L8ejb9V1oZ5tStAY/tXe+Bex/dMi/FV2B5DV2t8JY+ot8lmm1EUcrnVgo8ANeEDORr5KpP2g2YraL7gidoF6GF4ouSGO15plvOQ1rQehRUpafUoZC7p90KMyB2Eeru0ZT1mmUrd1nZb9hBQJWr91mJja/PGAqv+aDqVT4fSzDn856lyxoZCYLmhUky/AvP5jj/gR4SLhJ3WoCzbfiBkMGYTfXTaV5EWh62JJEX4NxlMTksF/neBpwC7dbffEGz2fE0P6YEo1uU8lz3tS6HBzjk6IpqxLLR5o1z2+nbAWfat7bo+3nYE1WQ9vON43/PvMKzwlzCtkcliR6rIlAfU0DmuUgpc60dLR9rIv/O06IBZWBSBc3eELHsSq+NgU8bIXak5H2lsImgSXWZGoBw1g25aPV/eOwF4ny6WZAR+Mu2dbMQgGQ13o6AQcNJ4yYiyFKLtc60uTH4CD+ermbnugS3nbZ3C0uvC1eledUaj3/Upiwh54Vlh1yEQUVZEW8UGO4gbmFFOQ8ILXLDw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fsSTV9+Cpw4aWPd7EQ9w5vLos5VYODn1BjupyZyFUCmPhBbfcAfly4OfnMbt7ceCevi+Wccvq/MfA7EaDCqjH7HeMEXwEf8vQp9uJHOglwg1eRrOP+6Yzi7YQnc1YRRT+9AQfw7mGsS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jUvzm95tJZVtM+Yq77bgTZc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: abbcbcb7-f9e7-4422-29cf-08dce14f1615 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 12:54:57.0180 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: V/PrWyxL7ViTm6YqD0xCz8WsZ8VGX5mIAizIrPVn5W/r+kHR/YfyUNCk3lDw90xJQkb2rVwjVIZAcyKyUP8tcA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6116 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-09-30_10,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409300093 X-Proofpoint-GUID: XflJs80bZOPsT12w2lxigMxFMSAka-1y X-Proofpoint-ORIG-GUID: XflJs80bZOPsT12w2lxigMxFMSAka-1y Support direct I/O atomic writes by producing a single bio with REQ_ATOMIC flag set. Initially FSes (XFS) should only support writing a single FS block atomically. As with any atomic write, we should produce a single bio which covers the complete write length. Signed-off-by: John Garry --- Maybe we should also enforce that a mapping is in written state, as it avoids issues later with forcealign and writing mappings which cover multiple extents in different written/unwritten state. fs/iomap/direct-io.c | 26 +++++++++++++++++++++++--- fs/iomap/trace.h | 3 ++- include/linux/iomap.h | 1 + 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index f637aa0706a3..9401c05cd2c0 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -271,7 +271,7 @@ static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, * clearing the WRITE_THROUGH flag in the dio request. */ static inline blk_opf_t iomap_dio_bio_opflags(struct iomap_dio *dio, - const struct iomap *iomap, bool use_fua) + const struct iomap *iomap, bool use_fua, bool atomic) { blk_opf_t opflags = REQ_SYNC | REQ_IDLE; @@ -283,6 +283,8 @@ static inline blk_opf_t iomap_dio_bio_opflags(struct iomap_dio *dio, opflags |= REQ_FUA; else dio->flags &= ~IOMAP_DIO_WRITE_THROUGH; + if (atomic) + opflags |= REQ_ATOMIC; return opflags; } @@ -293,7 +295,8 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, const struct iomap *iomap = &iter->iomap; struct inode *inode = iter->inode; unsigned int fs_block_size = i_blocksize(inode), pad; - loff_t length = iomap_length(iter); + const loff_t length = iomap_length(iter); + bool atomic = iter->flags & IOMAP_ATOMIC; loff_t pos = iter->pos; blk_opf_t bio_opf; struct bio *bio; @@ -303,6 +306,9 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, size_t copied = 0; size_t orig_count; + if (atomic && (length != fs_block_size)) + return -EINVAL; + if ((pos | length) & (bdev_logical_block_size(iomap->bdev) - 1) || !bdev_iter_is_aligned(iomap->bdev, dio->submit.iter)) return -EINVAL; @@ -382,7 +388,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, * can set up the page vector appropriately for a ZONE_APPEND * operation. */ - bio_opf = iomap_dio_bio_opflags(dio, iomap, use_fua); + bio_opf = iomap_dio_bio_opflags(dio, iomap, use_fua, atomic); nr_pages = bio_iov_vecs_to_alloc(dio->submit.iter, BIO_MAX_VECS); do { @@ -415,6 +421,17 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, } n = bio->bi_iter.bi_size; + if (atomic && n != length) { + /* + * This bio should have covered the complete length, + * which it doesn't, so error. We may need to zero out + * the tail (complete FS block), similar to when + * bio_iov_iter_get_pages() returns an error, above. + */ + ret = -EINVAL; + bio_put(bio); + goto zero_tail; + } if (dio->flags & IOMAP_DIO_WRITE) { task_io_account_write(n); } else { @@ -598,6 +615,9 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, if (iocb->ki_flags & IOCB_NOWAIT) iomi.flags |= IOMAP_NOWAIT; + if (iocb->ki_flags & IOCB_ATOMIC) + iomi.flags |= IOMAP_ATOMIC; + if (iov_iter_rw(iter) == READ) { /* reads can always complete inline */ dio->flags |= IOMAP_DIO_INLINE_COMP; diff --git a/fs/iomap/trace.h b/fs/iomap/trace.h index 0a991c4ce87d..4118a42cdab0 100644 --- a/fs/iomap/trace.h +++ b/fs/iomap/trace.h @@ -98,7 +98,8 @@ DEFINE_RANGE_EVENT(iomap_dio_rw_queued); { IOMAP_REPORT, "REPORT" }, \ { IOMAP_FAULT, "FAULT" }, \ { IOMAP_DIRECT, "DIRECT" }, \ - { IOMAP_NOWAIT, "NOWAIT" } + { IOMAP_NOWAIT, "NOWAIT" }, \ + { IOMAP_ATOMIC, "ATOMIC" } #define IOMAP_F_FLAGS_STRINGS \ { IOMAP_F_NEW, "NEW" }, \ diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 4ad12a3c8bae..c7644bdcfca3 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -178,6 +178,7 @@ struct iomap_folio_ops { #else #define IOMAP_DAX 0 #endif /* CONFIG_FS_DAX */ +#define IOMAP_ATOMIC (1 << 9) struct iomap_ops { /* From patchwork Mon Sep 30 12:54:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13816291 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 946971917EE; Mon, 30 Sep 2024 12:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700929; cv=fail; b=l0r3uwoE6i4b6uXjOqBnB5kqyCL7MniW7TAJEsPZo4vXV6BOP4uQQCzI1t+juNzpTKMsQjBFNoT0u7+gcbb1lvm84ljO6vchFxEgTBRhNTn0IM836/i4USkERQIYPfg02ePSnXI/e+YF7buJElilG4S1KBoDVKeidgp4dRL1fM4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700929; c=relaxed/simple; bh=Banfh4EgYWGl1Q/xZydJxDKnJNbver2X28Eugz49QeQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=F0zgGAWZ8PIZABIcydNPpmMMjIK58CtVpC8BZRSNMkgRNm+/ZuxfxE4gtgOMtKCw7ZTkhrvdrsi2NUrGGjnM8K03it26Na9rwkj+nMtnmyP9cvKaGOuD+b3G8ANVRVbVoL7611D6xW3N58a60GFY8JM3cNhxkArdzk/kStoirEw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=li+/646z; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=maEb7oa4; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="li+/646z"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="maEb7oa4" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48UCK2x8009387; Mon, 30 Sep 2024 12:55:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=+NExMxz9Jq8oZh7DDJhn4H03KalWyNIgLxo8sC8oFhk=; b= li+/646zwPSs9Y25dsWEvvT0P9w0odW+IKooQC7CvMgnPG184X6kFAyRh759OlLq JT863/bidmS1fz/w/s7lcQ6I4cg+NBd6MAseuGsMHP4AeZO5F1nAb+jSREQ19MPD 3H1XNoPTCD0gfGZ49tZGpc4PsmmkUQU5m0arxDYGoVAAxO4t5R67jO4ABV45tIO+ quUpUPpNQuhvEL+arFIzDrI8kuzt8/0UD0fb423L4Zcf2NGtMbvK3NSolaYD6IpS LpLDvq6L4JA9iSqgaazd52h1B5HZQ49L5u9Hy0KQztkiN0OCafbAbdCEEPEOe78V 2kU3BdKXWK5feFMC+XxZ1w== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x8k3383x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:55:02 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48UBheqi012511; Mon, 30 Sep 2024 12:55:02 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2042.outbound.protection.outlook.com [104.47.70.42]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x885r6x3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:55:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jvd8Cp0XAZ2IwqMChRCqQ1Ikx1nxcUKWRIwEcd0vVx8fmvVVNVnRAnSneQ0L1loXhxQllKV5sVpworgzL/t0B+6n8oCDJSSME4h6k1mF+IQeOgq/eLSU7lRzNm/kGp0PI3sY5MrpDkJxNyllcYHzVy+iE7qAKmDBYiSDR+TAQ7cQ+u1P9XgirC3u0ME2PDF4M/8I2g8O1NiwEaUnVW3HnWkL5O+mt8Nqj8L8eztxfAF/P/48JZuI9zO49Mah25NaCEHgpux544wKXbblH3eF0oTANl7ugRJrXBBDW1puim0kKVwy2ITq0P5WFx4AhctGPBcw4+NgI3uhIBsSTfRKPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+NExMxz9Jq8oZh7DDJhn4H03KalWyNIgLxo8sC8oFhk=; b=uZU/P6tLIUQazOthclF6YdWEhebZze718v8sGF+fUp5cEogVDeaQKPhqP9lcJ9eFKmhCBQuRJ9wEwmFGcBcfPUhx8N+mMlb+vxbhS0eojSYMD6n1xg4iuq0oXmNxToQMrXR07jxtKNNNjb+Q+iNh+8M1M33+9JpxTsMG/cpGS6MaYQMW83vkvVDC93ss9E7IQaRF1UkSyVVHThll0qSI3dqxIJCwvmJmA4a5IHIr8Hldp5fgmp/bqFtFIiMwGTQIMG1icQAAIB4LbUQwuf0M++ReRq48s4wOgT1yokeNevNMZdSVK/XOe4fCoy/3hgW8eqPxqaT0QDrLIy1af7tq3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+NExMxz9Jq8oZh7DDJhn4H03KalWyNIgLxo8sC8oFhk=; b=maEb7oa4CEelMO+JerUaILMsjjrW4g3gzBH6HGbNU4p04K+kV7FfJT7RlkDXxbcKDacGYi97njNDDresz41nVGNcvSfiIK0F1Z4owOFFXdl9TRxqd+b6gVYmKfwOYjPPGRxSqQSdVQ1mZ9nhzkd6m3Y2dDWmtLws1IGiNiS6Lko= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MW4PR10MB5861.namprd10.prod.outlook.com (2603:10b6:303:180::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Mon, 30 Sep 2024 12:54:59 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.005; Mon, 30 Sep 2024 12:54:59 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v6 4/7] xfs: Support FS_XFLAG_ATOMICWRITES Date: Mon, 30 Sep 2024 12:54:35 +0000 Message-Id: <20240930125438.2501050-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240930125438.2501050-1-john.g.garry@oracle.com> References: <20240930125438.2501050-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR07CA0044.namprd07.prod.outlook.com (2603:10b6:a03:60::21) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|MW4PR10MB5861:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e070d4f-0ffa-4ef4-fc8a-08dce14f175e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: TxJslDv7PhP6k6h5Y94YN/rsSzDL8QXE/KVUqRAVEGzD2pHndu4PQoJdd9sdslxL1GCr+AQEYOP8EYbZv1W9sY+P8wvZF2LslCOaWUqb+xn03KSVfDSxmkZzK92kNDM0USRvxROypXifRz5x1PET6w3Lks5Gd+JYF4Vc/dAvGo/MdZPbBV1i+G+wpqShRsnSql5F8yZ6YH0S3dJmFvcID5bGn/dGLuYPhQDQMKRlZmZ3a/QZfZK3YCDMF3pJ0Uya3K3FvtREvgRl8CjKeCWF77WPnaISKG6LU/qLtI85sBc6DtoPtt3yXY5fvZsLL2L934bMLlzMjLLqNGgmk941Ml2QL0adyKzuki2U1qDE3ENMQi6Bt7DuyORBVzcHpcFgffXH+U3yUgKZS3D3gjgH6AMWIY0+5FTjqXdoD2ZdsMyqBgkGkttSJaxK5HdO/UyW2EFyZp0ycG5hxYm8/tW94rTVQy848cNEHYzbeDu9MCQIYmLpr3CuQapsEjCOOuGXjt61CiDmMu0G+NgYdpMh4X6+owWTR4EpmPQH5l9QGFIa6rPQh/iH4ahftiLuZ+KKnWp5wusABm261BB19wb8EgB92BF+XBiIGHI1vfB87w/r2PnM2L3Nm0oDWbLsinAub22C2nvbSj9aBVCt8aohnHajXWWb4gUxfNIsGjePQT5zZbpMirXlnBTsxbZ4dbtEKcmrQ0f1PeibTET6wQKd6ts5AJHojevlCUf1EOr0q3dUHSFwW4wqP4FthUXV2Vec8+qioqL4volEt7098onfneFomCckb5+Sg23G3vDLGo7T4/9uzHVtkc4SZSl7vy8qcoHM8JYiqrNK/ivNTkWh9Mr5dflkixnzI2vQeYURXvGaRI22vTkAEYmruwSGTaijly9nnPhLCGJJZPp+zz9GbTDS2jL43iKRjfDlD8CWG6KeH1pjT6ClVGn/mFHefmeHqkq+/WMgvBzvrVZ7lQPdWaTrp9atI3rTBk7hqzufTMvx6QqVqqZZTRC5CGVyQ2wmWiIiWOeHSl8/blRlbGdnL/ws+yxKfVZiZHoA8Zr7Ps7RSchhRb36ybdVhl7unmLsC+GOHCKQBb7RM7L5USAsUbGczyJgQ0u8H32T2g7xBTF/Ou8RzpAuTI5ZHymBsiVfKW1Af+/jzgIqgyLO6h8oAeIg7+J0jdkQ0VXP9hSsejuZao7GBjc0V2d0IVfsbBghROepDXGxOVWqtddi1w/UD0Km0aLLGcLIb3HayIy0zbieOkFbLDR5ite0KlEb/vutAuj8Z6OqTPFW091yOigD5z7l6hnSOgqpOJg2z6Y6djNdUp+yjwecmp4LoHXQHuGImuf2e+BSBaascRPKyfHEkA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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dwFYxFKSTDeDPLVpCMv5FpRnml40RNgmgqeGBGGUU1Rzq03PKTX4LJ9aH1SkVSzv6MP6GzskC1SjVcJsCtxvgW3bHUMCNVE3Vz6AIwp5JunCyCfUIqlbSCdYcuXnvEnw6Gygq6+seW1mYOp2bFyYzq6LXOF1nWTPYkdLUv5Z9NIZCTIOmFLbFgIsX3iA7Xq2SouHapJiamOg/TtX3gNaWcHzQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e070d4f-0ffa-4ef4-fc8a-08dce14f175e X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 12:54:59.2484 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UeiVn1rtq+QqBVhQsy91GS3VQ6flHBvw9SvNA7gJ1WT3406sv6RVqG7LfyOI9XClOUE+I7qRN3OQq/4PI7Mdag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB5861 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-09-30_10,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409300093 X-Proofpoint-GUID: fAMcGqNEQOOHSwwgiKaRU_jmEhVmwGeG X-Proofpoint-ORIG-GUID: fAMcGqNEQOOHSwwgiKaRU_jmEhVmwGeG Add initial support for new flag FS_XFLAG_ATOMICWRITES. This flag is a file attribute that mirrors an ondisk inode flag. Actual support for untorn file writes (for now) depends on both the iflag and the underlying storage devices, which we can only really check at statx and pwritev2() time. This is the same story as FS_XFLAG_DAX, which signals to the fs that we should try to enable the fsdax IO path on the file (instead of the regular page cache), but applications have to query STAT_ATTR_DAX to find out if they really got that IO path. Current kernel support for atomic writes is based on HW support (for atomic writes). Since for regular files XFS has no way to specify extent alignment or granularity, atomic write size is limited to the FS block size. Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 11 ++++++++-- fs/xfs/libxfs/xfs_inode_buf.c | 38 ++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_inode_util.c | 6 ++++++ fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_buf.c | 15 +++++++++++++- fs/xfs/xfs_buf.h | 5 ++++- fs/xfs/xfs_buf_mem.c | 2 +- fs/xfs/xfs_inode.h | 5 +++++ fs/xfs/xfs_ioctl.c | 37 +++++++++++++++++++++++++++++++++ fs/xfs/xfs_mount.h | 2 ++ fs/xfs/xfs_reflink.c | 4 ++++ fs/xfs/xfs_super.c | 4 ++++ include/uapi/linux/fs.h | 1 + 13 files changed, 127 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index e1bfee0c3b1a..ed5e5442f0d4 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -352,11 +352,15 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ #define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ +#define XFS_SB_FEAT_RO_COMPAT_ATOMICWRITES (1 << 31) /* atomicwrites enabled */ + #define XFS_SB_FEAT_RO_COMPAT_ALL \ (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ XFS_SB_FEAT_RO_COMPAT_REFLINK| \ - XFS_SB_FEAT_RO_COMPAT_INOBTCNT) + XFS_SB_FEAT_RO_COMPAT_INOBTCNT | \ + XFS_SB_FEAT_RO_COMPAT_ATOMICWRITES) + #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature( @@ -1093,16 +1097,19 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DIFLAG2_COWEXTSIZE_BIT 2 /* copy on write extent size hint */ #define XFS_DIFLAG2_BIGTIME_BIT 3 /* big timestamps */ #define XFS_DIFLAG2_NREXT64_BIT 4 /* large extent counters */ +#define XFS_DIFLAG2_ATOMICWRITES_BIT 5 /* atomic writes permitted */ #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) #define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT) #define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT) #define XFS_DIFLAG2_NREXT64 (1 << XFS_DIFLAG2_NREXT64_BIT) +#define XFS_DIFLAG2_ATOMICWRITES (1 << XFS_DIFLAG2_ATOMICWRITES_BIT) #define XFS_DIFLAG2_ANY \ (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ - XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64) + XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64 | \ + XFS_DIFLAG2_ATOMICWRITES) static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) { diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 79babeac9d75..1e852cdd1d6f 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -483,6 +483,36 @@ xfs_dinode_verify_nrext64( return NULL; } +static xfs_failaddr_t +xfs_inode_validate_atomicwrites( + struct xfs_mount *mp, + uint32_t cowextsize, + uint16_t mode, + int64_t flags2) +{ + /* superblock rocompat feature flag */ + if (!xfs_has_atomicwrites(mp)) + return __this_address; + + /* Only regular files and directories */ + if (!S_ISREG(mode) && !(S_ISDIR(mode))) + return __this_address; + + /* COW extsize disallowed */ + if (flags2 & XFS_DIFLAG2_COWEXTSIZE) + return __this_address; + + /* cowextsize must be zero */ + if (cowextsize) + return __this_address; + + /* reflink is disallowed */ + if (flags2 & XFS_DIFLAG2_REFLINK) + return __this_address; + + return NULL; +} + xfs_failaddr_t xfs_dinode_verify( struct xfs_mount *mp, @@ -663,6 +693,14 @@ xfs_dinode_verify( !xfs_has_bigtime(mp)) return __this_address; + if (flags2 & XFS_DIFLAG2_ATOMICWRITES) { + fa = xfs_inode_validate_atomicwrites(mp, + be32_to_cpu(dip->di_cowextsize), + mode, flags2); + if (fa) + return fa; + } + return NULL; } diff --git a/fs/xfs/libxfs/xfs_inode_util.c b/fs/xfs/libxfs/xfs_inode_util.c index cc38e1c3c3e1..e59e98783bf7 100644 --- a/fs/xfs/libxfs/xfs_inode_util.c +++ b/fs/xfs/libxfs/xfs_inode_util.c @@ -80,6 +80,8 @@ xfs_flags2diflags2( di_flags2 |= XFS_DIFLAG2_DAX; if (xflags & FS_XFLAG_COWEXTSIZE) di_flags2 |= XFS_DIFLAG2_COWEXTSIZE; + if (xflags & FS_XFLAG_ATOMICWRITES) + di_flags2 |= XFS_DIFLAG2_ATOMICWRITES; return di_flags2; } @@ -126,6 +128,8 @@ xfs_ip2xflags( flags |= FS_XFLAG_DAX; if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) flags |= FS_XFLAG_COWEXTSIZE; + if (ip->i_diflags2 & XFS_DIFLAG2_ATOMICWRITES) + flags |= FS_XFLAG_ATOMICWRITES; } if (xfs_inode_has_attr_fork(ip)) @@ -224,6 +228,8 @@ xfs_inode_inherit_flags2( } if (pip->i_diflags2 & XFS_DIFLAG2_DAX) ip->i_diflags2 |= XFS_DIFLAG2_DAX; + if (pip->i_diflags2 & XFS_DIFLAG2_ATOMICWRITES) + ip->i_diflags2 |= XFS_DIFLAG2_ATOMICWRITES; /* Don't let invalid cowextsize hints propagate. */ failaddr = xfs_inode_validate_cowextsize(ip->i_mount, ip->i_cowextsize, diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index d95409f3cba6..dd819561d0a5 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -164,6 +164,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_REFLINK; if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT) features |= XFS_FEAT_INOBTCNT; + if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_ATOMICWRITES) + features |= XFS_FEAT_ATOMICWRITES; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_FTYPE) features |= XFS_FEAT_FTYPE; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_SPINODES) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index aa4dbda7b536..44bee3e2b2bb 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -2060,6 +2060,8 @@ int xfs_init_buftarg( struct xfs_buftarg *btp, size_t logical_sectorsize, + unsigned int awu_min, + unsigned int awu_max, const char *descr) { /* Set up device logical sector size mask */ @@ -2086,6 +2088,9 @@ xfs_init_buftarg( btp->bt_shrinker->scan_objects = xfs_buftarg_shrink_scan; btp->bt_shrinker->private_data = btp; shrinker_register(btp->bt_shrinker); + + btp->bt_bdev_awu_min = awu_min; + btp->bt_bdev_awu_max = awu_max; return 0; out_destroy_io_count: @@ -2102,6 +2107,7 @@ xfs_alloc_buftarg( { struct xfs_buftarg *btp; const struct dax_holder_operations *ops = NULL; + unsigned int awu_min = 0, awu_max = 0; #if defined(CONFIG_FS_DAX) && defined(CONFIG_MEMORY_FAILURE) ops = &xfs_dax_holder_operations; @@ -2115,6 +2121,13 @@ xfs_alloc_buftarg( btp->bt_daxdev = fs_dax_get_by_bdev(btp->bt_bdev, &btp->bt_dax_part_off, mp, ops); + if (bdev_can_atomic_write(btp->bt_bdev)) { + struct request_queue *q = bdev_get_queue(btp->bt_bdev); + + awu_min = queue_atomic_write_unit_min_bytes(q); + awu_max = queue_atomic_write_unit_max_bytes(q); + } + /* * When allocating the buftargs we have not yet read the super block and * thus don't know the file system sector size yet. @@ -2122,7 +2135,7 @@ xfs_alloc_buftarg( if (xfs_setsize_buftarg(btp, bdev_logical_block_size(btp->bt_bdev))) goto error_free; if (xfs_init_buftarg(btp, bdev_logical_block_size(btp->bt_bdev), - mp->m_super->s_id)) + awu_min, awu_max, mp->m_super->s_id)) goto error_free; return btp; diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index 209a389f2abc..b813cb60a8f3 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h @@ -124,6 +124,9 @@ struct xfs_buftarg { struct percpu_counter bt_io_count; struct ratelimit_state bt_ioerror_rl; + /* Atomic write unit values */ + unsigned int bt_bdev_awu_min, bt_bdev_awu_max; + /* built-in cache, if we're not using the perag one */ struct xfs_buf_cache bt_cache[]; }; @@ -393,7 +396,7 @@ bool xfs_verify_magic16(struct xfs_buf *bp, __be16 dmagic); /* for xfs_buf_mem.c only: */ int xfs_init_buftarg(struct xfs_buftarg *btp, size_t logical_sectorsize, - const char *descr); + unsigned int awu_min, unsigned int awu_max, const char *descr); void xfs_destroy_buftarg(struct xfs_buftarg *btp); #endif /* __XFS_BUF_H__ */ diff --git a/fs/xfs/xfs_buf_mem.c b/fs/xfs/xfs_buf_mem.c index 07bebbfb16ee..722d75f89767 100644 --- a/fs/xfs/xfs_buf_mem.c +++ b/fs/xfs/xfs_buf_mem.c @@ -93,7 +93,7 @@ xmbuf_alloc( btp->bt_meta_sectorsize = XMBUF_BLOCKSIZE; btp->bt_meta_sectormask = XMBUF_BLOCKSIZE - 1; - error = xfs_init_buftarg(btp, XMBUF_BLOCKSIZE, descr); + error = xfs_init_buftarg(btp, XMBUF_BLOCKSIZE, 0, 0, descr); if (error) goto out_bcache; diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 97ed912306fd..1c62ee294a5a 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -327,6 +327,11 @@ static inline bool xfs_inode_has_bigrtalloc(struct xfs_inode *ip) (XFS_IS_REALTIME_INODE(ip) ? \ (ip)->i_mount->m_rtdev_targp : (ip)->i_mount->m_ddev_targp) +static inline bool xfs_inode_has_atomicwrites(struct xfs_inode *ip) +{ + return ip->i_diflags2 & XFS_DIFLAG2_ATOMICWRITES; +} + /* * In-core inode flags. */ diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index a20d426ef021..81872c32dcb2 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -469,6 +469,36 @@ xfs_fileattr_get( return 0; } +static int +xfs_ioctl_setattr_atomicwrites( + struct xfs_inode *ip, + struct fileattr *fa) +{ + struct xfs_buftarg *target = xfs_inode_buftarg(ip); + struct xfs_mount *mp = ip->i_mount; + struct xfs_sb *sbp = &mp->m_sb; + + if (!xfs_has_atomicwrites(mp)) + return -EINVAL; + + if (target->bt_bdev_awu_min > sbp->sb_blocksize) + return -EINVAL; + + if (target->bt_bdev_awu_max < sbp->sb_blocksize) + return -EINVAL; + + if (xfs_is_reflink_inode(ip)) + return -EINVAL; + + if (fa->fsx_xflags & FS_XFLAG_COWEXTSIZE) + return -EINVAL; + + if (fa->fsx_cowextsize) + return -EINVAL; + + return 0; +} + static int xfs_ioctl_setattr_xflags( struct xfs_trans *tp, @@ -478,6 +508,7 @@ xfs_ioctl_setattr_xflags( struct xfs_mount *mp = ip->i_mount; bool rtflag = (fa->fsx_xflags & FS_XFLAG_REALTIME); uint64_t i_flags2; + int error; if (rtflag != XFS_IS_REALTIME_INODE(ip)) { /* Can't change realtime flag if any extents are allocated. */ @@ -512,6 +543,12 @@ xfs_ioctl_setattr_xflags( if (i_flags2 && !xfs_has_v3inodes(mp)) return -EINVAL; + if (fa->fsx_xflags & FS_XFLAG_ATOMICWRITES) { + error = xfs_ioctl_setattr_atomicwrites(ip, fa); + if (error) + return error; + } + ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags); ip->i_diflags2 = i_flags2; diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 96496f39f551..6ac6518a2ef3 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -298,6 +298,7 @@ typedef struct xfs_mount { #define XFS_FEAT_NEEDSREPAIR (1ULL << 25) /* needs xfs_repair */ #define XFS_FEAT_NREXT64 (1ULL << 26) /* large extent counters */ #define XFS_FEAT_EXCHANGE_RANGE (1ULL << 27) /* exchange range */ +#define XFS_FEAT_ATOMICWRITES (1ULL << 28) /* atomic writes support */ /* Mount features */ #define XFS_FEAT_NOATTR2 (1ULL << 48) /* disable attr2 creation */ @@ -384,6 +385,7 @@ __XFS_ADD_V4_FEAT(projid32, PROJID32) __XFS_HAS_V4_FEAT(v3inodes, V3INODES) __XFS_HAS_V4_FEAT(crc, CRC) __XFS_HAS_V4_FEAT(pquotino, PQUOTINO) +__XFS_HAS_FEAT(atomicwrites, ATOMICWRITES) /* * Mount features diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 6fde6ec8092f..6679b12a56c9 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1471,6 +1471,10 @@ xfs_reflink_remap_prep( if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest)) goto out_unlock; + /* Don't reflink atomic write inodes */ + if (xfs_inode_has_atomicwrites(src) || xfs_inode_has_atomicwrites(dest)) + goto out_unlock; + /* Don't share DAX file data with non-DAX file. */ if (IS_DAX(inode_in) != IS_DAX(inode_out)) goto out_unlock; diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index fbb3a1594c0d..97c1d9493cdb 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1733,6 +1733,10 @@ xfs_fs_fill_super( mp->m_features &= ~XFS_FEAT_DISCARD; } + if (xfs_has_atomicwrites(mp)) + xfs_warn(mp, + "EXPERIMENTAL atomicwrites feature in use. Use at your own risk!"); + if (xfs_has_reflink(mp)) { if (mp->m_sb.sb_rblocks) { xfs_alert(mp, diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 753971770733..e813217e0fe4 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -158,6 +158,7 @@ struct fsxattr { #define FS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */ #define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */ #define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */ +#define FS_XFLAG_ATOMICWRITES 0x00020000 /* atomic writes enabled */ #define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ /* the read-only stuff doesn't really belong here, but any other place is From patchwork Mon Sep 30 12:54:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13816289 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5767718FC65; Mon, 30 Sep 2024 12:55:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700925; cv=fail; b=A198K/UM9AC94hBEtQpunTrYHRmO7EEprZGggz18FCshp0wIvX5txEeZqcO8pM5vJm3c9/2HmQQkKl5K3ma2nwDjebaKS6nCM7FluZ2YlQqleaCYys3FTK6ehrQv+JWpcSPrWf8n9lN91CZaU6N9tO9g4uq5pxGxNc5p9GvJeu4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700925; c=relaxed/simple; bh=JrkUTFihLijuQ3CKHKbD57k2b9ovKf9VhqjJzPfeEHE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QZoy2z9IGIv+Fi2YK/oPMlXqSsr4fe5nvQwVmnxe561Upfd3eVm99WEW8rtr7wJ90sjYblqfjgB2MJdwdNZw+On/sAjYkWO9qd0Ody611+cQcVJmSLfZUCzguHcFRh2EFDeq+VM7QFVHXgderY//8mzFHaoLe7WW9Tv3x0/jIQM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=ENL9tMj3; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=QQ06HBaw; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ENL9tMj3"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="QQ06HBaw" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48UCPRZD024034; Mon, 30 Sep 2024 12:55:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=ho8tJS4uySoQ3rH9pb50OVfoTp67KlBFYaTfNkGTf68=; b= ENL9tMj3o3xNch3tlmX9ODs1SgiQ2DQdsmQqCQgRlFj111teHvZ95fOskphSSu9c gwNxggQFsrSENQY9mvFAQZlhVYUzkiJ++6rfYX/77j6uX9n2GQqpSh7uKTlezsK0 f7WtJQERBFkhcan3q7bY/2HxMXIGR7IzVax/rRoVTmdRBvC99BH4gOvLnCNqXSRq TaQ/FGJHipVAlKnXnv0D+Aac/1oNvJXnJOeQ1mBoaFOIxXeWgED79PkVCOHAvFhB +D/+ax1+Wi5Y4QQ+h6BGJXKNQUO53AnJVzgnjeRQfzQz/0uH1XBxf9uA4C1wu/I9 SEIleK664tlevWD43/GOWg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x9uck7hf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:55:05 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48UC9IKE012510; Mon, 30 Sep 2024 12:55:04 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2045.outbound.protection.outlook.com [104.47.55.45]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x885r6y8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:55:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rodSZWv1nHH2CCnw7QZh3mqN21BR56+tyN+p++KceKf8NxRlmoWAp+aiasotN9Ub/PAdY3WRaazmkfok1JMWpicq5OPqfLjfVdUgxgIOdya6Mb0wkIuJAWzA14qsR6+LR4YdN4us4j/Hsk1O+rqxtwQpDUL8WKQZyjPDvfGeSu7oQog/3iZU0NPu4CPi8EBeqim6idN4VrisOEQwNNnjP+u+BSlv1KCxicMsaEDlqQMqjkVbSFVz8/0+sAkTd/hSKWB8uj5TwuzEwxLkJR5UJv1IzF1I2PXWcd0DJ29uurLDkvyE3zxY6hGm8naiZQ7VsPLrndai8G+D7izM/ze2IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ho8tJS4uySoQ3rH9pb50OVfoTp67KlBFYaTfNkGTf68=; b=gIa/222BMCBxFnA7PkYFY2ht1qieqNMDjytgl920ZWXkNF/S9xQ0ub21tekfsf1fQt/Q/9gzOfLsxe5VXo+87fgbsVgxmI9LTz9kKpDW1frAItGyNOvmiCZlCueIxVxfAWx/62dFsMn3U+FyoTfXiMif5RZZtpjFZAjqr95WGYzhbmW5BFXNcvKzKPc3IjXENG+yNMR4wdXyPqOOpKx0n1x4eizl8NoIAnRQr/HAao2yP7YrTMz8hhZXhofvnxs+XoWI5too5mF1jl4TiBLSAujbDKkLegE8Arzv84kz4FDPVNHqc+8AA9sci8kBzEf3nK+7AHpe7havPQ9bymfESQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ho8tJS4uySoQ3rH9pb50OVfoTp67KlBFYaTfNkGTf68=; b=QQ06HBaweyl6zOvW7SkSwj0GFRitYrt0kae4cHnkMh8ik0ZhWbVLaL9dV7GaidbVWJtQAJROtVcJbWPbLdOvekDl1a6n7RhOxwVjylJpAZk4E3SORpBoLQpw+EGj1BLayRhF7d91NfezXlzpEW4XKyjefvBJDD5AxwiGMlUHLbo= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by BL3PR10MB6116.namprd10.prod.outlook.com (2603:10b6:208:3bb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Mon, 30 Sep 2024 12:55:01 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.005; Mon, 30 Sep 2024 12:55:01 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v6 5/7] xfs: Support atomic write for statx Date: Mon, 30 Sep 2024 12:54:36 +0000 Message-Id: <20240930125438.2501050-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240930125438.2501050-1-john.g.garry@oracle.com> References: <20240930125438.2501050-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR07CA0052.namprd07.prod.outlook.com (2603:10b6:a03:60::29) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|BL3PR10MB6116:EE_ X-MS-Office365-Filtering-Correlation-Id: 03de3550-6633-4796-7e2b-08dce14f18ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: QGhNAmRgdv+/GKXo45Xtf8340Q/VP+SaT9iVgbMgKk+kxCnNzA+5SIPvsh3Tr8BnBfVHokOzuj3ptb7bjFnzfLZp1MVP3VoHLq7AB7ZjCCZNFgIZV9grb7kv4UsgeRvl2DDzmnzE18VbE9/bUF9NCEwUxkxofvH7i05xU23xJrQ4IrQ0BxLhsBLAsENuVFm6TnPCuJa2/yzRrnVbiAecoYhB1JjNpv/zRKYV0qPYuszOkvVr+YyG+zV+DtRfPOs+v0Uhfe3Uka9B34zc7I1/KlznJs3QjqpFzkdUiDRZ1k7+jpX/CM9QxaKK09FhNsKUazQgdV94iIImjH6uY0SzkiwuPrNmz41Tdi48OsP3inD184gQzEjTlTsKyDpgkllk2ckL5rKo0T/E3lHiJ3plgW8BqlQQ8xxbylmbn09RDcY1z/gHbf2j1gA7m1x4ciNJFdrWLV0U+y5m2668Kwsd8wRWcWqsrRLA9MuvL/6yo3hN+jcUOMBMN92h35eHV3KqGPzpBYt9dmOwnXno4/+TDCMvMs1mPoDBO5PrulexaEQa1xFvMKEJeyJkBfJUI+m5uUrGQ4ow9a88tOZpKrPphY9K4wC0G1rLZlx8FI8ZZ3ZCuEeJxgV890fmiqqgYVgsrnconjrQASFgdfjFw5b1LYeAa6bf1x3twEyZba+OPsH5QkU1PhpDO/YnrzOsa9zjml+RrUbMgqUkQTW8euqx/4gf0rHxZmkz2Wwl2vW2YafXiL/SdsTFDH6b4crYMkBMqVA6AwRFK59s1oZ9qjdoekQMQgE+z00iJ+tYPQ/qTyWpm+2o2LWHBBo2b3iM0jTkObQJX8GLlCilP/RyirN5rUiEOovMrSpwMLhUKaEwWvJB1/x4fdDePOHDKu+4/xihNayvsprN/Jzk8oXUTPPzUyZM8cu94dtcOCOg+dk622Z/z0F/LNyKg8EmJ5XyU1cTjiBVQ4Ix3vxDbHwmh7y+F661QknJ1P5OzzgPLSq0X90fU7kNfXrNf0pI3v4Fv0G7wZ7zaWGmz8L3nX6wLaBrJ60gtFjRlIy0RVCdl6S3EXrh1QBKDo+3wiYThsOdKbp+yjig7t7UZc58H0VvvqOTrSMVMmcLuUelkokM1nDYx6jUnw89Kn2Z1MuMsT51gPaZRF2XlmgYUmK0R8oyA83aAHiZnSFCgDcTqjp5ojnsqx8YQaIs/DYzZOxoQvl6CjZBcoYto03WPpzw079ssu0rnGwVKnPp/b9LCs2GIFu05uyebnnAZT+6ClQpprmlhYLjSEP7Lx+2+dQIcq3OarmgXQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UJVFduhJqNzfmmG7glcC4NpNVbnRSn8QuucxM+NgD9e401eqyZQ2iHjpi2ejYjduR06hBQwl8EwrfuHAxmeoxM79jw3waitvvKk42ZGUGtAn2mHkJu6OZY8GQLY2gw1aeFq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lv+ok7XNGuPo72e94M2/c= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03de3550-6633-4796-7e2b-08dce14f18ba X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 12:55:01.4130 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +n13HJFwbC18FBKKbsX/pBF45jQVcFJxKvaf+C/aWbZ4pGVgFZd1hTmXJW6Cdd4RX0wfCPyu/ZyERg1NecMR/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6116 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-09-30_10,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409300093 X-Proofpoint-GUID: w_G3q2kzEQRnWsaach4wna2AZcpKRVMY X-Proofpoint-ORIG-GUID: w_G3q2kzEQRnWsaach4wna2AZcpKRVMY Support providing info on atomic write unit min and max for an inode. For simplicity, currently we limit the min at the FS block size. As for max, we limit also at FS block size, as there is no current method to guarantee extent alignment or granularity for regular files. Signed-off-by: John Garry Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_inode.h | 17 +++++++++++++++++ fs/xfs/xfs_iops.c | 24 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 1c62ee294a5a..1ea73402d592 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -332,6 +332,23 @@ static inline bool xfs_inode_has_atomicwrites(struct xfs_inode *ip) return ip->i_diflags2 & XFS_DIFLAG2_ATOMICWRITES; } +static inline bool +xfs_inode_can_atomicwrite( + struct xfs_inode *ip) +{ + struct xfs_mount *mp = ip->i_mount; + struct xfs_buftarg *target = xfs_inode_buftarg(ip); + + if (!xfs_inode_has_atomicwrites(ip)) + return false; + if (mp->m_sb.sb_blocksize < target->bt_bdev_awu_min) + return false; + if (mp->m_sb.sb_blocksize > target->bt_bdev_awu_max) + return false; + + return true; +} + /* * In-core inode flags. */ diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index ee79cf161312..915d057db9bb 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -570,6 +570,23 @@ xfs_stat_blksize( return max_t(uint32_t, PAGE_SIZE, mp->m_sb.sb_blocksize); } +static void +xfs_get_atomic_write_attr( + struct xfs_inode *ip, + unsigned int *unit_min, + unsigned int *unit_max) +{ + struct xfs_mount *mp = ip->i_mount; + struct xfs_sb *sbp = &mp->m_sb; + + if (!xfs_inode_can_atomicwrite(ip)) { + *unit_min = *unit_max = 0; + return; + } + + *unit_min = *unit_max = sbp->sb_blocksize; +} + STATIC int xfs_vn_getattr( struct mnt_idmap *idmap, @@ -643,6 +660,13 @@ xfs_vn_getattr( stat->dio_mem_align = bdev_dma_alignment(bdev) + 1; stat->dio_offset_align = bdev_logical_block_size(bdev); } + if (request_mask & STATX_WRITE_ATOMIC) { + unsigned int unit_min, unit_max; + + xfs_get_atomic_write_attr(ip, &unit_min, &unit_max); + generic_fill_statx_atomic_writes(stat, + unit_min, unit_max); + } fallthrough; default: stat->blksize = xfs_stat_blksize(ip); From patchwork Mon Sep 30 12:54:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13816290 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DA2D18FDA7; Mon, 30 Sep 2024 12:55:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700925; cv=fail; b=QJfdhr02Ny5r452I4b5p8klDbUBuevWcQ7t1ejFLgT/RFrvB5OTHWeKzwIlj0XkmiDslk8mSwCOwCeZQXOlgHGogkn+gzxkffekqYw1hAYJgNVeOoF3ejesFxWB2LMAXjDzjEAQO2/EmTTMcOoTrBcRLs6B1ZF3by//kDyz/KJc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700925; c=relaxed/simple; bh=qKWEsR4/e6Nb62b2ZwQQs8zKoeKPm26PXa3PReEew7g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=BUQwfTSn8m/c48oIdRVusaaTGD5M8cv+wFJfN+1DIuokuS4rlQV/Dg7oMCWNbQGMH2EHLXSngSyfhQY5u5qoCc39eBS2gypqpvRwtEETKzFxqQ5MQ/jR/eOeHkqvrae1W0MLDlBqQJb/HzJ9Y8v/TJAeeT8m33M4fwggjGvDpm8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=TbbJjAMP; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=TNPj1ou4; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="TbbJjAMP"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="TNPj1ou4" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48UCiqrq024890; Mon, 30 Sep 2024 12:55:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=9SijhOl5iY1lV3UpdXeQdVISoLFE0ou7Bh7/3E84Bew=; b= TbbJjAMPhZ5TBQETwvMMmvBvIoveDF+z5yoxz3EsNgaq1Cb8CSBhHKTjiQZSMsX0 DacYwDCSj2hl6feQ2xermGS3pOKCGs5+NQ5VnCOsGuRZmKd03X+8xHxVr6Js3SLh 9Te0vD+viClXCrOQRdbjo+69JQHmrH0D/ECBO+oQWSAPSyH5MhHut0lpq0eA84qx i9rwzqVhEadZpo2F30Fn1uZAUqvqMHAuWqTg3OS+v1Fifd6Czc6wjdWDSdjMyCyj KBP3y2pnzSUkc0W9uvW6+zvRmTfJQ2uT1kjfqoRYbinJc/oTb+zoxvf25gu5IWJ7 430xeprex2pB8EmXkug/cg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x9uck7hg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:55:07 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48UBulV2038629; Mon, 30 Sep 2024 12:55:06 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x8860pqu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:55:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YKIRqic9f2QD83KH0hiVPzxDYdJM0vbQx4B6VY2xV50u/T23lnFsWjvumQc5SApsdE1+IwyqDw/Zi+q6NJ6Nca6S1Q5gaazhkaoM+m/9Etm1FPHz1Mcq9xl7cVUVTrKPRVqPruXFMgHxvvIbCqTmkESp+6lxehuWWKyGTkZfoo8phYZ0Crrj93vBPDzj0ls8n9Xc1SljiXnmEQJRriUr0md9FqI3tmawK5V3aslSB/f+ze3q1q4ZtXKJyJf1Jq8iIAyGjQ9AzvRzST1PwD2z57xdLUIT3xgLyQ69125xSzsX+Zxy/zj6z9VruwgdH4K8mg+y9Rz96XbgoOggikLFnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9SijhOl5iY1lV3UpdXeQdVISoLFE0ou7Bh7/3E84Bew=; b=Ald94/JrFaL3uSVgPUUrrvIlvgYZTAt3fyRFIwdTr8Bbdbd3XOZRYWhhSmTxT1WTKZI/oRBHvj/Hq1ILfXYylEkpiTK3TTMI82/UpN87nN4fT1mCpAvME/EnS59WopLGTRRtx6gYae0Fh+ig6mLdcL2omTUqRUhSZEqoutVi8C6gQPM020kUgnSOs5o4v1F0TS3k+EyeZ3YTsLNPhM6Gt9noeHTEdFYDCDT1IMloQCgxZZswImTciNP3+fibWPwoOcKyZaSu9S84I6rqJqOqmROqp8g+xrdYEnD9OwcWf4hu6jMwt3F0ANQunNK2ohTXhY9DaeBBCAvNvMZ/OsQvOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9SijhOl5iY1lV3UpdXeQdVISoLFE0ou7Bh7/3E84Bew=; b=TNPj1ou4VtBnwz8KYn6ECrjbbMDcWNXNlNTzjjWubtudf3ocK7ydrlBU8JJjKKkZrXJu11HMW92BT16fRw/RcJG2VkcUQ2GLgOuRV22LShjYEJQMfDQeQjY5VX9lQzayk70HGmIEsBg8xCO/6zQw0gUMjXU0ifQ40ntuJRRndwE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by BL3PR10MB6116.namprd10.prod.outlook.com (2603:10b6:208:3bb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Mon, 30 Sep 2024 12:55:04 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.005; Mon, 30 Sep 2024 12:55:03 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v6 6/7] xfs: Validate atomic writes Date: Mon, 30 Sep 2024 12:54:37 +0000 Message-Id: <20240930125438.2501050-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240930125438.2501050-1-john.g.garry@oracle.com> References: <20240930125438.2501050-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR04CA0007.namprd04.prod.outlook.com (2603:10b6:a03:40::20) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|BL3PR10MB6116:EE_ X-MS-Office365-Filtering-Correlation-Id: 87cbd0c2-1e8b-4bf9-3d01-08dce14f1a25 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: A3NG3e/NRQmnWZWjXrUJ64Q712i91H0O2FIzoi4dJifjkuCzfdN8WKdILxLWoKbZjC1WpvWV25OPHeDsTpte+1rmMivr4zQlVb3iS3q6qngSRbPLEjPzK/GU62P1Ql0PTLjHXZRjqOSq1QTw9PPvKqXZRZdZqmx4WPPVBfMyxBLb5X09tBCRZSdzO8pwDSI+v3cGux//9iP2psRX67mKzvV6hvF+gOUMr5cXbeYRFNQgCT+G8GfZTGys7mlkBwq+lZB5M4nsI2m8fX9dGfCjyN387jcJkgGTlKtT769d40I92AGimZ2JOVKUguQLWXLzN8TWRMZXjPXorWZCM48+3lk6SYWFgqKDUBkSKXCN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799024)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xlawT83t+r/BMBowyRFc6SYc3ueStedGhCYIxeS7ldP2uvyXbTXAEIWu5Ugy9k165mighiWqTSIjb4hWX8uyxzcCybiHvxq3rRk+AZFRgKgbpms74MlP1/R3L3D88llgI/jRBeJ21PT8U/Iu91btlI5GFrNJRG6t8y25Q8hcUf34xScoON2JmzeZCV18nkxTLngiJ9KpJNsQQVMSV0CYMSV+KjxO7DCaYxIpInQr0Oajb+DOl/rVLcU8rM91A6aiUgOB0byyxJyvXYpPa1m3BTw9PhNINmLLWpKokbSh2hJGlR17kC+uz3H5F7H8rdTe7jAniVVJbO3AD6voDn6KZRwefoUk9B9XohJSxcsWrAPJ99JnVE9CxhK29hhgohU63uBy3XNVQRKCUMEz9euuPKS7lhHWZV0b+LdxsRSyKV9OTgJPAv08WQXcjxv50TQ20+DOyqdEQz7MoXvapZFsttKPVnsm0q/LvIrMSKuuvlgykzTSjxkrrmcVmT3N1wDsu+D22qRtH82SSxAnuIbf155ThE+z8VcQGcTbdY93OGnebxacCj6SIEUP3h0Eh3K70JBtEjVQkJT+qNlr1d5YxH8BRzWRdunGWt8KAuLWfXuz5Kdb7KmOLPV3CX+GFgIexaMhbbT/ogWmJ0PxF5kOPBodNSZSsZJIZHRtbGTlPUmgsD16Plpgyr1jtE3g5DFMsNokAGBf2RUyHx5T9SAL27ANSOyMHP69dhDN1sMR56mEKR7WPWLW2ht046qsFxFyuGiGUHgyyuBiU+1BT6KwH5XVECJI1LLm8ozIpsLpUgCiGuL80lIYNc3Q8B4MVTE7LfyTejpHYs0sSNWi3SmkTGczNQuVQXXZe7JLXJajm6YrmTJRyFgKAylT/N1qh3cYBwrwwB2tejI/1GMdxBptthsFh1QkM/FCOQIscik8w/cEYqvlXlsK62EDJajUk9m/WXnzaf2h5Bz+q/Sj6G32cnTvI6bfM6ZErImNiKOhL5aKU3MV7L+FS4piucPrKUc13FTGePQS9hjOkroYz2VfyEPqWtyFHav490g7HgshIqEMYY75GSPJVJ6Puwxqin6qf0FAGnPltUM0M0XK3lSLRT3hgpphzNR8h49evpR/s4qfOpMWf1qxDyfAeeA81s7XO3FU8yrix0HeR3Ppm+7xmTSMDfXXDlMz6H307Wbk8M1a8aaX1bhBL3RXOS4OivIUotrzS+KC9v++d8Jcli8yMSU19dmQ6aAvNTyUV8abG9UsiEsbLqjtc4HU4CkXqrBxVajtZEhvxSDsMcEdwRV4MoToQNM/Hlcy+U+6se/zECPvCC0dwHnWoQxEG+MgEVDCGnXdk+byWsd6B6x5z1RE3NoERJexGCI+a3DK8Q6ZGadZUPtHjQf4VM9ujsSRTwAP63uLntrzmsogoemv+8YRDAc+UlLHApgWPbpF76kggBP3Pvz0gaYleQvqKFEAybusbNWLVX9GVFx4Uqij5AYNCKGb2m3SDrAfqSMFvvP7I+OkCN0YkuWm4Xtf4aLr+njD7GWys5SCLrd3kR5TsBBcaieQcjULhyeXQYZPAQwd9rqq9o9dp+Eu+LrOrJMIWfFnTJ9cCYDttVbUsLPC5OEadg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: TQTxZwEm1IH2ZC0g+A73py5I8Bz9daDkk+tV4jtrB3ZA+0UqGGTnGDkfujK1cXlYjLFw7F1otV/JkhGIEpuOZL4gdo+nAVyleu1KYXo75cSkx0P3mFghine8DbKqsbSoh3PW4Zq427WZLjaaViDLQ8V5QXgr/qGwUY/cWDnoQ6//l9jyX2h2j5w8XbQOc8Nye3gwmE1OWDeIHOygueLEEbp7LDhprUtzyH+CU8H2zYZaAjdWuUwfrnXYL91PlsYwHewH1SEG5QtF4QrTv66LjZfnfywJ3aSo769G8uYcJjMWohtExZTbzoGRRjub5z1sudnMiWdnjePYIoMVeWMpbBlEgowqsPYhtLMEPbMEMjkawjiMdQeIzpO6nJIwbbLiGdmTrUd/3kXF2jc+UU6cA3AgTGDpVOI+Um1mHAGyNtTAVpgh5bB1jWnrLen9vowYLcdFxuWX+r+8bL6J98EaKjxJnIIUyeOkHkwsw25mCPwamqR2WBzuJF7B1xH+g5WHBz6huWnz//L72bnsR48TUiXeIw3/9t7D1cLN04KblUsGSdTp/P6X/ZuObuDJFAQDvZLqWO0VoiryDebEobr4psDO89scMimZTsT7M9iR5Vs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87cbd0c2-1e8b-4bf9-3d01-08dce14f1a25 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 12:55:03.8835 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: I41gDsnN6P7PRuWl7jpCBL8lUWTn8FrA89b4adaQ2F72MhONKHY9giwgP9WOLn3gMGm0s5y6RGD2Ak/3J69lrw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6116 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-09-30_10,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409300093 X-Proofpoint-GUID: Y5ZR2WFM07KIjUmYJpluTBlQOrUnmfYR X-Proofpoint-ORIG-GUID: Y5ZR2WFM07KIjUmYJpluTBlQOrUnmfYR Validate that an atomic write adheres to length/offset rules. Currently we can only write a single FS block. For an IOCB with IOCB_ATOMIC set to get as far as xfs_file_dio_write(), FMODE_CAN_ATOMIC_WRITE will need to be set for the file; for this, ATOMICWRITES flags would also need to be set for the inode. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 412b1d71b52b..fa6a44b88ecc 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -688,6 +688,13 @@ xfs_file_dio_write( struct xfs_buftarg *target = xfs_inode_buftarg(ip); size_t count = iov_iter_count(from); + if (iocb->ki_flags & IOCB_ATOMIC) { + if (count != ip->i_mount->m_sb.sb_blocksize) + return -EINVAL; + if (!generic_atomic_write_valid(iocb, from)) + return -EINVAL; + } + /* direct I/O must be aligned to device logical sector size */ if ((iocb->ki_pos | count) & target->bt_logical_sectormask) return -EINVAL; From patchwork Mon Sep 30 12:54:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13816292 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B434191F74; Mon, 30 Sep 2024 12:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700929; cv=fail; b=XXneZxMDocl5fIa4fwlYKyVkLgQJni73LWZTw9kwIA3Nfe5OGDP4peggdvYMO47MbVnMRB8pm44kITToek6V9ni/XkXGrWGwMk+YdGntL5jUqkeR6it0XX7Pj3t299aW8EJTfc6GmBikJA3Qt5OPzyqs6ABeXlBke1w9Kw3E9xQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727700929; c=relaxed/simple; bh=bH3davgQljoxEbWBABMjEiQXVDU3ArRAoaIcitLV5NI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Vzo1BnSR6eDHCwrLI+NYcMRK32+kdf+wrrv4R3jaoYmu0PxgIYRFUFZDF8voBa1N040hF7fxqQrcXLFVrD/L+BgsCGLrd5G9nHspdrbTB42gkGoJZK/3X45JI+ArSNHnBZLvnbS/SqF/Vn5H6oPBm3vBXrmBh2+lOKfHHUL3N4g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=hvYoy90U; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=y/5dO0Vi; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hvYoy90U"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="y/5dO0Vi" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48UCmVXE024828; Mon, 30 Sep 2024 12:55:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=N3pcIWB0SQX0AlI7OjorfM8qc5BRjjeY8iOnvs0mrTw=; b= hvYoy90UaS663gTuF0qJ2LZWjbxYEq5UB5GfqZMmrtWNr4K4/HAZmqNkEjd7iewL pr7nTKXGiazGx1RBxlUK7vizADuuU8TYAJCtY+CeaGNmjMlqZDonlfsVDslMNZvk HoGrZmc4CMNJjU/qL16aKuVFqouIsCWt0sFmc05QD7l1uqWrDhkPSPSP0yA3rFbi Q9+8jRJGXItoYTMfdgQ4yX0xeS9H9/dZhX1RlCq1NuLRUEgGBbOkA5GId/re54lH q0FOZUoEFQ3PNwk2qBI+KjtPe3SkNUvdmVO86cgGe2ST9hwvpyhuT3Sn00OqryG7 bTq4ND4EdBWMmJq7V3EJiw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x87d37uk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:55:09 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48UC8NnS040759; Mon, 30 Sep 2024 12:55:08 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x8860b8f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Sep 2024 12:55:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xA8WWH+uBAMUfzcd6Hg2Wp/cNTVBcnVh94lEv6Lm6ISfwMSmGCD5Fd5UxCr1f4VtmvRmBKkkZjgzkPBaNE5cWjsIQ4E/TrlVHSTL3ZaGCuGQxZ28i69pK1G+BzaWBmpCt28g95VHScbMbOpfqPdunKsSWrHDF/pOCu4dF3NAiG4oCX/JLxyvSjvPScE94VqPKzWcVNUtn35vGoHtB7xox8htyXlG/l5uFFsOH4Y44BKlgRla2IehM5Y1sB3UUzLoZV0pja+kPlOyMmOb23T6Otb9ZRIxL+EpXINJf6xCkAblzsMmxFcBr9gW5YDlNMCyR3T7PAJZosDGYnsIf9rDwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=N3pcIWB0SQX0AlI7OjorfM8qc5BRjjeY8iOnvs0mrTw=; b=P6HcBHOh9A43R4j7EtNlcZN4iqrG38kEwUkBK3TMgG5230XIGGwQ/k7Qh/mVZcksluJQR3kc2AKvk+Bc7Nq3eoFhBd3a35O5M0IKRHDqp86azNaNR9f4QDmWLmzVzKq/GIfnj5ClN7AOwcZiaRcLgkdi9UnyelqgZSwygjnzkaM4QSYKtzsdsg3EGpuwnjvG7TIbyAJEXXgcMw0ZbyeoQM6g58e/4GXLXirJCOTNNeUcPs4xD79/7XfhwQIoCo8yqbmsSFcYj9oczJ95ZrEwXg4SNmmCv8HEJYacT+PWkmZmeEnHr1Q7T59pIHqfSXp6UOXGAdfav0Q2Fiag/cDddg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N3pcIWB0SQX0AlI7OjorfM8qc5BRjjeY8iOnvs0mrTw=; b=y/5dO0Vis7EtCHi9jg+DlgTvXwJjSz0/4Cb8qCOIIWnkLVQjNbUnVH89UZsXj9xWxKCm2zsxcenuip49TKd9NBIxuRFVDJFXwI3huNDlthmDNH6qYoQ/9ada2vI/xlWxsK1VfLusIuK5Fquhdg2+sBwVrWhHain2rW8PRBJ2rrU= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by BL3PR10MB6116.namprd10.prod.outlook.com (2603:10b6:208:3bb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Mon, 30 Sep 2024 12:55:05 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.005; Mon, 30 Sep 2024 12:55:05 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v6 7/7] xfs: Support setting FMODE_CAN_ATOMIC_WRITE Date: Mon, 30 Sep 2024 12:54:38 +0000 Message-Id: <20240930125438.2501050-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240930125438.2501050-1-john.g.garry@oracle.com> References: <20240930125438.2501050-1-john.g.garry@oracle.com> X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|BL3PR10MB6116:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d442589-ecde-476c-40d1-08dce14f1b4a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: LYzK+Lcgh+CMPQni5sN1N5i2P4T0Su2LtcnSiuCZkWCB+SRJ0t8PV65vcfvppiexPbzwo2pIlZnE5CCRMe9ZXH7b73zZ8/iBTShOHFeoDCgX2+iwyEAKdLTa2YN9eTDt3eCmCk5oeDa9D/MPgO7CCZNnZtleTp/DwEsJ/xOVjG5is0z/D64//KjjdZmxpjkXRC1pUHqaLg0KBLOUntUCssqqW5ewFI+4NAcTKgGOGxTCNS07h7dMN9LY5MW5NBOsm4Jpkv8w+hdpjuxYarKMHIF43SP+QJJnl4PbEkaFMLLtezoxSQeDFnmRMBsT26i+cax6rw13pHEB36um0aEppVzb5XxETEruZSVsJdbdfMIZt6somqXzfit/zFzsgLFJD5RVvJ31A+Sr4uooK3sjU/pR9RiCzG3vA9q/luvnwLIRH+CqW1NhkQEK3FcDTdnGmF5sCStxdeu0fDHHET3gshTrxLcH7nMxxaJJHAwEaizZ9G+wHPy3AuNfwcm1wD843y+YMqKWG4Ctx717PR16QlJuKBHIWZYQTjzVC/Q18aN9qnPhbM5ShiXFPfHAgBrQUZytxiWS2v4eGGHBrhGtkOj1G+VV675Bu9pesz5qOdl+ZJRxgxzTbFZxfaXvwt1bFfJq0leyzAoLOJPDGOM5Fy8y6k2aFHivbRVv4bzgMCjZ3WEkVl2dQSht4/GMIIVMKh1BQpX6GHBBgs2eo2RTZGOEcXsVpvHDw94ZMUXr/7l/UMnfLxMH5KoZMVLFqDsO6+oPMfKAIqiNaoesZ2T+09Lwve+LkGatPdqlC47I+GSonoRy8vh+eQKO9nFWJOSbds9y68XJxVnQNKctUUGq2gqMBvqVfj4ekS+QHExKqNq80KgL8ngFycCvPNA+xSMzb90wMz0b3S8dM/Qt5cRyUGnsxULkjMtyb6iqlmAYmn85m8904ObYr7qC9waiNHrlISvd41OBLQE7REAF3fMCVsm6BOtmdqzugIuS4mMfGTPHP0uMtenHgTXOxAgnM0u5wCHp7qg29bECaH7C9MQShCjhO56Mgl/IDzaubr9mc9PY7UiKev13whV6F1Vcd64S9zkLpWqiGQ928MK2+xG3339DxIZpp6AyBjVQ6FQfNpb0NNQZvB2BPuiONdRueo8CyAIhdfKkC+8AGUta64cY/jIezzlXJab09i+Dx3llPgJuEZrK3OyI6WOSVBRE5ormvzf2R7lPneEmL09SHrXpw4z8zDWIQemJFsjPn0jOmpEXPnsoo4FCfEZCjK9RsxUmfYoO03WFKcCPG0yyzRpJkA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M2cMAB9Xelmv+6Wt4kaxhneQySWEoUUlsJBRFshRCB5BmlKI7pOxmxLXnnkvW01jjp44ghlKOAarz5VF8EiqQy1pktFUGpjrjNorDE/kCo+LNOBsiCFOIlDJDRoUsZSnOcKbl2aAtiUSeMrN7QfBt/rfID+ePuh2mFzOaT+vLgf7430Z/SmkSvhhN7WXN9LQpsYMrZRG9/Im6O9wjQA/Kxt0CmkxUW+TqUkRT296RnDt/XVU/2E2092WoeCE1u3KKlppNcrgV2K4wocBQ2M9E8dXt4zRe/glXZ4G/6AMTXoChAyNRZH68Sg1TWv9Zmd84lnlyL1b8M7o6hwJw4eRIo0O73+K27QSqrPkamF8Wknm4qZt8esj+6tKtFHwiFH74THO+uckung18OncJSfK34YWOXV3hcmvY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9ALbmQcgG9W7Xs3md0hXBqRdlD0mnIKPktxEbDSDU8WdIOAlfMs6fXpko4W0WpMJwYCX5UzK+kS4QP7q9CHd3pEd1lWDlwEsQrZjKV6WWYE9d+EE6cm9oVgTGNMW4hlaQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: WAhbBxKuIchopP0DU04O4WXBY68w8sHO1TkNMiRL1eue8fk66RnRoMEU7QNQ9OM7zMcZTEmcJNWuN46BeBZBAnteeIKolkkSlFNc5wp/PuIYO4nrXWk/nlapNKsi1aGkxP5pz0yfV5Znawu+rvXzZfYCjGc7bylU04IC9czCLWJ7K8pHYPeNIYJS7Q5ibO2TGo0ECVPTjstaHnwixgvb3D4PlUhSFJnqB7BRyaGcOP1S66QKyjmE1hI68U8vyYh3gBIx39sXkEeXCnYCszF8yMCedIDOWgjuI7sE/HdgUV9NgVYxJvRq0UuwRFVLmg8p9EXNaJwYCVCbGZVojUPKn1KNIbQ2ggz4PIzIEBWRSKHkJHmgJc0JdBpkuKR91sber3bnH7KpzfWinWtYjDhcV3DM2R8sTwe13JZQp+bcLTsNKW0R1div7uvuvcpEP6YQC+glhEqfOB4/wV4oI0RFVAYXtm8Nf0sQpYkUAy3aUJ7h6G4lqNnQGeBXZFGWpKJyiC1vhUVsNHZJCD7Ew04ahzO2LWMvn4swdIRraCipVU6JjbBX9iiiQNgeRxMgyAEaIKVlLhtJ/j0NbIRBLbIUCGNcl9WNjV54bim1GN7P6GA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d442589-ecde-476c-40d1-08dce14f1b4a X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 12:55:05.7482 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TjIxRtG4LODblz5S/7XT02E0AsMPXFPNk+Px+cgw84Oke/WAGpfeXN0R1qDOFBPmRjLcwrqUSger4M/nqOovCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6116 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-09-30_10,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409300093 X-Proofpoint-GUID: h0s6dLNQyqBQht0Z4A-eTv5oRawPH8sM X-Proofpoint-ORIG-GUID: h0s6dLNQyqBQht0Z4A-eTv5oRawPH8sM For when an inode is enabled for atomic writes, set FMODE_CAN_ATOMIC_WRITE flag. Only direct IO is currently supported, so check for that also. Signed-off-by: John Garry Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_file.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index fa6a44b88ecc..a358657a1ae6 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1208,6 +1208,16 @@ xfs_file_remap_range( return remapped > 0 ? remapped : ret; } +static bool +xfs_file_open_can_atomicwrite( + struct inode *inode, + struct file *file) +{ + if (!(file->f_flags & O_DIRECT)) + return false; + return xfs_inode_can_atomicwrite(XFS_I(inode)); +} + STATIC int xfs_file_open( struct inode *inode, @@ -1216,6 +1226,8 @@ xfs_file_open( if (xfs_is_shutdown(XFS_M(inode->i_sb))) return -EIO; file->f_mode |= FMODE_NOWAIT | FMODE_CAN_ODIRECT; + if (xfs_file_open_can_atomicwrite(inode, file)) + file->f_mode |= FMODE_CAN_ATOMIC_WRITE; return generic_file_open(inode, file); }