From patchwork Wed Jan 24 14:26:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13529285 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 D366A7A717; Wed, 24 Jan 2024 14:27:19 +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=1706106441; cv=fail; b=uxKetRsZsSwb9aLk0dHge+RNN4YpnXnXof4nURz8vjchaygtVdOejiS+1lWMAoLwneqbA+qLI2Tkc0FYmBUxMXQWRi3k9EZX1s4/RkRBDlBEWDZmCJCZQmdZy/IBBXbzxXDNTATU8zxoS/S9aIVbjjvTmKs7G6XPlvjRC8fpfh8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706106441; c=relaxed/simple; bh=1F4LDydEgnez3sthhEWkJHq9EBmg0YgzYniy2Cs71jk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=S06FYF2ooaiaxMpjTMTd49jfu5vVAqkDbuOqaE6kQIPOgbvrhDfLqRRpac4GEQMsuBgB9NmZbjVNRS98anAuHegK4JakamGXhIKyPk5TnNnJxMOwPp9jJ0ykG4Og1hee2CUUYR6pFjbeDRWHPGnK9MZGyDKpTuJnfcZ1vbx/5M4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none 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=IpzFDCTi; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=XOIm0UvG; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="IpzFDCTi"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="XOIm0UvG" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40OEDsLP031407; Wed, 24 Jan 2024 14:27: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=JdGHMEoXa48N6sUic+VoCq5TSyjLvTgzgCyyELdJUjk=; b=IpzFDCTih+yYU0YEleQlnRJqJuhN2Pqp17iLeur9LHgZ2VFtVbt3Stg5doW6c40pqp2v 2Qdps9FTkdTNdU3L49kXyAAI1+4SWhmVfuyhoZrh/WJXKPZ5kmiZvLVezlysBF/koQG4 5nBVDKi645DpTl9rjLfJYjWzHlS8Yi2p6WUfp2D2/wCEc4XovqHB83LfJXiIkdEBeWs5 DUHT+kHZ1EqVwgWqld+wGlbjcFykfIhwTznh0sDWM8MIsAOdZHQD6gRJqertrMfxnqgf hcmD7onkDMSMc5wp3rrKids36F45ON9oaIl6xl+uPV04zX0BUCJvm1yu0IpeqnJ7HniS Wg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vr79w3tyd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:01 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 40OE44UL031478; Wed, 24 Jan 2024 14:27:00 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2100.outbound.protection.outlook.com [104.47.70.100]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3vs3248nxk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Anyr2Lr95HvvRIei/f0FswMsitchXd6myCHxw+s1Q9G0dnZ6nbk9+DKrRMSxhqHzQ81EUgOY+ledYeTbE2pPlAFb6d2LeHObvet3QRU5C+ELkmYYRSIRRHCraMC9Qx4NCWBGF40XRVGnUyhz5ehmT/3sDfIdqdaowUPEkA7djgiwfMe4WWNbG1R9HuGoqYRLANYPWJIkb3uRoaWVhRBtnD3C0Lp7r0uKUL5RYc16eNIwh8WIRVduxrhn9F1QdDOEkQHZdurBelGVuw8RzzhmwQauZ5HItf3kckIktMAlnfAZNtRVOwk6bBCK8bsX08eTZOUsl1N+IAK/Nar2PxvEHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=JdGHMEoXa48N6sUic+VoCq5TSyjLvTgzgCyyELdJUjk=; b=EBkGmBAAgorBkGifdgjlzDIN5GjUF1klCV2O+Huv9N4bYEwH27AxmgvkFi/CuCFIYt/K/DfKxN5+jckZtIZWLuwKIIlZyRRb1cjy359R5M3nBypPVSJ8g7Jh2u+/IS8Gb3++bw6bvTDfL09p/yQhe7otLM/zXRWWV3iB975EHpSsZclshIbIlX5OU2b2akP7/m2yTxn0KJHnWUaQxmN4zeJXp8JbYsio2XPw/WbgUfF31+VM9LnDoHC/C9acZ05qaHLK7lAQeQURQW0twaOmyRG1OD11KT9f/5sWcxyRkgstTrK//tW5iNqDkwMw9OucZOdmwvuk5t6T+0Pm9+ViIA== 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=JdGHMEoXa48N6sUic+VoCq5TSyjLvTgzgCyyELdJUjk=; b=XOIm0UvGuNNi6HPZCVvNIQ5/3knJpSDL5GINux6R+B3uott/TTEiTenz85looUwi5i07aE1bFk89m3zH+b6/ndgDYP8SY0S/M4+T8TQ+xO0Ru+mWAYdvGnOa/nK/k4wE+NV1Y4VT5qy73iQYAMEgrOmNSuXwimewyhGKHTKy3RY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB5212.namprd10.prod.outlook.com (2603:10b6:610:c8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Wed, 24 Jan 2024 14:26:58 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c%5]) with mapi id 15.20.7228.022; Wed, 24 Jan 2024 14:26:58 +0000 From: John Garry To: hch@lst.de, djwong@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, jack@suse.cz, chandan.babu@oracle.com Cc: martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH 1/6] fs: iomap: Atomic write support Date: Wed, 24 Jan 2024 14:26:40 +0000 Message-Id: <20240124142645.9334-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240124142645.9334-1-john.g.garry@oracle.com> References: <20240124142645.9334-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO2P265CA0251.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8a::23) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB5212:EE_ X-MS-Office365-Filtering-Correlation-Id: 177f6864-3bf2-49aa-2310-08dc1ce885d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0x56Cz+3qNHPsnlrVvEamqOR5QJx5zRONma7uLqFGOMlXYNhcb03G9BmkeTPRqLCsca0z7jb6B1WWWOVybVzKdIxPRo7F6lUZB9+k3i17f8GTCjfmu9LxZWM1gLm1cXdmHnm6xj90ZGfObchJY6q543dQIq3v3mQNkWPKnBAUC5tDXLzc5J80lqYpzfVpzpdCUwq3OEA+6VYET/fMNI0tC9Gw9X7oD/hZT8iV7cacF50enVBAnapMbaodoMP7cs5+IBbQhmoYMrTEExMd2OYVF94SngxgosZ2Pzt3qd+BQwS5jMXlaro6R+qbjnLMNSrw6Rs4EjHkP+sA5OAZhH42qX0VXeautozvtzJqU7BFGctKf+jUK2HxW+r7Eo4e5TJcAoxwb453D3iq9tNp3YrJKovG4wSrROzIR8vInq0ZHDHSNAij1N63Raws85CuYD+DMPPo01GkgGltmW7TqRhZxXGAZxZXF2xP73uY/dlv+CgX0iJ/Sxzg3+ySpO9WY5AJX2/H87Gr/k/WCWZnbvIaQYq9CqsUlwnYC8Rh/KPs6rhsCpjV8WwXovk7b8sOl9B 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:(13230031)(39860400002)(346002)(366004)(376002)(396003)(136003)(230922051799003)(64100799003)(1800799012)(186009)(451199024)(83380400001)(41300700001)(36756003)(86362001)(103116003)(38100700002)(107886003)(2616005)(26005)(6512007)(6486002)(1076003)(6506007)(2906002)(478600001)(6636002)(316002)(66946007)(66556008)(66476007)(6666004)(4326008)(8676002)(7416002)(8936002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gTRNx11NvUzy4vWQWfUaN5ZUwJvi2TUqpm7WJ96Rn1VTi0wsf57tJ3Ix9oHUEbOYLY8Cdg+YDg//u1mIK689EIroF8dXYMIy22nvldVTB5qvAO0ty6FkRcNXavdEk1y+cEDPDsX1BHBlpiB9wmQKwq2Pm5SUb5wb0ZCNxJgGNCPWoyqLAqBKfLpavJMAhGrfSzSOda33XaQEr6hbTkTtGYFMMPvJI1EforbPO3feDE5CGUHBDqLnALRtirl1oMoStvzWg5Ovm6edX7VWraUU3wj3Ek2TNrZWR1nJqMBdapTmc9Br9EB/Y2Z/5GNg99GzARGSgV9CYiNN+meMKWP6uskmK49sQIWFPdZE/UUTV3BqVDpS8wODVbr7RayKrOqcevHoW9OV/WkKkhtOmP7fX/VaEYRuc6L+b9GCzS4qbW8+pu96JJHim2Plwvaa2I6snOccxG7VTqcDSpmCdPcPmj0oeQNDIMy9n0tmAshuV21kojd9b+98u8Ne1Mo+H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QQAk6SgqsxY6AQIotOxeAxl4xIQ55MVqRSQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: aaLYAtzhDPggR+Jik9KvIl6R7fmVX664Jwqi1BXix0/rwGARm3CFpHyDQCCoj+KHVCl+XLaDbJSIE5/M99ST4egvl8EkDaWpR2oFMI8Fc3uCZJMwffg+LNBs6NkWB75fJF4HIZKtPEEkOtdl1+SCCiyLlSS60j0pZEsUBIiVTt9yfrdIoUjXbv4nPtA8BiT7dUurVmST5LaDQaDqtS9LxO0qNso6+B4RTgNAoxcnq3ALME2JR7kHB+G5X5afjN1TMOaur4q7DaQO9N15TgdK4FgGbUtZku6uzVuIEqxgoyMIav9hC6w3GekTCaA7OybDx9YuARrs90z6wyOIwYIML3QsS5N0CXOz21xvNx+8BGu6zxRTnD93XVq0dxHNNyUgBqEIJsrxacEJWDlB6SLp840fXRcVw+rLQFUa0z2QHz7rgrIjzMa4QV8CH4UFoK3artd+i1VxT1Cp3T+HgcJ4lNXePGQIyVM7TaTv/jupSrffURrJ+jcLM7/dVuIz1ptYTP5D0sDUSPQAKtXfuJf9fVX3uTqSLmkDeHjk0vValkeA3s6n+gxFdJotHIDFbt6UoX8T2oWbbwa5qDsyW+ltzrzPYvbf5n19eszamf4Xz84= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 177f6864-3bf2-49aa-2310-08dc1ce885d5 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 14:26:58.4833 (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: 5HcBySDtY1ULErI17hvpqWapmiVZUL6FRQjT3G/OZyaUawC0kU1xdZLfHkN62c97XI6q14hzLiiz9w5LTUP4yQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5212 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-24_06,2024-01-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401240104 X-Proofpoint-GUID: 8hcAyRpJxxR8cGWoZZ2mqznduwYdNHLv X-Proofpoint-ORIG-GUID: 8hcAyRpJxxR8cGWoZZ2mqznduwYdNHLv Add flag IOMAP_ATOMIC_WRITE to indicate to the FS that an atomic write bio is being created and all the rules there need to be followed. It is the task of the FS iomap iter callbacks to ensure that the mapping created adheres to those rules, like size is power-of-2, is at a naturally-aligned offset, etc. However, checking for a single iovec, i.e. iter type is ubuf, is done in __iomap_dio_rw(). A write should only produce a single bio, so error when it doesn't. Signed-off-by: John Garry --- fs/iomap/direct-io.c | 21 ++++++++++++++++++++- fs/iomap/trace.h | 3 ++- include/linux/iomap.h | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index bcd3f8cf5ea4..25736d01b857 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -275,10 +275,12 @@ static inline blk_opf_t iomap_dio_bio_opflags(struct iomap_dio *dio, static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, struct iomap_dio *dio) { + bool atomic_write = iter->flags & IOMAP_ATOMIC; 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 size_t iter_len = iter->len; loff_t pos = iter->pos; blk_opf_t bio_opf; struct bio *bio; @@ -381,6 +383,9 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, GFP_KERNEL); bio->bi_iter.bi_sector = iomap_sector(iomap, pos); bio->bi_ioprio = dio->iocb->ki_ioprio; + if (atomic_write) + bio->bi_opf |= REQ_ATOMIC; + bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io; @@ -397,6 +402,12 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, } n = bio->bi_iter.bi_size; + if (atomic_write && n != iter_len) { + /* This bio should have covered the complete length */ + ret = -EINVAL; + bio_put(bio); + goto out; + } if (dio->flags & IOMAP_DIO_WRITE) { task_io_account_write(n); } else { @@ -554,12 +565,17 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, struct blk_plug plug; struct iomap_dio *dio; loff_t ret = 0; + bool is_read = iov_iter_rw(iter) == READ; + bool atomic_write = (iocb->ki_flags & IOCB_ATOMIC) && !is_read; trace_iomap_dio_rw_begin(iocb, iter, dio_flags, done_before); if (!iomi.len) return NULL; + if (atomic_write && !iter_is_ubuf(iter)) + return ERR_PTR(-EINVAL); + dio = kmalloc(sizeof(*dio), GFP_KERNEL); if (!dio) return ERR_PTR(-ENOMEM); @@ -579,7 +595,7 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, if (iocb->ki_flags & IOCB_NOWAIT) iomi.flags |= IOMAP_NOWAIT; - if (iov_iter_rw(iter) == READ) { + if (is_read) { /* reads can always complete inline */ dio->flags |= IOMAP_DIO_INLINE_COMP; @@ -605,6 +621,9 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, if (iocb->ki_flags & IOCB_DIO_CALLER_COMP) dio->flags |= IOMAP_DIO_CALLER_COMP; + if (atomic_write) + iomi.flags |= IOMAP_ATOMIC; + if (dio_flags & IOMAP_DIO_OVERWRITE_ONLY) { ret = -EAGAIN; if (iomi.pos >= dio->i_size || diff --git a/fs/iomap/trace.h b/fs/iomap/trace.h index c16fd55f5595..c95576420bca 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 96dd0acbba44..9eac704a0d6f 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 Wed Jan 24 14:26:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13529291 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 89AE8134738; Wed, 24 Jan 2024 14:31:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706106686; cv=fail; b=Ae0yOxcWz0Tj+tFQfaR8d4h3rFsqqnC8vSeBiVxW4j8j1nKq5si+C7ozbyobJScDxCDNsBizfV12IkHucjqbKlUE7w+xmyszjNKxzC+ZsV1iVsb38D7lmNk170vp0UZYKiNOalgKGD3n0nvFNcZ697a8owt85rN4zw8XbQhXaiY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706106686; c=relaxed/simple; bh=AWQ+1Sj0aG5iJnfRsuFkjWtV9Wmvyn7jlgiY2EZpOKA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=W4DVfP+70N2EBpr+qSeVFJgom7Gs6PpfcEAsaUTUf13zeGCU2jISKmnEHIJ25hrHuuJcyDEv3FuIkK0j42Qr5z0GspXZheUP/iG28vMPfCQxrIvNlCeQjFpUYdIONP6rByGwCfqjq4H1wEMuZlWZdV+Wj7oH7S9JxCn4Y0lTuz4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none 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=IMy6Jxm8; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=awhA7DGM; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="IMy6Jxm8"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="awhA7DGM" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40OEEJTc013261; Wed, 24 Jan 2024 14:27: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=brgOp2OxL371o6OTal8xLgcw124BPhdkdF61p4+jAnM=; b=IMy6Jxm89oLJ+TefIBozYtvZiig7ZPi5I3MwRHpbTMP7rZeJrsqbTY4AiD3jZaHV3S10 kola+oXY9iIdsD/A8XQuvEBXRab0NFvr1k0MHX/jOZtvScG55NdZJrdBfc5bu1w6sQmT wd4XGKyZAdWbWNmwxuwYRoHktYJDFaV/VqfzcUHBR2zcPaKN7IHWYNtlG1Ot7iYeM/dN caFFzcq6kgL9P/qOwFXEcfiPejBkORnFBZBgtsOQJhePVg8b485+SF6ebqtptCjoLsNN eWl/nWPY5VrYQgOAlQhlk4Hy8OqBi6BfZ4v0IM7rxIovofzMsmQ/qTwH/3MfXm6M6sp5 4w== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vr7anuqcv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:09 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 40OE1L29029572; Wed, 24 Jan 2024 14:27:08 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3vs372rr2v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HGzP9I1S3wTfBc9Ar1shLhukZvOQIObtjY1gBaT63XZ1QtGrU153Tpb5e3TatdJWAt6OsWmIef+krX8thTnD6zg75e5MA1kMO56xmasYtjQw0fwMbkLwflzbomA0ZFbgzMekDFHt5GdjhCvpKaKGBHt5fk0MasINpJuzbN7/uo6pj8urmNTk1rDKRFOevwfOwxGcGcEkKsv9Y7VhLXBu/zQ/6jGNGWy3VLwKvo4RPQJ0H3bps3bIgEFeDnn2EVEWFQ48b8NZpUf/HpigRCDWxBOyqifcT7ZoAKCguxyccz9+cJR2xjbLo2CpHpIaCr7duCVUB3EgUXpM+QYDPAFUPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=brgOp2OxL371o6OTal8xLgcw124BPhdkdF61p4+jAnM=; b=DpAniQqlGZbciQTG6xnHQGO9Eq/k92NnBcZCKFarrS5FGDYPgg+4zofrmVJyNyJGE0LYXALk1HXGzDxyRFw3c0oFnU0s7qhbkdNCaULA17mKpcSh408x6mR4oCkJp+TIg4YWfCN3lEEACYhFWYTo5JGfDhmGTGnc9M1PZcqXQFR00+bJXeEBMiGQvs9zi0skRijeO2jF8V/uy4hLQS5t06MPH5GJ8W6ADPxmj+cx+G8UuKQt9KOtZeyLJypG5LNhZusUUZZkBBb3/miJYxuMDc7xr8O/HCvcboVi+DG8XQchrvQiwjTjcCLK2iaKjyYKs9wG/Wdv30HZuwZ0jIip4g== 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=brgOp2OxL371o6OTal8xLgcw124BPhdkdF61p4+jAnM=; b=awhA7DGMHbiJd6JtGpDBwuVfA8+6SoOk3NVEtR3teiVK6JAMv3ndCt/7fv5ZnFZChX6BLLGqnm3snqDFmc/cProoiiHKIXR6uHn91X6O5qAhi89PrXEWv+GWkaEJ26ImR9bFq/jherle+BfmMUVY1fyE5qko8RLEhKqWXBDFdVA= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB5212.namprd10.prod.outlook.com (2603:10b6:610:c8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Wed, 24 Jan 2024 14:27:01 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c%5]) with mapi id 15.20.7228.022; Wed, 24 Jan 2024 14:27:01 +0000 From: John Garry To: hch@lst.de, djwong@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, jack@suse.cz, chandan.babu@oracle.com Cc: martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH 2/6] fs: Add FS_XFLAG_ATOMICWRITES flag Date: Wed, 24 Jan 2024 14:26:41 +0000 Message-Id: <20240124142645.9334-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240124142645.9334-1-john.g.garry@oracle.com> References: <20240124142645.9334-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P265CA0141.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c4::11) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB5212:EE_ X-MS-Office365-Filtering-Correlation-Id: 525ce835-b02e-467b-727a-08dc1ce887bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4GCDjVH3vEeENEUcHvdJKdTgQ55KZOR2S34rrwQ59hjq0nCbhYitw0kT1oZoSxHxWxudz/mGYD1UNNWaTaySjjHilbAB6Tk7yg0oNGwEEXf/Cw6mtMTGGcbmgpQZgVFF4ouYLAf0NuTBqYM5xwd46OhBMHZvU8W/q5nXSG1B1ibKT32mdJ1IL6IbJ8x/98oH64pSd2njKxIIKO/2dVsH5KljLPcbqnknqpM46O1UGgxDBsDxgM5rYh5aXIpChVWDB1oacFPpbwjq8c6MmIki/AKah5oPNr4I0wMz8c08FkmlrVpCfDb14Gkk2GuaLfCY6B+fUA3W+yG3DeGlWsFo5MjOEXNl2dP5L93IqH6FSD+aqIlHS8eRt/yOaaRqyxCSF01myqYKPu7Q/4vVAf7saKr+T+SVp/NirSbhjjfCV7RNLQghLWiYt+yDEcgXrIbwLAfi8GAosBxK5SoRo1/SmqS0vmWc8LmdCz+S8s4U3DVf/kLMEd8H9/PkZETYeZjLY7ndzIhPpBU/6G+is+19Ry2pDB6Xgnzlq1P0eLEnHKfX2kql4icurGSCVXivluLY 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:(13230031)(39860400002)(346002)(366004)(376002)(396003)(136003)(230922051799003)(64100799003)(1800799012)(186009)(451199024)(41300700001)(36756003)(86362001)(103116003)(38100700002)(107886003)(2616005)(26005)(6512007)(6486002)(1076003)(6506007)(2906002)(4744005)(478600001)(6636002)(316002)(66946007)(66556008)(66476007)(6666004)(4326008)(8676002)(7416002)(8936002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-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X3Ufx4K68dzskmljQ01PKfoVzYYjZpMdTVwe5/Pr/fLEYg1MXPlVInu5XANESkbdSCOKn+W/LrpTGAu0aN+N0gGQ1faiOi4B2zV/7ht7S3C8bIGp6y/i+15157ZMvAbZG92oP592IC336G388j5H5urjQgZoTQcSduAjxPR/UzttuggV/D4/kQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 525ce835-b02e-467b-727a-08dc1ce887bf X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 14:27:01.6008 (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: ZSfqX6LmuB3kfMBMvmq2V/RFNBfxRGttNbFiuM9GjM/U1qfwoP1FTPXZFXvs4rl9CfrhJJqBe0y2FH6/UgnaWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5212 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-24_06,2024-01-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401240104 X-Proofpoint-GUID: 5tqKjQQKyj4h_M4ozfeoLSD-yJPHl15D X-Proofpoint-ORIG-GUID: 5tqKjQQKyj4h_M4ozfeoLSD-yJPHl15D Add a flag indicating that a regular file is enabled for atomic writes. Signed-off-by: John Garry --- include/uapi/linux/fs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index a0975ae81e64..b5b4e1db9576 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -140,6 +140,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 Wed Jan 24 14:26:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13529290 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 5AAA27E76A; Wed, 24 Jan 2024 14:30:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706106627; cv=fail; b=eXv1QtsJa08FxPEkUgspKh8n5Ng2+k1VKDdoCCjurBzfJ+dspduvFJaUs80qWXSGSRvkZErbn8+EBHYRxVP2q9yvlbFBTzDIdcELIwIBQkiXB3jaFs24d3XEUSknVrxb437C7vzbR1AMiEnwnVok0lYU2vi48nsRyXDE3+DO3Ro= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706106627; c=relaxed/simple; bh=m11x9zr2c7WAhARSL2qIIW4lHdhAo1t4TpvvwwO/1wE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fI3D2vuDVYAtY7DQHeOI8jnwgvO/eIQ9akAv4sM6L+Y4D0/eEJ7omCgC8FU3OD9ZCPk5dwQzXM+FuBOvX2rMGQR1+80k0bG7A5PwUc3B9fX/cLyBJS3nXPkHSaxszxHfTVTJMYJRDm3Vz2QxJcs5qJh7EhHlLOqtjgqJXqBHwRg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none 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=nmlNib+Q; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=MH73LyKk; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="nmlNib+Q"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="MH73LyKk" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40OEEIJZ013249; Wed, 24 Jan 2024 14:27:11 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=Q4L4YDsjacLh2GjC22A+cQl0QZfjcK9EBUSZdxONXKk=; b=nmlNib+Q1Zc4g2+1OMVXGnJ3ipY+UVGpttYaOGwZGfE6cg00cOnV8MuMEs/5vysEj9SI 2eL7Qa1AwGIK/Od/OYlVMv7VWAxrlKoeZWDE0b3lC8z3+bQC2F42j2fGXfYHj8lko/ZI wTeqv3RMRNdW+gGaOSFFsTzoIST8aAcDXHKLSA9BiLyICHq1VQyog5e8O7Fl5Nlnvfv0 UVGqSLPIBeZFiZCKRdl4Wdr8S4nRfIU9i3dXkpnIZkAo4BYndjUN0DCMNNTsC+oZ1u7C 0DvYlVjVyMy0rWsGTz6UrF4AYL5tysVYfIP7S55YFF5gctWZFhTl0qiZSX3eFY6mN+v3 Kw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vr7anuqd1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:10 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 40OE1L2B029572; Wed, 24 Jan 2024 14:27:09 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3vs372rr2v-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TfFylqEL8h4Vs+GlM7msK5hDYvEydfD+HkHuJNIX4SfSBgejCVwrDb342mfO8jmUDk7sulKRvaTooTTr0nZ3eX6y0zygxrd3BaiX9+rf380PMH9O798h3VQwoPT1I9jrUEqOq3YlBiZXw+rj2Brfyd9IkXi3M9uSe89Vxpdxqr8wxxp8hN5UyTe0kriwFoUMWHQtwHufYJSv+J1ErQbTc656dCcirTjyKJx/ZkhwxC3Eiz2uTX4a31Q355d6hvNFugqCABk5As//qkLBUsPN53uHYnpOIR9+cP2dfKXFjxfgqxcNu06csJ+TxBhY/a0MlvGAK13ZjbWg7npFB/+rYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Q4L4YDsjacLh2GjC22A+cQl0QZfjcK9EBUSZdxONXKk=; b=Gk7HmD7XSSEcYlqAlndRX7Ur5BhPFBXcjQu+iKLZciawNGaBMg0NRNlLRK6D35g+XG8BYxGCXRPWnUt4YEsXK4KrHUzV2lAzbhjTrspH1snMqw495SKuw+8HpVjxGk1ttzX/v6Ju/JtrU6sUqrpLQzrfI0E8MtWypqO/D9Z4LlQV1Un2xq0Ys8vAjEIU09C/psrWB4fXpPZqA70sIBzTQ8UIif2hGn3Vre+9/ThDYrQjlzHDgNWRbi0+CeZccQ6unRa5nPmpCQXCb/okqo8rOepSwJ7n6+/aCTO73XNZZvw8OOprS3pUMJ72ubtgaj9wJ7rC3XXXuNLxbZ4nElKaVg== 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=Q4L4YDsjacLh2GjC22A+cQl0QZfjcK9EBUSZdxONXKk=; b=MH73LyKkL4jGYcLl8WzvVkdXS04yIfznOSd2gqNMvZRB112HOetBB6FQAigKwdPIsCNWR4ocwvqmnkqgJw9IsbaT3sb5dOL4L+ULqUY1Kk7fJj6J5jnlwwwy1GTUIupsAWv8me4lw9Es3oFFbOYYUBT8Dugmye+fk0rlsJKczN4= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB5212.namprd10.prod.outlook.com (2603:10b6:610:c8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Wed, 24 Jan 2024 14:27:05 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c%5]) with mapi id 15.20.7228.022; Wed, 24 Jan 2024 14:27:05 +0000 From: John Garry To: hch@lst.de, djwong@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, jack@suse.cz, chandan.babu@oracle.com Cc: martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH 3/6] fs: xfs: Support FS_XFLAG_ATOMICWRITES for rtvol Date: Wed, 24 Jan 2024 14:26:42 +0000 Message-Id: <20240124142645.9334-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240124142645.9334-1-john.g.garry@oracle.com> References: <20240124142645.9334-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P265CA0147.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c4::20) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB5212:EE_ X-MS-Office365-Filtering-Correlation-Id: cee4928c-3ff8-4d0f-dda2-08dc1ce889f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R6hIdhv+0ZK9tr2J0pjYpT0zzFLmj1VQJ3GNwsQu54aPFenpUMaPyQY5DSJZz0oyFcjcCRSe9/xmYoVKq36E9LKLxawF73G6DVKbLZhgCYeIH7hISUGYy9BUOfg2sk9WUEsClf8XHfOTHn/lVp09yg1GZRL1q7JY8+ZFsx6APUcNNtYmgbZsS1zEELVi+tRhHtqxCnv/PKQiA7Nou6rPLa1R/2VOSfXvvONNKMqIn/jFb/XVOX1IzAX0jlcY13GbzpMm+AeD9dzsIbn06zuwJkfxrfjj6ZMggWqVdmaz26VWx3RBIqh14A+1BSeu3bc+xMD/C0gS170B5z46wLTO+Pn/7yZ/HCScAVbwvmFTDpRTNG/sbeiQDkaBlZ2d1wtmmT6hsrvXU0TEhcdahbqoi9/lg++IdoW+6ajuKTEFoplRR6ECRNRQT4MqaSyzNseH3h70n5HdnsYgQScdXm20ZntvNdVZcLyUOl7Bigs7MJQrHyef+cqXIy6HvijPJ1OObnjP/5c1djTBojATOxKDP/tXDmHHPzaPMA0wEK8lqzAk61nZkH0z8rOmEr6rTvwO 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:(13230031)(39860400002)(346002)(366004)(376002)(396003)(136003)(230922051799003)(64100799003)(1800799012)(186009)(451199024)(83380400001)(41300700001)(36756003)(86362001)(103116003)(38100700002)(107886003)(2616005)(26005)(6512007)(6486002)(1076003)(6506007)(2906002)(478600001)(6636002)(316002)(66946007)(66556008)(66476007)(6666004)(4326008)(8676002)(7416002)(8936002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YaeAlV1ZnRBJ54cuROUr59TrK8vygcZdRZw68YHXkb4iMKWJURgMyijIR41wGkbMAZZLS7mhTonXrMOJEvOWbDt+4Kdm9pP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GiZ7J9lTYNd0WOa0p0oI+zbA1rM247esGMTUohjzjb6q+H4ihKLuosg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cee4928c-3ff8-4d0f-dda2-08dc1ce889f4 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 14:27:05.4220 (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: +W6KHBZBdrmBPaOvjQSsNF5hzS5Q5w6h9P1H97uxlNnxocXnHkR6v2TJvcn7K4NcrAqI6v6ZjwreXXkIZ1KN5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5212 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-24_06,2024-01-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401240104 X-Proofpoint-GUID: 8eC4GhOFVKISfos8lGd7FbO_2AOZmmvo X-Proofpoint-ORIG-GUID: 8eC4GhOFVKISfos8lGd7FbO_2AOZmmvo Add initial support for FS_XFLAG_ATOMICWRITES in rtvol. Current kernel support for atomic writes is based on HW support (for atomic writes). As such, it is required to ensure extent alignment with atomic_write_unit_max so that an atomic write can result in a single HW-compliant IO operation. rtvol already guarantees extent alignment, so initially add support there. Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 8 ++++++-- fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_inode.c | 22 ++++++++++++++++++++++ fs/xfs/xfs_inode.h | 7 +++++++ fs/xfs/xfs_ioctl.c | 19 +++++++++++++++++-- fs/xfs/xfs_mount.h | 2 ++ fs/xfs/xfs_super.c | 4 ++++ 7 files changed, 60 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 382ab1e71c0b..79fb0d4adeda 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -353,11 +353,13 @@ 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 << 29) /* aligned file data extents */ #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( @@ -1085,16 +1087,18 @@ 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 6 #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_sb.c b/fs/xfs/libxfs/xfs_sb.c index 4a9e8588f4c9..28a98130a56d 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -163,6 +163,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_inode.c b/fs/xfs/xfs_inode.c index 1fd94958aa97..0b0f525fd043 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -65,6 +65,26 @@ xfs_get_extsz_hint( return 0; } +/* + * helper function to extract extent size + */ +xfs_extlen_t +xfs_get_extsz( + struct xfs_inode *ip) +{ + /* + * No point in aligning allocations if we need to COW to actually + * write to them. + */ + if (xfs_is_always_cow_inode(ip)) + return 0; + + if (XFS_IS_REALTIME_INODE(ip)) + return ip->i_mount->m_sb.sb_rextsize; + + return 1; +} + /* * Helper function to extract CoW extent size hint from inode. * Between the extent size hint and the CoW extent size hint, we @@ -629,6 +649,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)) diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 97f63bacd4c2..0e0a21d9d30f 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -305,6 +305,11 @@ static inline bool xfs_inode_has_large_extent_counts(struct xfs_inode *ip) return ip->i_diflags2 & XFS_DIFLAG2_NREXT64; } +static inline bool xfs_inode_atomicwrites(struct xfs_inode *ip) +{ + return ip->i_diflags2 & XFS_DIFLAG2_ATOMICWRITES; +} + /* * Return the buftarg used for data allocations on a given inode. */ @@ -542,7 +547,9 @@ void xfs_lock_two_inodes(struct xfs_inode *ip0, uint ip0_mode, struct xfs_inode *ip1, uint ip1_mode); xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip); +xfs_extlen_t xfs_get_extsz(struct xfs_inode *ip); xfs_extlen_t xfs_get_cowextsz_hint(struct xfs_inode *ip); +xfs_extlen_t xfs_get_atomicwrites_size(struct xfs_inode *ip); int xfs_init_new_inode(struct mnt_idmap *idmap, struct xfs_trans *tp, struct xfs_inode *pip, xfs_ino_t ino, umode_t mode, diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index f02b6e558af5..c380a3055be7 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1110,6 +1110,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; } @@ -1122,10 +1124,12 @@ xfs_ioctl_setattr_xflags( { struct xfs_mount *mp = ip->i_mount; bool rtflag = (fa->fsx_xflags & FS_XFLAG_REALTIME); + bool atomic_writes = fa->fsx_xflags & FS_XFLAG_ATOMICWRITES; uint64_t i_flags2; - if (rtflag != XFS_IS_REALTIME_INODE(ip)) { - /* Can't change realtime flag if any extents are allocated. */ + + if (rtflag != XFS_IS_REALTIME_INODE(ip) || + atomic_writes != xfs_inode_atomicwrites(ip)) { if (ip->i_df.if_nextents || ip->i_delayed_blks) return -EINVAL; } @@ -1146,6 +1150,17 @@ xfs_ioctl_setattr_xflags( if (i_flags2 && !xfs_has_v3inodes(mp)) return -EINVAL; + if (atomic_writes) { + if (!xfs_has_atomicwrites(mp)) + return -EINVAL; + + if (!rtflag) + return -EINVAL; + + if (!is_power_of_2(mp->m_sb.sb_rextsize)) + return -EINVAL; + } + 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 503fe3c7edbf..bcd591f52925 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -289,6 +289,7 @@ typedef struct xfs_mount { #define XFS_FEAT_BIGTIME (1ULL << 24) /* large timestamps */ #define XFS_FEAT_NEEDSREPAIR (1ULL << 25) /* needs xfs_repair */ #define XFS_FEAT_NREXT64 (1ULL << 26) /* large extent counters */ +#define XFS_FEAT_ATOMICWRITES (1ULL << 28) /* atomic writes support */ /* Mount features */ #define XFS_FEAT_NOATTR2 (1ULL << 48) /* disable attr2 creation */ @@ -352,6 +353,7 @@ __XFS_HAS_FEAT(inobtcounts, INOBTCNT) __XFS_HAS_FEAT(bigtime, BIGTIME) __XFS_HAS_FEAT(needsrepair, NEEDSREPAIR) __XFS_HAS_FEAT(large_extent_counts, NREXT64) +__XFS_HAS_FEAT(atomicwrites, ATOMICWRITES) /* * Mount features diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index aff20ddd4a9f..263404f683d6 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1696,6 +1696,10 @@ xfs_fs_fill_super( mp->m_features &= ~XFS_FEAT_DISCARD; } + if (xfs_has_atomicwrites(mp)) + xfs_warn(mp, +"EXPERIMENTAL atomic writes feature in use. Use at your own risk!"); + if (xfs_has_reflink(mp)) { if (mp->m_sb.sb_rblocks) { xfs_alert(mp, From patchwork Wed Jan 24 14:26:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13529288 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 16C3F12C535; Wed, 24 Jan 2024 14:30:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706106616; cv=fail; b=cUd1ZSQAIH2UTI8SRiCUwXZHVPkVFEc3ywgZ9tESiQ9ctzlH9MezQ8ses4QV5gcKlCp42HyDtXTiZ92VlmbsjVS5nTV8Cge8T3XQXBWO7SynzZgsI2ehGpWN6uaH4Ca51PelNVFyFkMFEUfxp875VCVkXWg/SkxR5pE139cmIyU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706106616; c=relaxed/simple; bh=9uX7HUcEFacerr0HXW6je1/BaVBjfMMtp5jGY9GvPh4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HOEVjqvpj8GeGPrtaTLioXrDInLh4wnYt71khoyWZWwPu/O+5lTd0zhUg0TPQZRqz0oMC5FCdGy+MSFMq91PNlBGBQ4WPaZDm7kStW7/D/b14K6AClJfmloWJHgjphDIeo3wQDE0cmFjFItgACsZo1No2/kbYRQULyt0tAozMxA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none 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=KfvqcCf6; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=RpRyZNSL; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="KfvqcCf6"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="RpRyZNSL" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40OEEZiM026736; Wed, 24 Jan 2024 14:27:11 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=HUCCJu+kJZY/w/0AnOM/kMQ+pyn5EdF6M4LTo7IXxm0=; b=KfvqcCf6Pmhcrd5xnQ+MuDeVFu8UKP5P68e07DvASCKnnvhmhA8xOWhyaC4xfcVnFtOE LIotmoMcd9u2yC+BBV2Ej5LVzF2Yaqcw0Oyx32Wo2AyH4LDOdJBxutN+cJcl9fN6l6wc HGtDaP7SnGtt+VxeIUJsWi6KBxcHuRoknARR7Vy82SEgxS+alJT2qLW4uCAxgTxRu1aW 7bMIAPDG+Gb9Tb9eyGN+wy/s71uYmUE079dETP1J4hz7isruUYIiSnCQXiks2mXd3hDg 5ZIeORyDNKB1D7jKqnJ7HpxCdyeBkxfxfDIexzdBWPtRkI2K15glBhQ9kO44lus1sghH TQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vr7cuuuc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:11 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 40OE1L2D029572; Wed, 24 Jan 2024 14:27:09 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3vs372rr2v-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iYRU7+92b2d2tDPS5L1NOpRRZul+voe16f0CYGFa2+hd/CzJsk3pEWQj2gWmwZM6inELCxMChFzIAiZrS2daW7G3D8INzbktss1vyZQKSjG/1tZ6MideMABgd4hICsSBQpKxMaDMZSqc/BkSPQob4QsQOhQryfBvzaAn908qFUTU+iUWCXQN3yoax2b33ejI0zNF8NBD8DN9UVoj1qCNQEjJBIjIRa0JuMtU4WROQ8TyhDi6H1avaDUS14fu3N4YE/Xt6/d1ESyT1C4EjDi5wSADIq5US04TiCtR7fZf6SPKws9d2SqBSu0nUNsrJZ0qNPFw1KO4n5uhMm63EJrmLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=HUCCJu+kJZY/w/0AnOM/kMQ+pyn5EdF6M4LTo7IXxm0=; b=DKhJm54xkLVb/M4cGelnvsD3HEC/zljJM+/IOLcJ9wWaHl67eY8ZugMICAkQAHvNlQ22ck5SbzJRSmSU/hgltKzuc/j91sPHkfnIAFxW434VMG7+2EznwK5pAoDadjKQ4kSdaI9gWu9ssbn4M3fm83ie1ehG2VPKAb2niYQk68FK1RBaic1Qg9QZA5u+8oUBYiAKJGLU6sV+zxr0PbTfOVzIYEdluCmJOpSw8krga0QJx3194q86pOJnx5qTgl6mTzvmn0iP6JIUUSTyjuuJFp5Gk0TcW24E6wizWqQYF+VmhCSsNuBWpctcUN2pDKagkhp/AotDw2cm07c2lZ6GHg== 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=HUCCJu+kJZY/w/0AnOM/kMQ+pyn5EdF6M4LTo7IXxm0=; b=RpRyZNSLOoX6Rb3r7i+YAk/YhKE2jW8/SwoFlJobQuOzrc8jl22POTStMVFa8sw4eKUBO0+bUmi2bnFNz51XhU8pqdkFFjWo+iXRNw1rAJGJGnYaounAFlJAUxMXSBJhCvuLEmkiu016Z05/HDf1VT/0Cvi+PBZ0SMqe9dEZTxs= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB5212.namprd10.prod.outlook.com (2603:10b6:610:c8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Wed, 24 Jan 2024 14:27:06 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c%5]) with mapi id 15.20.7228.022; Wed, 24 Jan 2024 14:27:06 +0000 From: John Garry To: hch@lst.de, djwong@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, jack@suse.cz, chandan.babu@oracle.com Cc: martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH 4/6] fs: xfs: Support atomic write for statx Date: Wed, 24 Jan 2024 14:26:43 +0000 Message-Id: <20240124142645.9334-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240124142645.9334-1-john.g.garry@oracle.com> References: <20240124142645.9334-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0435.namprd13.prod.outlook.com (2603:10b6:208:2c3::20) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB5212:EE_ X-MS-Office365-Filtering-Correlation-Id: 04e855d2-7705-4a97-37ce-08dc1ce88ad7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IQHBd8JuD0mP+dN3FWLTEJ2tWAEVpr8Y6e59W+Owqa8EkGtMrbCquK3MihA/lb0X3rfXJDsu+nmi1+e/b9aJ3I8Su7hVVMed8PgC5L4Sha1Tbwu05+ggla2a6HgMrqzmrHBerOMczBVAgabhxYXU479OtgZgJXmrIl3l6zqcuABEzww1OZlf7R6aKjgaYyYz99dwQRVYzUtCHyEZtW1lsUwjHA0bGhNNAaXiExnVUnGW4m4VJy9lg3xQdWXof1qBi553MfYi/pfGV4NXWwxVyWjFk23vaogkuL2v3Iiyz36CqGq4gS0yUJVYyos3z6bxxIjf2fc0o9PNpR91gF5UHTiXCE4WwX20wLpqVUEFALJb2BJWlc6watbi/9MVtia5csXNT60o8oxnrsZJ5ie2J1+7GBqW+6QPUOzwXicb9+CPmYjs5ZSxtchZlkzlkG8ZzWofAg51p5R5/ug25fAmgNj0LBA3W9uMZwUAtq0IWAbWyfKzctDwfQUswce5QsSb9I3ogNw0TAk+nf/7IY0dap3PDFQ8RKJMtiFulSyERJYdPMm1VzNDKHHMY6gYSDTf 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:(13230031)(39860400002)(346002)(366004)(376002)(396003)(136003)(230922051799003)(64100799003)(1800799012)(186009)(451199024)(83380400001)(41300700001)(36756003)(86362001)(103116003)(38100700002)(107886003)(2616005)(26005)(6512007)(6486002)(1076003)(6506007)(2906002)(478600001)(6636002)(316002)(66946007)(66556008)(66476007)(6666004)(4326008)(8676002)(7416002)(8936002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Db3mglmNsBzfRh5X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qfnUqjOL+bNLkMgVTpWoQyFfNK1D7TQy0EHMhCuU2kkC9mHa27nr6Ui/PxleV17A36oLH7fP9JJx47Kv2x54aIgVcwGLOSOhkvGyRqUl4a4U9KHfyKzKaoaBXoyqBhhoG4YoQ4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04e855d2-7705-4a97-37ce-08dc1ce88ad7 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 14:27:06.8222 (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: b5GtSfaAOxiZ7/pK2ts21e1W+cWKJXdXmlL2+EL/cSP3e2ZC3Xp64xX30bJyTuh21m18py19epRtAzoK8dxAcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5212 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-24_06,2024-01-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401240104 X-Proofpoint-ORIG-GUID: MRuRMQem1csCBN-TI7MUrlZwme2dHj76 X-Proofpoint-GUID: MRuRMQem1csCBN-TI7MUrlZwme2dHj76 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, but a lower limit could be supported in future. The atomic write unit min and max is limited by the guaranteed extent alignment for the inode. Signed-off-by: John Garry --- fs/xfs/xfs_iops.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_iops.h | 4 ++++ 2 files changed, 49 insertions(+) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index a0d77f5f512e..0890d2f70f4d 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -546,6 +546,44 @@ xfs_stat_blksize( return PAGE_SIZE; } +void xfs_get_atomic_write_attr( + struct xfs_inode *ip, + unsigned int *unit_min, + unsigned int *unit_max) +{ + xfs_extlen_t extsz = xfs_get_extsz(ip); + struct xfs_buftarg *target = xfs_inode_buftarg(ip); + struct block_device *bdev = target->bt_bdev; + unsigned int awu_min, awu_max, align; + struct request_queue *q = bdev->bd_queue; + struct xfs_mount *mp = ip->i_mount; + + /* + * Convert to multiples of the BLOCKSIZE (as we support a minimum + * atomic write unit of BLOCKSIZE). + */ + awu_min = queue_atomic_write_unit_min_bytes(q); + awu_max = queue_atomic_write_unit_max_bytes(q); + + awu_min &= ~mp->m_blockmask; + awu_max &= ~mp->m_blockmask; + + align = XFS_FSB_TO_B(mp, extsz); + + if (!awu_max || !xfs_inode_atomicwrites(ip) || !align || + !is_power_of_2(align)) { + *unit_min = 0; + *unit_max = 0; + } else { + if (awu_min) + *unit_min = min(awu_min, align); + else + *unit_min = mp->m_sb.sb_blocksize; + + *unit_max = min(awu_max, align); + } +} + STATIC int xfs_vn_getattr( struct mnt_idmap *idmap, @@ -619,6 +657,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); diff --git a/fs/xfs/xfs_iops.h b/fs/xfs/xfs_iops.h index 7f84a0843b24..76dd4c3687aa 100644 --- a/fs/xfs/xfs_iops.h +++ b/fs/xfs/xfs_iops.h @@ -19,4 +19,8 @@ int xfs_vn_setattr_size(struct mnt_idmap *idmap, int xfs_inode_init_security(struct inode *inode, struct inode *dir, const struct qstr *qstr); +void xfs_get_atomic_write_attr(struct xfs_inode *ip, + unsigned int *unit_min, + unsigned int *unit_max); + #endif /* __XFS_IOPS_H__ */ From patchwork Wed Jan 24 14:26:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13529286 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 5CBDF7A728; Wed, 24 Jan 2024 14:27:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706106455; cv=fail; b=Gt4dUy0ruL3d9Ll2VgEvJPzdDIX7+qqf9k2q7mO6CFS0MJdbzxdZNGMoX+48JFz3HfrEMk+ZsPJCHCr95G1fTuVLZK+5PJ/Twn5fA0skHfivFEKJPl91ZcSnw4+X/Vh3luzx+pzugoj1jD2wL+CzbsnB3vlz1MYnIpQbZSdq/Ys= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706106455; c=relaxed/simple; bh=hbt+0k+R4+qccQnxPZlDW0Qi+QvQlzvLsNLX0UMwDtU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=twM5cnWnaQDekESV0QU+jUIjmtwJ99ymKaKUKqXaqYAPuAyZvSLEg6GncCsc2g7lon9mVkYCFJn8e5hQt/t0D/kTtc3zvTB9v2Fx0e9AMykuqXMuLCnHv6UZZQVosLJJ5pdSLceeOI1jMUn1g2n7XEsC3hKwS0fCQFz4B11HtDg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none 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=jLFUxQWb; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=o9gKuXbl; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="jLFUxQWb"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="o9gKuXbl" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40OEEaIu026749; Wed, 24 Jan 2024 14:27:12 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=AFwdfP3dbZoF4oRQn3J9ARLTElsVYZ+A8bsr+ucvIMc=; b=jLFUxQWbRc1bGUM5sWwCJzHO0W6RipToCFTYwpTdFIU1O4J6jYlRLwMfU2JKhEr8JEpn dQ2f3KvEYZASFq4akkwsKNwdQrAa/hy/o2dhZ6vAHD3XGTHUeMXuBN06t2XHcrwcVC2K P3rKUkNeO/zKOTqduDCQhIE6aSQYsTLAwd4KuZHs/IyU7sGhzwN/1IjLpeW+mxxspQrG qslGf1wO/RfjSZHqma90jGdycgmg+/W+iTBPJQYkPbaJgo+QhRPAlynfbq/W2WKMT52G ha0L3kBoPuicT77N1zkCfgDtZO09vb1flH6d8cH920ztdqzpmCAt31l3Usgl04Hg2uVt IQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vr7cuuucd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:11 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 40OE1L2E029572; Wed, 24 Jan 2024 14:27:10 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3vs372rr2v-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C38CZwLv6yqgVM8MDbOrdqKWXNyOkMqtVDS8HT+Ea0/wr2ZidNOSf2871IogpuePki92YOPwwXgOtJK8bl+BdQp9JYtusw9FN4pZ7ZnO2m0rIiSQKHGBicX07Y7MRnNKm6uF9lI+/L5DPxK8PPFawaWb1a1x0hUAjLK0yNfvyBpdhqTDNcu7Sec7DPho/dtrV5Tt3CA+o6MnRlkKPX18mCNCB71tLTn2Ff3tcjP6dsH5rDeZxOBlmEEnBFPQs6KFrRI1Uqj9I6Qg8hav6BfSYz9G+WacTHSt2WCNkrboIJBx0mvD1xrjaovpBs5UWd/FT/a/Q5ZoC3vV1JBmFbNqGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=AFwdfP3dbZoF4oRQn3J9ARLTElsVYZ+A8bsr+ucvIMc=; b=lkzkQzpXDCnZUuzgim1aofd2hVqN6LjFYoyOrkRBlbgYG9A4AN1F9ASHwdtUdS5E1rl4mwONAZbrIelCPqyKTBTzoVviWDJIaMRZerPovENjtw2Otqa1Lo5+Nv/OG4ltog7g8Szqw0uiDbq1ORgtY9waIKenKe+JW+nt+sE62TrNCpJ1GVmuUU7ZUsZDXCU2Al/0jqoQmTHe88yK9zBZZglvMLkF5l7un96duy3dByIs6aOn4IiwEq1L49lbil317kYciaYJJzo7i3tyZ6vn1q/zJpE5L+xyMtUFuYIY7saxqYJPcg8W3N1qSrbIkDY/wDgZ0fVocYLzLKtmbLCw2Q== 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=AFwdfP3dbZoF4oRQn3J9ARLTElsVYZ+A8bsr+ucvIMc=; b=o9gKuXbltmNbtfemUqFi2FdHFYMlDxVev5V0+cFDdF0POMO9kp/DkX4X8gjJLYPXgbVfi7u8H5wjrGcjKq6DIHful9gDtra1ySnFDMUVplpVjFoWb/L88+WoOKwKKSM/D5n6sw5PwaihYoM4lsezPKEDkUu9LxLINPylSzwwQWk= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB5212.namprd10.prod.outlook.com (2603:10b6:610:c8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Wed, 24 Jan 2024 14:27:07 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c%5]) with mapi id 15.20.7228.022; Wed, 24 Jan 2024 14:27:07 +0000 From: John Garry To: hch@lst.de, djwong@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, jack@suse.cz, chandan.babu@oracle.com Cc: martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH RFC 5/6] fs: xfs: iomap atomic write support Date: Wed, 24 Jan 2024 14:26:44 +0000 Message-Id: <20240124142645.9334-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240124142645.9334-1-john.g.garry@oracle.com> References: <20240124142645.9334-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0440.namprd13.prod.outlook.com (2603:10b6:208:2c3::25) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB5212:EE_ X-MS-Office365-Filtering-Correlation-Id: 94beaeed-c5a6-4a75-7654-08dc1ce88b6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MiWChE89foI9Q/P2Fyy4XUB/k/dQtHzzSA0AEljqdQZpqvQgKj33lPk2UafFruNGEC3NfP9CBpIdcRWzK/QTZ+KzpKtQBZk8Y1Ch8Sqs2S96ZAqr4gnPGEeAHCg4/qvcl6hHtKbff+3O9s1pzRDT/VXSUt9VDZ7OXtqfqQNmk77pIWTyoaJKM1bIgH9T/RwC2nx3+UNzq2/9yyEN8ZrY/EYdvsAxXWjtz5CUWAO7IpHH8e+YX7Wng58ufJgZnc9KZg37Gd/rU/sLcosUMWlKfPvSU3DWHA3ahBL8aCfBVlpvfX5q/oq+QarLPfX/remlGK7HFvOThLdk0NHSVmiRGPAgaYTkHhkjfWJ/rCQC/ysR8C68rLYyM29vpMRCXas6GcDU/4c8QBqOhgLNj60lvVupPXlGErSOEWx42WB/UV5zD+vPVWKoSc0MqPCLivFcZRU22zD5cL8CR+ekFjv3y2pHUjeRzCVJIqL29LvqzNyim1JYFWe2hpQQnX8QmzkWTBwWfVRPlmtVnC086DVbRBgQAGae+tdfHQHtoExAk2ZA41mAClQojgJu4cML9Ws0 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:(13230031)(39860400002)(346002)(366004)(376002)(396003)(136003)(230922051799003)(64100799003)(1800799012)(186009)(451199024)(83380400001)(41300700001)(36756003)(86362001)(103116003)(38100700002)(107886003)(2616005)(26005)(6512007)(6486002)(1076003)(6506007)(2906002)(478600001)(6636002)(316002)(66946007)(66556008)(66476007)(6666004)(4326008)(8676002)(7416002)(8936002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YiKjV+DxWnm3HB26zQ/5g2y2p7qhufYsiDRX1QUjV8xVyADocDNqAanJ3JS03A6zVuENHvo/WNriKOUskXclZJR9im2wq9Iser0I/lcnIka1uO/0wTfIppKS1QQJ82V8ss2e1CD8nyl8fZoQUR9eZBRN5lLB6jnWT1lVhYKe+iL954PBgLsmc/w6+LYhYOXc4OAkJ/b5uuf2osaBmkZg+4mUIaVTeteHV12RenLOWW72C1tpmeBJDn5qiyxp2wil/FqxfIV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MfOrZm/pASPCWglRPX6J43YlYhQi7L4Bi1qBqYpG68dbXygCCH92q4Mcfb7leXOs/651ZOtj+glyfAYLcNq6y7cfqmxWThnepWM+WruGVVy3vAGeflpH3l3AYhXMUe3lNRftv1qQD15tPVmi1R6kUAmU1BMlmxab14QaSgYpYTvomNQIBpwSETh5kQPBUuIh+6X5g5QuC73CPOEh3QZhNlJSoReL63OlNtFxhCIzS7cX14yoZ3Cg3XDYEITV935TQbgT8OxblFnfaWw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: FC87AnVVvg0QI3ci/T8MlFUni6Z33HPtaVgKgDeGq1vXfoaNNkZqwIFdQfCZCmaVX1D/l3SGHPDPmbglUd7JJHq+wgm8oqYk2lvDj8DnNa1hiARnFNvcoxmGNCFV4k6uV3tw/hbF1TkMU1KUcECuIQP6vzXeLtRcCmrqwYPUq5nBGA9kxk5BIAZnFcOfVb/71jyGSa/qAcAt5aza/zYa6+dJycEnERvVZVwfLwHEP+MntdtHK2J2SLvsYf5Qe0wIfR14RhZ2cmXd7WlHGUbUh6IugyeyhCY9PzGqpxLGrLpO4tE7pKzSTYhh8XnmBSQs6YkaKmT9azuoMLq6yzjw4XpMZxJqQAolEl2VSacrFjYeS37FobG4yljJNBgk4NP8ua3t8EwVT8eZ0sQ55Wmvd0uiTLOr+5w2CeUkvdsk+2Q6DoQKughELoXWzqD5ljUvyNDuiFXSTzgVldpopbSSyDMF18XKRjIgr8r6sKJ6ji8yDH9luSdDAXerv1sxprtYWkm15/6GXsTFtdNAfsMjMh/x18rHg+uqVPSG9jxD/hm2WVI9rpiZaVA1XSm1xv3TIQ36B0n/A/iA+kjS4pXHLGIlJENAh8gpdBQYWHu1CjE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94beaeed-c5a6-4a75-7654-08dc1ce88b6b X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 14:27:07.8208 (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: GSjNsDakt4NAdGvTwN2p53jDzpFGYupFhIRDodDBlymkE7z5wgMxDir82myIZmdjpskVjpH4um5qWkk1zDu+nQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5212 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-24_06,2024-01-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401240104 X-Proofpoint-ORIG-GUID: EFokGYJGqSYivndvNp0L5eCPc9XTTs6I X-Proofpoint-GUID: EFokGYJGqSYivndvNp0L5eCPc9XTTs6I Ensure that when creating a mapping that we adhere to all the atomic write rules. We check that the mapping covers the complete range of the write to ensure that we'll be just creating a single mapping. Currently minimum granularity is the FS block size, but it should be possibly to support lower in future. Signed-off-by: John Garry --- I am setting this as an RFC as I am not sure on the change in xfs_iomap_write_direct() - it gives the desired result AFAICS. fs/xfs/xfs_iomap.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 18c8f168b153..758dc1c90a42 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -289,6 +289,9 @@ xfs_iomap_write_direct( } } + if (xfs_inode_atomicwrites(ip)) + bmapi_flags = XFS_BMAPI_ZERO; + error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write, dblocks, rblocks, force, &tp); if (error) @@ -812,6 +815,44 @@ xfs_direct_write_iomap_begin( if (error) goto out_unlock; + if (flags & IOMAP_ATOMIC) { + xfs_filblks_t unit_min_fsb, unit_max_fsb; + unsigned int unit_min, unit_max; + + xfs_get_atomic_write_attr(ip, &unit_min, &unit_max); + unit_min_fsb = XFS_B_TO_FSBT(mp, unit_min); + unit_max_fsb = XFS_B_TO_FSBT(mp, unit_max); + + if (!imap_spans_range(&imap, offset_fsb, end_fsb)) { + error = -EINVAL; + goto out_unlock; + } + + if ((offset & mp->m_blockmask) || + (length & mp->m_blockmask)) { + error = -EINVAL; + goto out_unlock; + } + + if (imap.br_blockcount == unit_min_fsb || + imap.br_blockcount == unit_max_fsb) { + /* ok if exactly min or max */ + } else if (imap.br_blockcount < unit_min_fsb || + imap.br_blockcount > unit_max_fsb) { + error = -EINVAL; + goto out_unlock; + } else if (!is_power_of_2(imap.br_blockcount)) { + error = -EINVAL; + goto out_unlock; + } + + if (imap.br_startoff && + imap.br_startoff & (imap.br_blockcount - 1)) { + error = -EINVAL; + goto out_unlock; + } + } + if (imap_needs_cow(ip, flags, &imap, nimaps)) { error = -EAGAIN; if (flags & IOMAP_NOWAIT) From patchwork Wed Jan 24 14:26:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13529287 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 BBE877A73D; Wed, 24 Jan 2024 14:27:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706106456; cv=fail; b=I2UDZEmKfdvOyTwLlCt73Y8kLj/V54rSfl62DwpUMoWTkaDDbdJqjW7IJotVcMsI/ZEPquk5PzQnwX4dcYxucn51F5xewLk2d13EGJ2ypsqHLUxcC/E5viR6b+bAzjAY0r519S3kzIslptFjAZk+yDkgbh49s0lD4GF6q47khXU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706106456; c=relaxed/simple; bh=qZ3ZqwcL2mSkOxkMdrRgCcLrz5wNP590t1lYbOF3NEI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=cNUfKePwf626oJHdc8wr2agMJC2qahd1tZN67MO4z2YcIjP2eRo8nOGfYZTqDIZ3QNtOocPMXLi9F+57LChf/SPDCl9HvK7PAruy89D+Gm57HqfXIzjvxChxfW4Vz11R/KFVFyQ9NSnuiDSwgN0ivI4/8xa/k406PzHTT2jIdOU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none 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=PvSPsTPu; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Y3TVLwGm; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="PvSPsTPu"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Y3TVLwGm" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40OEEAwW031335; Wed, 24 Jan 2024 14:27:12 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=+WEVMn/qZipO6hxM2qw1SmQSPSCdzsis+iVdAbrZA8E=; b=PvSPsTPuRBHLdcZ9z0R0SOpQ3MVY+bBcHn6sfbb1MT3F/ESMuT4YCz9XlL3CxH5DsDc7 UgDHrhLXrNHQN/tXNnl1UH/bnQHZQS4JpuoB1w99vWsORbYm8rethGSUjWOuE/ItJTaS HiiwuBMUj0O6egvQc7jRGRiBlIMibNbdf7hl0vhAAsY3uGHPc3U6Yi+7uDwyfZ+ZRrtk m4KdBXQYcjOIvr9X9fs6vOY+IDAEYj9seSj6dOd5glEzwpg9dJDmk8Qhc6aNgtDdQPVi h+1XP/+rROam80+R0hceXBPNcNQteXVouNB2aEtPtJKkZlq1KcqcyfqURK4S+Pan+hfE rQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vr79nkxaj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:12 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 40OE1L2F029572; Wed, 24 Jan 2024 14:27:10 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3vs372rr2v-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 14:27:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kWWrPK0+P+tUVbfqbx59EvRql0lYN78nTjCq3qHYra8GdAS6xzaYROzyEtnCSgNtqYrRLbcZXwpNt6J/gDNo4yOt2lTQ2yvCWoShUMTKJX7h9YSpiJn/xgEU6COnX3rTCv8Z81vys97p7N1PeTBynGOBXPGWdomXxMyGzBleTsfVTWFYsVeJdyn9/o2uNb3yVjGkiDwCzf00WrHIK79mbr79+RTV2QieDzcf4Kh0lmCeG6B2Oh/cJ67nlRLs+wtHb/6gYXz5ylrGsF2RXNCc4YakpZE4MmeEBNvcw42SRMfGyPyQrT/FyLv7KG1SS+JlT/79NqoizkcZSQSxL9rukg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=+WEVMn/qZipO6hxM2qw1SmQSPSCdzsis+iVdAbrZA8E=; b=NJv5UN4X7P/bGSsuqRKGe+ZA9TgShStj+LovAH1YCZ0rSpREDsyr+NRLF/lLWmJCwNsc5EZI+2OprCLPUtczna1FByMIuMvfrPZyfoXDoCXBi+O54UYOTP16N0U8P0qzqsraJhSXdufBE92TBdc0wcDgZJ9ESASxksYteR0o1rGKximMclaGWXoQOYIlegCOwA/By14Zuo8FjrJpZcoMMFIhibse1pNXdiB66NHwKlYyKceGCIC0IunfELF6n9ovrPXW2c80c9dhvhFwr7osy1mVq0qMpl6QT/WDtW8uDqzLOdUE3qqFpEZ8PJTVm73UzfKGPz1MxfrtJb2uTc3xDQ== 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=+WEVMn/qZipO6hxM2qw1SmQSPSCdzsis+iVdAbrZA8E=; b=Y3TVLwGmHbu9LFUDdTMhvCMB9vdmVU1+yLFSkgE7IOsaqL5jUcsAo7SzYgTEQZLFaR7osIZUyHn1Ng+tA67MI3lNSgtc0GpuA66OVnJsrNFx+og9Qb8CYZY3/IMuz25zLbC+Eb8+/350DlNuzYKbDMKYLtzvmbr5v/D/VnHOID8= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB5212.namprd10.prod.outlook.com (2603:10b6:610:c8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Wed, 24 Jan 2024 14:27:08 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::f11:7303:66e7:286c%5]) with mapi id 15.20.7228.022; Wed, 24 Jan 2024 14:27:08 +0000 From: John Garry To: hch@lst.de, djwong@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, jack@suse.cz, chandan.babu@oracle.com Cc: martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH 6/6] fs: xfs: Set FMODE_CAN_ATOMIC_WRITE for FS_XFLAG_ATOMICWRITES set Date: Wed, 24 Jan 2024 14:26:45 +0000 Message-Id: <20240124142645.9334-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240124142645.9334-1-john.g.garry@oracle.com> References: <20240124142645.9334-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0441.namprd13.prod.outlook.com (2603:10b6:208:2c3::26) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB5212:EE_ X-MS-Office365-Filtering-Correlation-Id: e52ab45a-ed03-467d-eb8c-08dc1ce88c08 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IjUzRuHWG0EyqtQ3FM93e+GT/PnpNqMb/Dsyteg/clgM7HFRnCmn+tJT8TelvxivRByEJZGTcXT7ZMfsm6+SPbWlZb9JQ3C30Uav6/LuGxdgh+qT0WQsTu07RxAF62PNnS3UjecyplGjQQfXSMBPk0GuY0sRPWdKDcn+r8Hwlmv+fIWkWiy2BONuxcS9YZmBLr1urp6eiSL/j8Q0DIaSrtr99VK02VscA6DaShWnL7aroyju0riAEmnAlxGgQiDHXKLKeEls8ygv8CeYhCBPG/orwIfGAlsj9OuupLrbf8nEefAQJfBsZVcWhv2ripDIr0peqWB8KGvXlw/ZaS0hB3WFfJkDsWjzVBUK01xgF/VMK4QnQ6fiEt0ZiLchnIZ1U2hhzwTt7CImOe6cExWS2BqO+bF1R628Gnam3QcGwaSkZbQ0edEWCyk+UhU5C1DfccA+KeDXJdcDs3xiP1NQ8NV02VQaTlinwFssjAvwb4DZOe5WmtNEZuXP2bxSMJP28s11GSflsXTG9arcQrspXJ/BxhZuhkk1TY7N5scOZjCRSY6nW+jW4fwHjtNrYzKq 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:(13230031)(39860400002)(346002)(366004)(376002)(396003)(136003)(230922051799003)(64100799003)(1800799012)(186009)(451199024)(83380400001)(41300700001)(36756003)(86362001)(103116003)(38100700002)(107886003)(2616005)(26005)(6512007)(6486002)(1076003)(6506007)(2906002)(4744005)(478600001)(6636002)(316002)(66946007)(66556008)(66476007)(6666004)(4326008)(8676002)(7416002)(8936002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZMR10NnOzVZruRQtqLY09tE/t7xtvKFZoTNocY7Oirl2tY0hAgQpPM3iAD7JgkdXq9DHA/tKvlxeg2v8w5oBHwTZhebhi0Wi63HYR8c0g3QIg08rfJpwCk7aQjlnf0wmlRd6OnCQjPWLBuUr7QqZENi+Q2zl3HOiUCgTOdkO4BTlTnNLbdVKvJ137Sm7Sr2323Aonmd2s144KxBBvP6XlvvE04949VRqCeaTDhuY24pxg69r75VEA26hYt04S9V36cvbWuUuo1wxd0x6h8Tj5edAJxFrC6hUH1C+GvPH9bL9Fg14aqGHE0sCz4GnlMdz4w5BfdgUKy/43CjcSJpnjVSeroCRbHoq2Mr8Px5HeR3iZrxGY30279U0Vie5e15HxtLgy5naF82pRd+gy8+Ji2RBif2wW1LFdPyCv+KkQDUShygNFo3ngTyTn8KpY/z3mw2lE+W99KxzMsNeVxpTcd762dCoYpNQqve7frDX1l8pvVlxWHjAyu6+FOUmZ+QfuZfxqjvcLp2gHEfkZOy0qgXK7RoGi+TGALyHuJ541bT32De9Me6QdCLqfQUVrJWvXGMyobj4U50q7VY7vSRfHW6tb7tA/Afc5y0C7HthLDiBPxLtx5QULKW3ln6lpGd7AGr5531HVnS4Kc0Y/IlPbpgmOGHJp0GgAjfxY3XEA5gGmHtN3UFFGUV/sDCPVr3ZoOQvOScfHqMaZYYabCIAFdZAOcdq+b5eDjUgq3rhhFA+AssF4nTwFTik/jfcF2aQdrsEFdYnMNj1pJpOFRixhuazfoGfgkiRQvT4wEMUsu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JhoxQDGxApLu3PawSx96oUTab02BtzlpN4uUuHcQupSs4WwZt5AKYmq5ZmZg3hZBgTxoYvAzVAfI8XNPQJ3lB2DCwD4FrO2bPmUPT/v4UbPi+bF7SsrnA3oFdD5cV81C9HUMLHU+RBRjsUXU/AczN6vwYZGJnixbky06aW2Qux68SpOJEf/42YLVYFXAd00/W4HkmDfBTALa6M4Yp42nQcBMufKyJvQeZjMttWK04UEU6MWpwICa15RLjo1P3XCuCh0614SPA96PbHp5FEDKty1KJz6xSsdqGUE/ONegNvVzqRSSiDZJ9DQxlAc6YkQ2wsmVpsuhdiAsDxwfQrA57QABz8mD1On/IAzF4vNefVLvQDNWrTqjfrhb+tpIhSdPLAiFApyWoKBdk+J0eHn3nWCo+2cB8LmhLpHwOFrvTon86+kBkkrBm4CGeOTghg2r8o= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e52ab45a-ed03-467d-eb8c-08dc1ce88c08 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 14:27:08.8655 (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: xhyf2P5EsJa3rMLlTo/qCPSCFWGrZTXfkGAqwmyOWF78NVZGMRkfiqVGRWo9u/HDWmj/wSRNHHylvaK2V7G9Vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5212 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-24_06,2024-01-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401240104 X-Proofpoint-GUID: Rb1ppTtU-Ba4OLTo3ljzvc0A79HyRIrc X-Proofpoint-ORIG-GUID: Rb1ppTtU-Ba4OLTo3ljzvc0A79HyRIrc For when an inode is enabled for atomic writes, set FMODE_CAN_ATOMIC_WRITE flag. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index e33e5e13b95f..1375d0089806 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1232,6 +1232,8 @@ xfs_file_open( return -EIO; file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_BUF_WASYNC | FMODE_DIO_PARALLEL_WRITE | FMODE_CAN_ODIRECT; + if (xfs_inode_atomicwrites(XFS_I(inode))) + file->f_mode |= FMODE_CAN_ATOMIC_WRITE; return generic_file_open(inode, file); }