From patchwork Mon Mar 4 13:04:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580553 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 E57DA3D0D0; Mon, 4 Mar 2024 13:05:18 +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=1709557520; cv=fail; b=orgTNcRHLlvkmWoK5NS9vCJxys79HVgIG9LPfeQDBIQUroR41Q/ceqoj3FHZB0iGiLar7PxDk3cgKqWU3nzHMMl8Pj8oGz/pNoilTHbAlTdGepknp5+fwSzTDYFIEEkVosHLVhJpvy4loMSB7xMpoRM1UEhZIa9C4F99a1QJa38= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557520; c=relaxed/simple; bh=kg6NRoqxNLVM6IMVaHZ5Llfi+kjJD4m8ovf/ZKVafO0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=sM/jaDm9gVYibrRfr5lJchXM5dRHCZZ3INuB4vfZOY4F5pcoyq2ll0vLnR6UnjnpQRCOv9IRuL/Al7zHo6JFgJcaI9kCUAHm9P3IxOBp83ZmOAf904h+DNs97RBTM58b2yWijCRVBiWwd0nVO3UEsOLkO6mMTwo7kJ1VyNI8vgw= 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=i9HexoR/; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=dE/tMhJB; 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="i9HexoR/"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="dE/tMhJB" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 424BSwUm028411; Mon, 4 Mar 2024 13:05:02 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=/3dtfupMQiitSmriS3Cj0CEAIIiC9u1xWU9cMCtrYtg=; b=i9HexoR/fW8PwJ75VoqkUA2+RO4lk9UVb0OGLO1UAjoQa/fQLCePKr3lmak/uKFLYfqI WGm5JZwLTDZpNoncLQnUnX3NVUsXMAaYb8yH+ioCQx8ywOP8WyRn2fdP84fAOliXSIJH +Jfs12/s60LjbCsESLBeu92BpI/1dKMqa0Q0NJyZkloo9Adj46xpS5KaYPM7+z3ToFdU Nk1qhGWIHpoaVuX1Cw+HtJ0a1J2P/N4o1px0WofuA624JT2F5eDziC/+s2Of0sHAcdrZ szLy6fiqCC2OGdfukIfVfdAOP8nnz0OUvp4aJQPyt6sMu5vbRuybmKnL0vYlHGHxDXXG 4w== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wktw43d3g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:02 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 424CwCFq017481; Mon, 4 Mar 2024 13:05:01 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj608ye-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kgEWxucqCc8mxmPQctWVyB5y5RnHbHrYANr5zRmb4Cswm3GhbmjnxmJrvVKnHt5QdVFS0P6o9N+8Ne5mS8m/3ScgAxGkbKIiVi012CaAe7iUNuR3UJ932Df6S51R133vo1Ytns9OMh3I+z45azpuNC5c3rIHW+4DPkX/UI6ljo8oD4B6rLgdKsmRafjB5y58M1y0LAFelt92flKrqHDzaKtp8XBvsvVxGGhKk3zeGKi14CoCoW+u5orU6zSNoVXZt/QN55D3in2/V8hN4DL3W0SHavuZOO6OgK039aKvxJhGWK0MPdrxw7WxJkxXfoO+qQP/cZAFWfsjD2lLTOmheg== 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=/3dtfupMQiitSmriS3Cj0CEAIIiC9u1xWU9cMCtrYtg=; b=I8pmw6lIH3RDe0JafYVsqOhSBVzqSOvZFqqiMUx94l1mQ/vwVoYhte/LydYXv7/lEpRcc0KqeV0g2imYEcF5vlcAXoh9FLCxM1wyVFn9/j34Kc8CqOGzAXxWvMAPUfPr4pdwTtly71z2bueMwri9bctHHw2anpIU9QZmqR1i5V49z4QtvK9xn0OsFn4ICaV4eXRbfVlJdnLcTcE9dHl4O0etRlhZVoWrs3DayFD73mA5z5YmVZXBUJ4gP7eWF5xyObaocGKiblysGILvab7rALPJB7+xj33pTCWW7gfg3PQJ2MYcVC/4VGrB/cu8MTlo4uY8xVFJznVwWsf+o1ICsA== 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=/3dtfupMQiitSmriS3Cj0CEAIIiC9u1xWU9cMCtrYtg=; b=dE/tMhJBgbTBTZYEBlWV1yzUI1AOEjm7WKRjMqGaFHGKHIzWtaXbf/6daTorz8Wfvk48bYdSN3ml0EvmwsUAfAqqmi4S/q5poQEF29vPuB0+LQx7ShG4zUqzmMJlABQPf8hkpvVGHHZHYAZ5l74OaC3KMgKej7bzJewh3Op5m7k= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7805.namprd10.prod.outlook.com (2603:10b6:610:1bc::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Mon, 4 Mar 2024 13:04:59 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:04:59 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 01/14] block: Add blk_validate_atomic_write_op_size() Date: Mon, 4 Mar 2024 13:04:15 +0000 Message-Id: <20240304130428.13026-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: BY3PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:217::19) 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_|CH3PR10MB7805:EE_ X-MS-Office365-Filtering-Correlation-Id: d0336fd0-8520-42c8-abfc-08dc3c4bb23b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CEAi9rC2Wg0pDfqAYq99Am4B6QLQ7QGZYYyBbK7B5ElHFMENvjp7GG2CVEFziKbTgWR5QVUBibJjaQ5XVGId12/94gXJJxgEHfxJ7PBu9CzdYh71Nmdqon9BFHsSSvl2Dx8zGjC3I4IQToy5erwKPbaBboMzSVU8VkPPaZ9YNef3Qz3lKoejt70UgBzWGn3D8RdstRiqAjqjTXhxUN25+TACxCxQfycR7fBL12F9bcsLqQIzdKV/mltiR6CNvuysF7N6zo2+UXKY4AFNYgJpQXmc3fpJReWYTCxdpm4YgW3oy+RlLECFFf8QpBmyg8koc8ob18AZ+hIEu2b7DJXkFz0sDo9WakooEgZVDVB/7CIgULeRs1RA/e09buwyjReKfYp2TMp5hplYryyOIi/AreLo7tKE1NHGKlX6fIc1Kdvw8/fpC793MrJMn0jzGxg95UAqFZRTFM7HdkZTT+O+V+K0/S4PRqtJVlM6E6Zo6N+HnF+oX3JD836ZL9V5QPGICoFAiJKqvuo576AR6Z440/I5GT5CuW5RjE6mFiv35+sBSBq1ZGo2Lw6BZbBsWNN4PLC77fttzbTzAaOrig5WDxb1x+N+RJHB8Imu5n59+PdGZgtPwke47OAG/KBztxgYT787ewwTlj3y39h1T3aN429oV4ymLd870kSz7aiNIQo= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qmRdVzB5+GTiuwQAbu1kl7iQcBP6yTryBKebuWRt5RgJ0p3RqHDcrSeoaA1PriwaPVM3GvrkOp07QA2d34qNvEcLPJsGJUW85gbvY2Ej89N1unZ7Im4kvKNJsuXKrmk2UXXyVCFHLgJLFzATuVvJpEn4sVStRoUtopEIBhkcNrz6V/J8cA+EF7WnH9LVpf8P1Z8nvcR9oGI0cKIXu9pHR0sObsQiYSP/Urwp1OxNnv8f4+nxPtisGVasrMm1G6Cqc+eVh9VmRvJLMqbH1Jl8/xD7oEBDcWVy1KvpqydMn4nnelWLwnt+qw3UCXNjwy/u4VpfyEB1MrVHsmUaX5UcMZwhHs0XvV2XXKUH/p6FqCV8iJvSLhAv6feGK1qKJado4pB013SuxphvCElmxMN0t1gBSey3fLLXoCMpYGBSANP7YVHFnLtbplWvYa0PtPFXpgymiUF3Yxcz1KJtMbhKtVaqiNxB9ArQM5ohMWgDqWD8jHgJRhPrK3v+YG/H08rZu2bYUc+Hdr0bk9DzpXoxG4gCe7m3P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x+GpaV/scL4jIGjzA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1KsM/pfoMMQ1YAU5HrIgJEgXWgZvySZahXpYR/5eFA4htoSkskrFhW8x6LdIX4YgVg7DIv04NW3QSAD557TxZ6tFy0szcJihsv1HuSnbD7bsuZxq4L3k8YtfLGEIua721oZmDVY8JwRxBmayeRbOhc914SCje19kX10hHUs18ES9eQ6C0ouTwzFeR5XuIFDQ0WDG4iSKJTyPiIN+MitAkyPPSp4RyBpk6MoPjlSp6457rI6SctCGeP3SSCeF3jYR3TOEEDeubKA5n9dbNxCidwp9DAguYEZ6JczQvjucrnQyCt6DaW17vlR6qRuWnKr83HyK2rMAyRbZaK11/rgMEb9oxEZ6BUEyEZ2YCz8WLvv/bqzKBFXsDspb/WL5ao1ne8Ff1rHeFXlyP4kun/iMVFtX9PDH/sfL6g4VsxHhyvFliPQ3DAT6ToUab2Z/WNCAuuz0/MHXIXb/v61dFPR94hsw4K7yviyBskiPM+cH7bbJX35vpUCpox/UPh3sPuc2x/tA5hUjQBdjnDmkTIP3ZuSgOa8YQsdh/lcI2xsTmGhykSMyOv7hcn8ykZkTYEYQyvJOFeeaqdyDKvpDlG918kH/yZJb3ZFBkIZrj8Jb0Ac= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0336fd0-8520-42c8-abfc-08dc3c4bb23b X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:04:59.1439 (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: AWRKpbeK4miKi8zBCzSe8nI0bM3qXune/iB8rVnVFN3dzuCHSy3ZfSgyzytWBlR2c/oCkIbFqi2zQihTzxuLOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7805 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-ORIG-GUID: uTh6u7jxwOYZ-1FznCV6dr2E4lXq1BD1 X-Proofpoint-GUID: uTh6u7jxwOYZ-1FznCV6dr2E4lXq1BD1 FSes will not check if the BIO submitted for an atomic write adheres to the request_queue limits, so check in the BIO submission path. Signed-off-by: John Garry --- We really should return -EINVAL to userspce, so can be have BLK_STS_INVAL or similar? block/blk-core.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index de771093b526..a1b095a68498 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -718,6 +718,18 @@ void submit_bio_noacct_nocheck(struct bio *bio) __submit_bio_noacct(bio); } +static blk_status_t blk_validate_atomic_write_op_size(struct request_queue *q, + struct bio *bio) +{ + if (bio->bi_iter.bi_size > queue_atomic_write_unit_max_bytes(q)) + return BLK_STS_IOERR; + + if (bio->bi_iter.bi_size % queue_atomic_write_unit_min_bytes(q)) + return BLK_STS_IOERR; + + return BLK_STS_OK; +} + /** * submit_bio_noacct - re-submit a bio to the block device layer for I/O * @bio: The bio describing the location in memory and on the device. @@ -775,6 +787,11 @@ void submit_bio_noacct(struct bio *bio) switch (bio_op(bio)) { case REQ_OP_READ: case REQ_OP_WRITE: + if (bio->bi_opf & REQ_ATOMIC) { + status = blk_validate_atomic_write_op_size(q, bio); + if (status != BLK_STS_OK) + goto end_io; + } break; case REQ_OP_FLUSH: /* From patchwork Mon Mar 4 13:04:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580554 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 0788A3D97D; Mon, 4 Mar 2024 13:05: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=1709557522; cv=fail; b=nCWJaOFE4YN9WszbxuAVYk1AMYwm5qiBeCAvsitXCJ1uxO71x4EMk4jY4jspGYvld+sfMa/h77ifEtUwYgpsPaUjb5s9tHsY/EhBMWXcMdcLubRAL1fUQTPUakHxMPveCMtymx0x+JRoIQuyE8sStXCpRRfhN5VWrQCZOHZJCFg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557522; c=relaxed/simple; bh=3TNDRfpQZBbZDP5g+gv4yqfcE8w3c5zXPn98QLwPw/o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=T6JTk9HE4i91me4h3oIl57zL6i9q29EaDML5iOYF9xRZ/RjvaXBwqHct6lQNW3+iV78wS1ktnxJ7Kb0IjHjTcrCzqKj8JLoLsm4hIE9cvvIKMowGiegeKb6MuymcfTynGG/0wIFXjQcVUvCdz3VhOMRt17IPMOiR10o+ViczWSQ= 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=aGRSPwTJ; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=F6liDskB; 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="aGRSPwTJ"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="F6liDskB" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 424BTBa7006577; Mon, 4 Mar 2024 13:05:04 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=JQS48Dxw1ngoL36+Udps8THtJx2l30nDWNbGS5e6exk=; b=aGRSPwTJQU9OKnnjwBgNKcOzsVzk0yEejcX3Isy7ftXvn12dx9PWMynguoOfbuac2Hj5 fi1nmHwTVXeKd/UALi6wXYHqJmK9OZ9qFRD+seWQMGOZtEvNjj1FBr9D6I6Er4VXBC49 6BmgYfxs93yQ1xQcnTWxipl1/LMBI1h1Un0t8VHJYI5iRS+ILTeFTmIyUJUQs5DnDlbV 3ROzbnnveYkxdkSMJtIS9SrorlAiEvh0YuqZJWoY/hq7mR/XThUmVtCRcB+Odki4dni/ a3eLWKAgC0PqUinAyw5jKAaALEFcyGkZzk5KzhJZSbwKgSNMPFjjSsqYlrnLtbqJ+Rkj /Q== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wkthebktj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:04 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 424BjGqI033198; Mon, 4 Mar 2024 13:05:03 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj63t66-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FzUAhFyeAKu5QPiquyyunpndGj4rN3I4Sh+NPPLZqZneowx8OKCUbpra60FLNZRMalDpGBBFRZXqzPSjt5FRMH9nGnVfRlMGOC6CGsP/+99R3K3ddWwmRQqS9KcTFs76wQc4LNDrJAEtLPzy7qWCLDbB5Ag9UmoGg/kjOirhvGizZNFMgYKwdpgHi394oXliX+Dlq8tdRwVsRzGZDhRSst+Aj9kYfhdLT/DXE3l2ebXx5IhId9wko7vlkMLStKBSX+V53sc6dmEM3bjdWjSr2cWk+qNegQiHR2Y8yZTYaM1mAMX6NFWmH1GR5yWjJj2K6+S/8wkEti3o9nOUHCejwQ== 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=JQS48Dxw1ngoL36+Udps8THtJx2l30nDWNbGS5e6exk=; b=YI+7UVKBXZ+AMzzylZwytZBQZETbA1j1JRTzmJ/P3cHqZgHn2GutQyaff3RkFzzFktR7WTWPQKkcdFrNF3+BX29zjkBwE/1D/vwiDtgXz8PP3dRjqHrDh45AmVrno76hJJyY4efGnWnq2QnO0Fdvffn5wR0honZ/t1TSI5N0AV4djVYwfrjM2TRALGWORsmwPBYE7Lkxbg0aUNVHELx9z26KiVn0tiGmixAqu941Lw2BkWiTNqM22rcrRXIvNYPrvWNFEAyNcF1X0II5VW4SlLOXnDZgh/A4jt9VMoOdSuYz6zSvWYQ8jz1o/vtvYZz9FYrVKs79bDtpedJ1kb4vlw== 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=JQS48Dxw1ngoL36+Udps8THtJx2l30nDWNbGS5e6exk=; b=F6liDskB/6Q8Ea1uHepYRf/t+CyfpHUs13C0fTyidUb+DHQjRca/dIHzvMJIQKPs9SPXZHCQTD6JF4Z0xRC8xzDrIfmnq86TEy36QvJ25FOIOo5QccMlw2Pw+R86sEUjYGo0ym1ODALF5ViHW+MZSQEN+PRMuU6rVOoFe8lihpg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7805.namprd10.prod.outlook.com (2603:10b6:610:1bc::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Mon, 4 Mar 2024 13:05:01 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:01 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 02/14] fs: xfs: Don't use low-space allocator for alignment > 1 Date: Mon, 4 Mar 2024 13:04:16 +0000 Message-Id: <20240304130428.13026-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: BY3PR04CA0016.namprd04.prod.outlook.com (2603:10b6:a03:217::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_|CH3PR10MB7805:EE_ X-MS-Office365-Filtering-Correlation-Id: 33106870-0f6a-4a65-dfdd-08dc3c4bb396 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q5qo6pwKcefJF6o/gqX6Pn88cBi+lpI40rYBrWZSjHa3Ui34dmtMI9300ZPrB1PTSGiEEWXrDtEtnPK9rV5jg6r6R4gcbgCpln7n5Aa2mHjuTeWr5nblFi53UYT36PBzJfSDqW8ExpWebEVEJj9uydmApY3v7yNlxX+DQi3W6v4DiXXh9Ba7FnaH81M9lSC0QjMlp+ijr/r+XyWVqYCZt6Ks6V2SySYV20E2p0T3qdjE2hCf9Q9NpCXJfxsnlsmAt0G9n44Ce+jS3afJ93I6Y41Qg0gSJGwydweBhEp/V1xYk7TT7N3J1/P9IM5CIDArdzPsbcj9yClW9fqpMjPUsbvuzG1mAALn8fP8xs14Yv2lfAZklylU4/vbqw6l7XzXS9xSmBycFkftPW/Us96YjnvycrND7w3B/n54tu3xJ2O0Zc6Mas6odZ4brTlq4zjTaF3ka/bLcghwayV6lhENZyLp6/HNwOmmkC5HIUU6qBmP1xolfJni6PbHmNdtpXGRiRMDQbp1YgPp8DOMfvR0pb2tXewiEOeSPFMcByKxBBlElyUafj0/sS7i6bJ/iXI/A0kFIVYJLse2gtBVka3fES+/Rdmrd5nnpJY+vT2vil34x/cYV/AWVX76cjVXt5o5QVYWzMMfZO8TRirTIIjwGRAA02kudV0l9kDFQDM9bNo= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZY+bJBlF+6kX4ZID/cc3AwvPyP/oDMzh0jaR8APAGdNPGaKxf1utb3nD1p6hE1Zlr/g13dIwi8bBU9HVt62J46QVV1fgfLvOcHmPPo3kJVGfxCv/9GdzbNihUA8H9R49KNVwnwYO8XlRVB/7VcG4r8sWD1hyKjmkeV2uNv7DjYDSFR0tGgmlP6KIPeAWFl/kk2SmpO8o2np4D4nEm8mCPsYhscNYEjL7Z2d8bPGAnvq0rrhOoEvRS6PH1VzwqVOixvbWqsRDN1selVasMzpLoYyRfDKsYGDLPEJNoX32mA75p/loeIZU23ngHRg+HSjaSv7qLfTM07gfJwmcdCfwl6QdrhKs+eHNIFlNHQLBLFccSIk1jcWPWOA60lWCjklLD3rt4JUWOpQP7IqNjhzjLuDkznQCKNDAc/oIpGv2xxLh+EZsD7C3T/XFSU27TQ6GMhKl1lcgZei88n87HBSQsziZvMI7F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VanlUQ7yPHuReKFKbSAuRD5k5fIXwyPIfpbwYUS4qhqIt8P8RD9dm6PnhABnZmHfh3EZfA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XKB1rnHjq0utvPD3Hg5f8kS8njzw3DvB0dHMAHw6GGp6UwLClB/pGRnfXCCW0i7Y+NdR1Xg+9PsiH7vR9AdzOJeNaYO9VPdfNmLNj2ctXRZHKKCDYu7bwGidxi2nzAopus2O53TJofQpO+iYPllpx4k2PL8qFPla9qVgGBJD+JyELMKZ6oCKzqrvvUXcMyFisF26gDPDZgXpsY7a/DgXAlW4+f/iIOao6uiqDdzDX+bK9QHitSYwG1rzM/FjbdaQoIllCZv2DySIWslUuc4VzZb37cEs+98gZvvB6g+8BrMW3T86Eey1eySEXsI2rbGfXr7x7l+rc9tUW7PqPKYwLVpxU79Qfltnk5MeYFoty8DS44Whtqtrxavo5xSAGu3kFzNlbKuk12JJ6/2paAiq+zdQcMctfbPlgyGUeP0lRKvKWe1CwFtvPKeLgHSPFlg63C3WPuhS0rCXm5Mqp3Y9hOmuKJ7Q+S+ToCljQBg8Qyb0I93F6KjhCF09ER0C29Hd9qP/uadQlzVKnijOlXERoBovPLVLcAim2h2NZmgeBEpQeR8rIGHUPiwnwmIlBUB1XQ3aNsnR0OONyK2R15UdaGpU9jnIethvhZDGgmWzVvs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33106870-0f6a-4a65-dfdd-08dc3c4bb396 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:01.3906 (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: w9KDo2KfYw8ny48PSQ50AQk5qNJtLU3hBzQJusz9hUqzuhr0w27BRAV/cbRqzoCWBdHI/NgA0MbSTedBnuDTBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7805 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-ORIG-GUID: 2wqFaGHbUswHckFaghkkHgiDsTaNTnLn X-Proofpoint-GUID: 2wqFaGHbUswHckFaghkkHgiDsTaNTnLn The low-space allocator doesn't honour the alignment requirement, so don't attempt to even use it (when we have an alignment requirement). Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index f362345467fa..60d100134280 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3584,6 +3584,10 @@ xfs_bmap_btalloc_low_space( { int error; + /* The allocator doesn't honour args->alignment */ + if (args->alignment > 1) + return 0; + if (args->minlen > ap->minlen) { args->minlen = ap->minlen; error = xfs_alloc_vextent_start_ag(args, ap->blkno); From patchwork Mon Mar 4 13:04:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580556 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 E2DF23F8C2; Mon, 4 Mar 2024 13:05:23 +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=1709557526; cv=fail; b=JIqFnRbOWhjnZA8R3BzVBxjPmv/SiXxyUzQOY1Ga/UuBOFPoqT6otCUv1Ksp6nunGdeZ4YjK7FRj6njnAWwfUss40YLnDiifOwpiRXVswP6Rt5itTDHHY6Ltle4lA1mnr0QRM4x7rs1OFVuJQgT4hZBNRh3mv0TBMVe4cULELZQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557526; c=relaxed/simple; bh=e3IjOMW28UsyF9uyFHOK5GKgbk1jrJ/tuNVh5ARGYCw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=tainHZQq3KcxJMSFJoAQpPgiZ3pze+gUFBvS2zdX3p+z1QBpTMX1BNANDRFC1pT8ns7G3tw/+RWLVGpFt9ekFnjpfS0Uklsjne9m06IX/oPzr7LR9tE8XdLiXxPB1BO00AZdRl1qn3Bh04GibaVTKOPl8mkMr9pteQu1BvqoT3I= 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=Vu7fOR60; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=dllxCFHe; 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="Vu7fOR60"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="dllxCFHe" 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 424BTmri027811; Mon, 4 Mar 2024 13:05: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=3YZGDt0LYatwH6pzKQoHiA1NOrwKq4u1DnTw9iQzDeI=; b=Vu7fOR60zK2Lur5SMTEfjDbwrMgbbXT4qZo1dn1W5YuHvDaot1e7jAPpEiLwBl/3a0HO bhEHFPWHZIoYvlDrdFwoq8MYwzIWEpaNKbyki/d7Es0ItiUdK7y+UTlqcAjbfNXR6DL9 3VUcDEC/wCX+mbabKY5+TFClchz6v1MG+EdKgZDiT82Dja9CI1O32USI0/oW6Lx8nOoe noIQa3sJRZI2OhLIlhSB38hob+Wq2PYn1o25szPD7qoelAVSy8ZaLP51Jg9E8HOGeIWJ GFG94zcqGuCkSTZeqeYfWA4t7bDty4//QNVJgETRQ4OqWXB7+40JPVNPu3GjI4+ob499 YA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wktq23hm9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:07 +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 424D4Bdi016956; Mon, 4 Mar 2024 13:05:05 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj5qp0y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A0M0y8A88teFpNxdMxs1XXr3cKXj5QwGTvrLm0niVrkfFSgMoWsFjxZi0jUO8MjoymIgNF3LT21qYc1GD5slqvUc48Cmt4gmDM4VF8etDFv1C+d/rCotGU/elHziK5A06xu+gzKtaOuIkSswTbrwTJv2jg48XgXhsuhWLew05RvQeCZutFWmMm4obtjDUlIol9rh7bJi+Px0Ui/X6enOGuCVM7nN0V7o74HCj4uYJjhJlDSg1NI6FF58jQSRtjIIS9UbGJy3JfzaFWMKOGr5NoKlfhXO5k0cKvrgfYqJ6WXrGlUfKrn9fn4flLjnbN1s3w3yfDrt4IBfNR27CbEFTA== 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=3YZGDt0LYatwH6pzKQoHiA1NOrwKq4u1DnTw9iQzDeI=; b=PRsbOsjzUED2aajMKQl/KFiBpwLbq0A4LUNmP7c8jGZa5Vqqf5egqqob3JWy7VEbe4EpERrGCn5N/bdiK/U3XFTohD+oi4eZlYLu3z2sTc9l7ddOIwEq5oD5fZsl51nzN4Y4HRVNTccTJv11noIuFw9uCtz5kfze9Q3nPmOR5FspaoFiwf9yGsvVpcZ43UC324ItmLyPym15qWifTMOpTdCKp/CL0LGNImJ7ppZQDmXUndeciEme/I153dGlCbai8eZNSiEtl0fZxWOqOdPRsItFu77rJb2Izk4uonDNBL7SWAXfxFmglBOQyeov/3KAFBtX9CeLKskWgS1U+Y8dtw== 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=3YZGDt0LYatwH6pzKQoHiA1NOrwKq4u1DnTw9iQzDeI=; b=dllxCFHea/+FN4E8GybMPpVV/FNZ5ZtBAvvy6Uaoijr2aTIjbMtqaCF3Mdl3HGYKsJ2Fgggs0BCtSfuk3kKD4a+sZ39aEk9920xbEEjWnj9j8UOS3S8tv1/9WfRFTRSoc/0b3z+3+QDeWaevzrVYGk3b2XjMQDC7TunL5O6ZJO8= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7805.namprd10.prod.outlook.com (2603:10b6:610:1bc::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Mon, 4 Mar 2024 13:05:03 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:03 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 03/14] fs: xfs: Introduce FORCEALIGN inode flag Date: Mon, 4 Mar 2024 13:04:17 +0000 Message-Id: <20240304130428.13026-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR05CA0085.namprd05.prod.outlook.com (2603:10b6:a03:332::30) 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_|CH3PR10MB7805:EE_ X-MS-Office365-Filtering-Correlation-Id: 41b37dbc-3fde-493a-e5b7-08dc3c4bb4e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6msHmaJtJH5ss47wL6j5FnP7LZZyr0B01Mzo55F9pSYp6kpENK2Fq5BmPeWgHiaXdz6B/M4nzre26cHuOh3krjSULLUEOLAIcHx2F7unLnh0PCusaylRuSgSDCFg+8mlLkWLfm8wjUI8NmQzh1GcIBi2WLPuRNkK+UvREGfoZbFZKrUDHAAOjJlpoJzv/DKn0kF82O41xmShmQT2vqcTxbdCly9e/DGAAQ/R0ywwnObiiXv3o9NeaJVUlp3odme9llPgG9Z910++bd2EF/6NDWKFVIRqfSmohA2zzGy+403ng6RT7Oqw6otOfcomdJTegfPHmcggozqMPrtQgQbRe97CSNpIotaYMEM4s34tu7PpLcl2Wiwojf8KLoI7nXYt0wozPIn1M4Zf2D9akigjJvzJ1/1DvhFku6h+T1aftXH7Oog86nlS2YNdSNDSVK6TQqiHWSKZi4YgzGpGHyMhwMDkRpnSZEd1TrvezGtT/qpdh5jHCqtPArc+jX+xUfDSdTZRncWTlCrzpww9WtG7nH/SAdn/7nrRjCUBCuWw+YAbRMiV73ZB+4tQUKo/D6g/LTHwJQfYy6y9zOaOPTlPOHR+x6vrHyROm0bp1E9x/guSiWfRqIMLq+t4Z9voyxQYXmIH+KQfpEvsTVsPgfL4e0uBe+RrdXw5bbGC2NIrKuM= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IFHMPZIx/Uzb8oK65BooqouppkFKURWT9T6wO3ypKGzcQwhFA8fu4e3sVZOUXmYBe8Sc5FT0WjP32cN3vhxFPNBlW1ZxbVYbd+2oHA3ngT0EWsxBQOjehRrUo3YDOx2pkvKRasp3pxBcFq4TBwnEYMQckEboeDy/jxUCdW2fsE57E9+CUaL0QoPy2oiLrB0MkxSN+EEtTTHKvm5szzZ0tD3KNUvklA9UqexM5S9Kv/SyKaGmvyEDkdjfP26HhRrZoxh+4A3oue+F5ag4BNLJV/CAfBSWRZzZG/Y9Z1TtK1bEW/hSQA37kxo7TDSeubQhOQXbK3OBphISY50j71f8Qd2t2VwMXtXz1HOrDGUuR3ls/6vlfNvqgMMCfAaTDq7oQ4B1yYTzdEoLbqqLxwi7S4fFnZ/yhuZer6FExfZJZvyaor38rV3vYCPn04p/1WF/+fwxs/a0Dd0mG8Jtl5xs5RuP/idTC1l6JhQE42oVDvA+hMeL368jNIXfDsXS1VbdFNJGhDJaZo2WOQsBiVkppsBLD7bqft0F8tDjunLhGvucJl2blLqMv0jM1npuvusUpu9ze5Cd8+Hv2dQMCskuSrsSxSKmiFFEbKOSNhopxgAttzl7TSeHiIEde9fPUV1v+wXvZLyIl6U9CeeFfTfK+6TogX9U/D1cYoNCg3+oI+Ffg0htKlw7nJwxdQZKS23h+oRyF/oq1a31RbtMpRba4fkvN2/hU0hCIcTWqoUmGbpA8p+04puo0IAXl/NOLHTUYSkHPjIvNJ+QBum1orJDcU5M9a1EH8RPugbkL50VrpuTI2y8TkmVgKRjHB+5wzOsNjbL9o5OG0BpUvzh9375jbyj2a01eQuqlt9OgdBJkbqh+5i19IFdVO7Dhk0XweJXU2JqVZ9bowG8jWYd8yYDVXlWYudC8xJcxcmLzFeXZheNGPqRHl5I60snv9E+1Zy6kfg1ijLo/Cuj+8zSL60jeYhcalr+UcND/pSAoCVu0weB20n6iv/zbuJChKveef5dymA6Kx9iu4WfvmLKSlSas538vRVqE+ohK7gbI52jW8wHGC4ZxW/9ZpIvxDWWt7WNnjgZoPeWb1LdCyQTseXvgnOdPKqdWMjTwkYLcQrr0Rx3gagLknz1DlD9V64/jtleYNzseiyNS/UOmgpqm3/hHRP03ACvUQI6s5KKapUZ2MTqCnvKElctCaSRFQzeV7MOi+yg/+HD4c1mDFSRGbRwmte/fz1RoWKp5jnR4Ke3HffSOk5GGXlsOXX5gjkDL5bQgvJezdxPe9NgKOUEuPCo4n91XJnheSgwvYqD+vqu9kO5kIc3TD6czcgO+EThBc1+aNj9ZuRnQa427cHCAEwtVHbZVl3Oq4viPbpd6kp1t188QeJLMn3ko0zZqoabfGgrEYlQptInSn3miLAzpWE6m8jwyUQSL+owmIN0bFeJVSf7GYkHEp9uYBiQzdbLud2vHWAd8U7ldsz0VdsZtK3ScCMhhw8LPIGWmnA6stulfBrNuJaAZigVPmlZmw3YmRQg1oLB0omunUCx2AqfdrhWe9RslmD+++v79x/bshESs7uvHbx1lg54d1+FSMGiyQduzJY74u/ac/ogUTgqf4ahkw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: kS/eGcUyiOFUPcnfxjw23ppS8tTF4PW+yt+jQz0V9krrqkOKvAEFre5r1ujclLwep/jUWb2RPKZ3uXs/zqqaxZi6t5hMxjVEqvB8Mdfu28WAjzLoENdiCOjBmUShKmy5iRGg682b4zO3fN8Fg4SsGIvnehKpwo7rqpYk99N6JsFLcT1tw6HQzXkRzCd+mQLU3Y6jT1mZIg/nLxQdlia6p9YVafq2g5X9zwbVBX5dCfyAH6EcR5NFm7taBT4xcr4ND4UOUcW59ic7akX4uHtoQdxUupRGRlqYlbt2wDZYEe3NawZf43BvpW6ppq23IsRa/Vvu72pIXP2cm9gZvl+kI0ZNaX7g6HCrhyE6CL56sdjj5WnCkvHkeiHGLqO8nbowBmq3icyN4vOTHLIkW7O3xgaG6WPDbsuG/lursLS1Z22rQHV856Fa0gWod6aN+PWOOeR0Nfmgxai/7MkIRuieCXbrLkU0MCLjxPkNukn2LsI0VtbScJJ9nu1720MyB2mJm2s5zASObNvi7Mjd16M/8xyq1HNz4GHsnJqIiXJ6lmZcRjveKXW3yFTCoqIgKCRdrNLljvtHAnCXZthvbRnQnPVZSIZxMW1Qyn6IvpEmDtI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41b37dbc-3fde-493a-e5b7-08dc3c4bb4e6 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:03.6712 (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: MjRa9A3vdlQMoLnL4gRWLqCubEgYR9Gfd9oH4x4S4+3RveXshgJzWkWB8+RncjnBybHF40WzAzoNXXENm33rdA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7805 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-GUID: tDut_4mDIWwcWb_bGguVuzstPeylxUDW X-Proofpoint-ORIG-GUID: tDut_4mDIWwcWb_bGguVuzstPeylxUDW From: "Darrick J. Wong" Add a new inode flag to require that all file data extent mappings must be aligned (both the file offset range and the allocated space itself) to the extent size hint. Having a separate COW extent size hint is no longer allowed. The goal here is to enable sysadmins and users to mandate that all space mappings in a file must have a startoff/blockcount that are aligned to (say) a 2MB alignment and that the startblock/blockcount will follow the same alignment. jpg: Enforce extsize is a power-of-2 for forcealign Signed-off-by: "Darrick J. Wong" Co-developed-by: John Garry Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 6 +++++- fs/xfs/libxfs/xfs_inode_buf.c | 40 +++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_inode_buf.h | 3 +++ fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_inode.c | 12 +++++++++++ fs/xfs/xfs_inode.h | 5 +++++ fs/xfs/xfs_ioctl.c | 34 ++++++++++++++++++++++++++++- fs/xfs/xfs_mount.h | 2 ++ fs/xfs/xfs_super.c | 4 ++++ include/uapi/linux/fs.h | 2 ++ 10 files changed, 108 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 382ab1e71c0b..db2113cf6e47 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -353,6 +353,7 @@ 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_FORCEALIGN (1 << 30) /* aligned file data extents */ #define XFS_SB_FEAT_RO_COMPAT_ALL \ (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ @@ -1085,16 +1086,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 */ +/* data extent mappings for regular files must be aligned to extent size hint */ +#define XFS_DIFLAG2_FORCEALIGN_BIT 5 #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_FORCEALIGN (1 << XFS_DIFLAG2_FORCEALIGN_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_FORCEALIGN) 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 137a65bda95d..61cc12cd54db 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -610,6 +610,14 @@ xfs_dinode_verify( !xfs_has_bigtime(mp)) return __this_address; + if (flags2 & XFS_DIFLAG2_FORCEALIGN) { + fa = xfs_inode_validate_forcealign(mp, mode, flags, + be32_to_cpu(dip->di_extsize), + be32_to_cpu(dip->di_cowextsize)); + if (fa) + return fa; + } + return NULL; } @@ -777,3 +785,35 @@ xfs_inode_validate_cowextsize( return NULL; } + +/* Validate the forcealign inode flag */ +xfs_failaddr_t +xfs_inode_validate_forcealign( + struct xfs_mount *mp, + uint16_t mode, + uint16_t flags, + uint32_t extsize, + uint32_t cowextsize) +{ + /* superblock rocompat feature flag */ + if (!xfs_has_forcealign(mp)) + return __this_address; + + /* Only regular files and directories */ + if (!S_ISDIR(mode) && !S_ISREG(mode)) + return __this_address; + + /* Doesn't apply to realtime files */ + if (flags & XFS_DIFLAG_REALTIME) + return __this_address; + + /* Requires a non-zero power-of-2 extent size hint */ + if (extsize == 0 || !is_power_of_2(extsize)) + return __this_address; + + /* Requires no cow extent size hint */ + if (cowextsize != 0) + return __this_address; + + return NULL; +} diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h index 585ed5a110af..50db17d22b68 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.h +++ b/fs/xfs/libxfs/xfs_inode_buf.h @@ -33,6 +33,9 @@ xfs_failaddr_t xfs_inode_validate_extsize(struct xfs_mount *mp, xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp, uint32_t cowextsize, uint16_t mode, uint16_t flags, uint64_t flags2); +xfs_failaddr_t xfs_inode_validate_forcealign(struct xfs_mount *mp, + uint16_t mode, uint16_t flags, uint32_t extsize, + uint32_t cowextsize); static inline uint64_t xfs_inode_encode_bigtime(struct timespec64 tv) { diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 5bb6e2bd6dee..f2c16a028fae 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_FORCEALIGN) + features |= XFS_FEAT_FORCEALIGN; 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..2c439df8c47f 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -629,6 +629,8 @@ xfs_ip2xflags( flags |= FS_XFLAG_DAX; if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) flags |= FS_XFLAG_COWEXTSIZE; + if (ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN) + flags |= FS_XFLAG_FORCEALIGN; } if (xfs_inode_has_attr_fork(ip)) @@ -758,6 +760,8 @@ xfs_inode_inherit_flags2( } if (pip->i_diflags2 & XFS_DIFLAG2_DAX) ip->i_diflags2 |= XFS_DIFLAG2_DAX; + if (pip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN) + ip->i_diflags2 |= XFS_DIFLAG2_FORCEALIGN; /* Don't let invalid cowextsize hints propagate. */ failaddr = xfs_inode_validate_cowextsize(ip->i_mount, ip->i_cowextsize, @@ -766,6 +770,14 @@ xfs_inode_inherit_flags2( ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE; ip->i_cowextsize = 0; } + + if (ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN) { + failaddr = xfs_inode_validate_forcealign(ip->i_mount, + VFS_I(ip)->i_mode, ip->i_diflags, ip->i_extsize, + ip->i_cowextsize); + if (failaddr) + ip->i_diflags2 &= ~XFS_DIFLAG2_FORCEALIGN; + } } /* diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 97f63bacd4c2..82e2838f6d64 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_forcealign(struct xfs_inode *ip) +{ + return ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN; +} + /* * Return the buftarg used for data allocations on a given inode. */ diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index f02b6e558af5..867d8d51a3d0 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_FORCEALIGN) + di_flags2 |= XFS_DIFLAG2_FORCEALIGN; return di_flags2; } @@ -1146,6 +1148,22 @@ xfs_ioctl_setattr_xflags( if (i_flags2 && !xfs_has_v3inodes(mp)) return -EINVAL; + /* + * Force-align requires a nonzero extent size hint and a zero cow + * extent size hint. It doesn't apply to realtime files. + */ + if (fa->fsx_xflags & FS_XFLAG_FORCEALIGN) { + if (!xfs_has_forcealign(mp)) + return -EINVAL; + if (fa->fsx_xflags & FS_XFLAG_COWEXTSIZE) + return -EINVAL; + if (!(fa->fsx_xflags & (FS_XFLAG_EXTSIZE | + FS_XFLAG_EXTSZINHERIT))) + return -EINVAL; + if (fa->fsx_xflags & FS_XFLAG_REALTIME) + return -EINVAL; + } + ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags); ip->i_diflags2 = i_flags2; @@ -1232,6 +1250,7 @@ xfs_ioctl_setattr_check_extsize( struct xfs_mount *mp = ip->i_mount; xfs_failaddr_t failaddr; uint16_t new_diflags; + uint16_t new_diflags2; if (!fa->fsx_valid) return 0; @@ -1244,6 +1263,7 @@ xfs_ioctl_setattr_check_extsize( return -EINVAL; new_diflags = xfs_flags2diflags(ip, fa->fsx_xflags); + new_diflags2 = xfs_flags2diflags2(ip, fa->fsx_xflags); /* * Inode verifiers do not check that the extent size hint is an integer @@ -1263,7 +1283,19 @@ xfs_ioctl_setattr_check_extsize( failaddr = xfs_inode_validate_extsize(ip->i_mount, XFS_B_TO_FSB(mp, fa->fsx_extsize), VFS_I(ip)->i_mode, new_diflags); - return failaddr != NULL ? -EINVAL : 0; + if (failaddr) + return -EINVAL; + + if (new_diflags2 & XFS_DIFLAG2_FORCEALIGN) { + failaddr = xfs_inode_validate_forcealign(ip->i_mount, + VFS_I(ip)->i_mode, new_diflags, + XFS_B_TO_FSB(mp, fa->fsx_extsize), + XFS_B_TO_FSB(mp, fa->fsx_cowextsize)); + if (failaddr) + return -EINVAL; + } + + return 0; } static int diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 503fe3c7edbf..e1ef31675db3 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_FORCEALIGN (1ULL << 27) /* aligned file data extents */ /* 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(forcealign, FORCEALIGN) /* * Mount features diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 5a2512d20bd0..74dcafddf6a9 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1708,6 +1708,10 @@ xfs_fs_fill_super( mp->m_features &= ~XFS_FEAT_DISCARD; } + if (xfs_has_forcealign(mp)) + xfs_warn(mp, +"EXPERIMENTAL forced data extent alignment 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 a0975ae81e64..8828822331bf 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -140,6 +140,8 @@ 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 */ +/* data extent mappings for regular files must be aligned to extent size hint */ +#define FS_XFLAG_FORCEALIGN 0x00020000 #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 Mar 4 13:04:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580555 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 2EF3F3D98D; Mon, 4 Mar 2024 13:05: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=1709557525; cv=fail; b=s7o6mN6aPL018XyaYAyHd3cw1nv79SLbWXKsHeYx9zZmFblufhSiRiMSWfPyNv3DizryloT01rk2mZcaFjk+F909hkiY90vW5dSdls11M6E36m9ksiS8A9gKfBbilpo0BlRojRP+I+51xuVZslQuRnlYMPLRrsl+0wt7MElL7Rs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557525; c=relaxed/simple; bh=z5kVOe7JLqM7hxtt0Rcv6dFyxS/cazNMp0CGhuDI1wg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Q61NZj3uGaITxkBxRVZQSf0P9cU/tuP2DBCFVE0OQfKmQQ0w63TGIkrXe55mXkItPkyquoD5xE1UXnTJhRytv0RIs0J79Br0dYWPFWC4YXWnV2Rfe5t2RVvk/LSahJ0gLJqpMFzCbeQmGzxVlzZPPzn7hcBHA17Km5jmgDsrGkU= 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=oVv7bLYh; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=OELpXlc/; 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="oVv7bLYh"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="OELpXlc/" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 424BTBGs006563; Mon, 4 Mar 2024 13:05:09 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=vWqEZRauMLCEuyAifF3eRr8tHs1zawA3aqG+JkoQQSY=; b=oVv7bLYhDkUiaBziKpW30QDSaLx41NKomk/m0OM2W0qQBgamT0ktbSDbEqNTyQsAYrRV rkqUjBpONclsZ0UjNgOv1u6vuLRfZCEFL3peJhU8pe5ibqACktoXOnLPWBzKDrTmeBB5 a4cy3o5pUXfPyx3KsQwAqb8+T00Kisf2j0lTAve3zujCzr3w7imsDVl1FumSWhpVTJn/ HCsoTPNKPGXVBbHL32nw1ZqLrjqgim7Ypc2WLIE+bovnZcb1RxVzFGpJFSq0TTc4byqk 42mU01KlbpJ8CTsKqQymys1UySwFDkTTJhlfr90WuSK3HEZUbxkQ33bK4ggWVpIskRkf rw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wkthebktu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:08 +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 424D0m7f016930; Mon, 4 Mar 2024 13:05:08 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj5qp2x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ldQyZnqOfGobXC92+ooLvbQfN6FzGGCOlORiUv1GaiEtj6NrP4SZ57EaWWQ+Tqi9YsJ8GiatrwaTBUq3P00POCqIYQLHCX7u9T71oDR9lscaWETPulzM3kLAefbPTUnUSHv/2lLsFkZSnuo6KJRnGaw0MJpNhJmup/ly8YJSgpgR5yTtXf4r2NqPhfOsdKhW4EzRXLDXcq33UFp9Gf2flusEOlMb/E+uMZAPwmbPDidkglpnu+KmthL8hc7GRhse+ufeSrPY5d2Ccp461gceqQ9XScbgopKpcfkD0tSnxz6t3Z5bv7A4vAVAaKyVLAaQv43s7+fjQX/0nL66az1vMA== 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=vWqEZRauMLCEuyAifF3eRr8tHs1zawA3aqG+JkoQQSY=; b=jG++op4u12o/oFI08YeHaPk2pmiPODhfb0IxVgCTSEffWZTMgyF8jid4k7jrAv2LQyYWZe0cLYWtpq/v869sf1sNPag/FnWJUhE/SohFHJHrhWUwXK40DjBdE/xHBonG7eUcXflygjxz5XJ5k96bdEXtQvnI6XHNmWlTZ4bp8pk1KsKpePJ2q7z2Xp+hLmM42oD0FEvcu2Yw/RhfEQ85oubCfqT3pG2tBmyab6iyQqw0V3fc2IbpE8gPYTrb0jLt6iAi1AOiBaY4L4Hk1Bf4g5FaEFqQ2pI9/waLmRPwpY2r9Y9zdifdKQ4Hb8BmoTS4r6cUOKU8VwxcGlc2aFZJ6g== 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=vWqEZRauMLCEuyAifF3eRr8tHs1zawA3aqG+JkoQQSY=; b=OELpXlc/ZP/H5pfqYvHcXRwiNIkPLiL0SbBCx8znKFo6G0ethRtgAECrKAE5s1zZGh8B8T95qae3MnLe+W1LRJqwwT0seFPfRXi/NI/gGnUFoEYhZVXWiCDLzYuFAHSZdsZS04eQA+5SFXYjMOGyK87M056iTC57GyNm61lT91g= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7805.namprd10.prod.outlook.com (2603:10b6:610:1bc::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Mon, 4 Mar 2024 13:05:06 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:06 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 04/14] fs: xfs: Make file data allocations observe the 'forcealign' flag Date: Mon, 4 Mar 2024 13:04:18 +0000 Message-Id: <20240304130428.13026-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR05CA0198.namprd05.prod.outlook.com (2603:10b6:a03:330::23) 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_|CH3PR10MB7805:EE_ X-MS-Office365-Filtering-Correlation-Id: 9645b6ab-b197-41ff-74c3-08dc3c4bb666 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L+1SfFHDjOGuHUP3qD8CrXbrFmc4cXZqTBlxk6/siSWi5Q+wT/aaJmJJJztWCyp+WuA51J7+huE16CoHy2SoHt2d2OE2KkjzDSWOlqHoxEA7CkgvwT9ipnNTJt+DSyt/FXlnkYXmk8g2S+KZdc+oTFnVCyuuHltSGoccfWjY9dBIpmRwfwyCgIh3pDoAM10mbInqUxcJ9hb5XsnEJloPWfHQZyxF+NOWxc23hnvL8EFBslTf8+LpuIldLSR31IkM0Rl3vv8JENpDfeKmbrSY6jaVhXE81TbjNifvN20m+q6WUpLuuZrBi9tVkGsdItxsA2UIsZJvP6eKRIOHa0yeWCssRtWuCGYvi09T++80i/66oUaaKmZX2fmLSiIXuqxAmX41lvwPyf6n2L1sAeu3b68SHD+K80pl4XLuvxi2X/8N88iGBliYU/SOz0Db9guuqORkQaz8UxRrMViVPAqFocAc9cfX+x7iAnbnKsMjB481yi9weuQjBQxVz/oYc0ocdMPfG5aeuGma6Ti8qFmm1Hf7+NXOvhnrqlyNQAW7BEaFhY/nVfeFFsAa2RUubLhQcmb+iukq+8LA41laKcHBGsRhIEtd8XOfybaxf6JlIK72YX/JhmxZoU64te2bEVngaaDNxtMKJ/TxqnwcSWn7wOBHl1DpSiPKx5o5xCfyesM= 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)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cpB4fraQnzNFxnhM36C9xhedLTRQetx9fd8GqkNQ49bEBjOVQ1KZa37eYqHabWvkIciQwOKdsZ3G7KcRo+mn2t4/a0/in4aJ7WFu5sGqQlUUW7n7UCpWwVBkZrL+QQtrrPqRtr0nFh8PHGxgF/NNsLW7qtYvNiEm19D4GTKpEGKgmcvgyrk/OoalLu9dLwKb4KYeZzK+PX1wQ5G7JZ/tlfVNsEols1r8Y5Shhnu2F5DQ2DXStulm6mJD4uM/nC2PuFd6Rlzo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9645b6ab-b197-41ff-74c3-08dc3c4bb666 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:06.1487 (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: OMBGPa83PN2f1EUJCo8/zRLB3QCLAg31VmbpEyU6cHj+HaSFM8NBI4J0qeXos1FPxMHtwnNW3A3+yK9jCIgP6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7805 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-ORIG-GUID: 6Xr8T4MKQ-Ioi4bh1YQsfOitooYWmmfX X-Proofpoint-GUID: 6Xr8T4MKQ-Ioi4bh1YQsfOitooYWmmfX From: "Darrick J. Wong" The existing extsize hint code already did the work of expanding file range mapping requests so that the range is aligned to the hint value. Now add the code we need to guarantee that the space allocations are also always aligned. XXX: still need to check all this with reflink Signed-off-by: "Darrick J. Wong" Co-developed-by: John Garry Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 22 +++++++++++++++++----- fs/xfs/xfs_iomap.c | 4 +++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 60d100134280..8dee60795cf4 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3343,6 +3343,19 @@ xfs_bmap_compute_alignments( align = xfs_get_cowextsz_hint(ap->ip); else if (ap->datatype & XFS_ALLOC_USERDATA) align = xfs_get_extsz_hint(ap->ip); + + /* + * xfs_get_cowextsz_hint() returns extsz_hint for when forcealign is + * set as forcealign and cowextsz_hint are mutually exclusive + */ + if (xfs_inode_forcealign(ap->ip) && align) { + args->alignment = align; + if (stripe_align % align) + stripe_align = align; + } else { + args->alignment = 1; + } + if (align) { if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, align, 0, ap->eof, 0, ap->conv, &ap->offset, @@ -3438,7 +3451,6 @@ xfs_bmap_exact_minlen_extent_alloc( args.minlen = args.maxlen = ap->minlen; args.total = ap->total; - args.alignment = 1; args.minalignslop = 0; args.minleft = ap->minleft; @@ -3484,6 +3496,7 @@ xfs_bmap_btalloc_at_eof( { struct xfs_mount *mp = args->mp; struct xfs_perag *caller_pag = args->pag; + int orig_alignment = args->alignment; int error; /* @@ -3558,10 +3571,10 @@ xfs_bmap_btalloc_at_eof( /* * Allocation failed, so turn return the allocation args to their - * original non-aligned state so the caller can proceed on allocation - * failure as if this function was never called. + * original state so the caller can proceed on allocation failure as + * if this function was never called. */ - args->alignment = 1; + args->alignment = orig_alignment; return 0; } @@ -3709,7 +3722,6 @@ xfs_bmap_btalloc( .wasdel = ap->wasdel, .resv = XFS_AG_RESV_NONE, .datatype = ap->datatype, - .alignment = 1, .minalignslop = 0, }; xfs_fileoff_t orig_offset; diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 18c8f168b153..70fe873951f3 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -181,7 +181,9 @@ xfs_eof_alignment( * If mounted with the "-o swalloc" option the alignment is * increased from the strip unit size to the stripe width. */ - if (mp->m_swidth && xfs_has_swalloc(mp)) + if (xfs_inode_forcealign(ip)) + align = xfs_get_extsz_hint(ip); + else if (mp->m_swidth && xfs_has_swalloc(mp)) align = mp->m_swidth; else if (mp->m_dalign) align = mp->m_dalign; From patchwork Mon Mar 4 13:04:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580557 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 0E0C73F9D8; Mon, 4 Mar 2024 13:05:26 +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=1709557528; cv=fail; b=L2cgqZr1KuSij7YM8Af1EYXNzweMIbXQrJzXoDfCRbQ2FW0nnWsgubVa+nZ7Cqfshhqx3uYyvWwuaZ3rSSgCEa35gw3glPD+kl+5POhGWbGCkmFYYuRUwzwCot7L+CPOW3tW9A2jFv/8THpijosFesb4e4tSBZ/3cQzzIHPFjus= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557528; c=relaxed/simple; bh=YfCQkGo8Sa28f9cFWhZG2xqcjNQ842ZhnnpGaJeF3m0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Mk87DOhjYthPbCLCmxqODwQ5iEWa0bdySndprq3bEU9mV2gwsnx8TdcEe6wvggwulJIestnMifZFW0mofkWid5uXevbWae1SRVH3YAu9XR09zyKzvMM6n1rVmDP25mjrdXWoy3/NKHb39usV1rVWyLpSw4eoOvYcWX8kYE/x4dQ= 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=midsimd9; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=CVzzcK6R; 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="midsimd9"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="CVzzcK6R" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 424BTn6a028533; Mon, 4 Mar 2024 13:05: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=U2oPilzhUsywLH65SAAkAkfeC/dSuW+Ee9zFAGHRaQc=; b=midsimd9PKsoQDdUrJN5wiG4bvzT8eQE3fpZX6+0/J67pVtJbeQ2fdLDCCg/O5OhuPoW /YwpqXdGlAYNyi940RuHKvAoTZVacZ0Y+TsQWyxJL8kd0Y4ti/d8PgfqXGwVI+VlwrW2 iOMYJQbADhFMl5TH7wqT1UoaDWD3Ev1GBbVT6jM2zwOlSOQ1wmAHEOexx9KGfgUOR21H WNYIjNo2KRJ6LN5W5CW4X2LJckHqO52BpStuf+rdDx1iHLPSHwcjolqRmYGL4QW7L5jR yulkGOW9PZxs7Uaucw9GCmjdbBEULsk6YrM0PigU+gZU6cmQNgctr4Oa5y21YI9biajQ pA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wkvnuufa8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:11 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 424Co7YV033255; Mon, 4 Mar 2024 13:05:11 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj63tck-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aGcyq3LdHLISXz8nzF8vLM7VpuG+huOeqdnG47xHQqe7bQ/vkBZ2t/RKyiTNeMXzaruP/Ih/LLfU6vaBLJ1izbdayKuYaU9zfWwbQrSMsW7TBJqMt6a/+UtsxsFNUnuZA/CC9UbkuYQ4opCc6BKNEyg2vqmaNbL2lo4DLhu4/+S7ok+C52WZ+sqe5BeYM6naIXntix6iN5wwNQV4Te9IABYoik9HqZk4xVLfsXaA+0a/sOu69VLwPhszsaDktR3OXfX2s7b0fH7t5HEPfwCzX7KRf+oFMn9yBJA7t/9yYP0dJ/fBo/KHM0qlWXlc25drChXP49Gb7zZMoydeuxW+1g== 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=U2oPilzhUsywLH65SAAkAkfeC/dSuW+Ee9zFAGHRaQc=; b=DTVcfKmNPAa4eVPfAX3t0q6Vi02/XrmhIx0NC7MGJ6Ouc2DZjadP7/UrS/fMx+zGSbIHxEpFtDLfjGHZAvpgE08cdzHl23Yd+T8b76kAwTPGiBBZNRRykMd5nAVXRTWZ17g0Qm+cyutB3sqofsAPGCXqn5aOqd2trGmjd35hkaNZ3HzQYFzEiCTwA1QcRELmXKt/tsLapvbEVknEFIQei4+2Vy74KkwZN2bDuv8TWE1W/bVtlRCUiqtqjaZIbaJOjS73hYgZnfZ1E+8DrlAoUe/SaVphNJBkwQJEe5HqoP+odXocLPLLgrQrnMa15tar0VGXT56gYzO+KVnS4S4j+Q== 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=U2oPilzhUsywLH65SAAkAkfeC/dSuW+Ee9zFAGHRaQc=; b=CVzzcK6RBJtn4FBgWt9t+NPrH08M8u1qU17h+SB26KSSaM/9gUbqwK8d00ANe03gsYZi/ZaIRkRvoJS0dkWCJwtDaV2rm0MhCtX1eLTjbyq6CQ6Oh1hGtH1MDdtUJtGUSo7OmJe4jyIYmG4+o/SdNtwEbajVQNmvRkaDcdUvhcw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7805.namprd10.prod.outlook.com (2603:10b6:610:1bc::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Mon, 4 Mar 2024 13:05:08 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:08 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 05/14] fs: xfs: Enable file data forcealign feature Date: Mon, 4 Mar 2024 13:04:19 +0000 Message-Id: <20240304130428.13026-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR13CA0141.namprd13.prod.outlook.com (2603:10b6:a03:2c6::26) 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_|CH3PR10MB7805:EE_ X-MS-Office365-Filtering-Correlation-Id: 55e487be-6b79-49c4-159b-08dc3c4bb7cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H1g+TKLVG6h/0paHN/OJ+GhHfiN4yHNeRosrIt/6szCzB9z6ZQ8XzAsmLkbtE3/Ab41Y/b+uiu5k9h2y/K4CEGRfBVYUB+RDnJ8PC1cuiJpsXpkWtt4QovSP5ygVcb6LZdNAO+4GB9HpP566j723d0dvDR78voZjuGIj+yM1ZeutFHzVgqCt+DVpSEumCIjmMhGuv8cJTCeBruJ8ytrzOfZJ/0gggelSgHdsTOfKeTIgEmK0XjpwiAQnjsnqW616zuZEYYgBgGq8QQbiFByg53iNJrKnwJe1iPxcOusLuubeqqCYG08oV9R1hQLfg0gwTuvUGZpOiSCbKVeUSyqSPk8l1KZBHR6QM1eIkVAhzYgeKYrdwonckWNDpM07HoOGr6mxohe6yizS3r5kK+zJL/vYdwLJqSybbUTih1YI07Dvj6iw4f6F4AxiLiKx6DV1K8t1aIXkUWTiUbULFbv4KZDlEoxaQhPazonX7FKZvGa8EP0FEwRogZy9iNkUOKGjX5ACc9UT6hzRGngVnzIFQK/iFquKQNBr1NXtPqb3gT7AvF4ztHjqkVj+iN1Q63XkFGiJChR4HmoaJuehFvpcrEftr8r+nRceCMu8bwi1RuaJ8iGleVXodCjVfepUNMLyH+G4UmC5xfRS/kzrc0Drttm6BKp+uCMPvgR5YCVSaCI= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IIBDkv72Z8uMzUUhcxDhlnb7y7cagVTjvs5dz8ONy8XChIOP732tadeRZtCCtXBPWFq/H/D69+Ba4e0YMyXsybPXwkO2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cY8zhd0/g4PfEis1XN9qywaZgPLaBcg7wJQC8vrsYNOodlQkbSrY4NX4gGMes621Sk30JvaOI1A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55e487be-6b79-49c4-159b-08dc3c4bb7cc X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:08.4719 (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: WCljqvTs7JQKRDtD7ufXF8haB70BPzxxZS2AwAdiqI0rwhNuzrY/j/4U2rY4SeiM4XPMQ8wqvnnqtYawjHBqxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7805 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-ORIG-GUID: 3lo-OPO1Qfd9JdtykVSTkSaURmSSibXa X-Proofpoint-GUID: 3lo-OPO1Qfd9JdtykVSTkSaURmSSibXa From: "Darrick J. Wong" Enable this feature. Signed-off-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index db2113cf6e47..2d9f5430efc3 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -358,7 +358,8 @@ xfs_sb_has_compat_feature( (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_FORCEALIGN) #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature( From patchwork Mon Mar 4 13:04:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580558 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 7EEEE40876; Mon, 4 Mar 2024 13:05:30 +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=1709557533; cv=fail; b=LpZcOae3JScLl+iDu9iImpdW0ZQigo2SxaoWZ38NkshHF7JHUuPYC6JMn8loZX4Fd7cyJV1kPw8xzOO+UHWuhmWRovmQrWJ3X+qaldXZvMSjFUs+TdysvqTxlQz44nY00AQ2JiHocHdVp2id2EMZmSSBB00hMeGDPcSU6hBkkcY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557533; c=relaxed/simple; bh=Ca+14OJOwwMIJRrzCTAz8rKt9vAQYCBDw96h0gnZYpc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=l3u0/du72vSJjANl3zgH442rlFW/JvoN7ZtCUUv8mOaQoR0cybkPgyqOtPmlaJ4Jro9DnkUMDOZOfso7nAZrOuqzSpaz+QBNcPNVO6NBC5ltq3tIDTIOTRHq5snEwHxq0EZviMD3onupoNaC3f1X/KmUBIVLV2bu4WGxGaYWzwk= 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=o1m73hIs; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=KsGZsrVi; 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="o1m73hIs"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="KsGZsrVi" 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 424BTd9l013715; Mon, 4 Mar 2024 13:05:13 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=WxFhCRvre+2cNUIUmaDBgWrH2k8gt2kohTU0lgHQQUs=; b=o1m73hIsWHhqwr3CfeLUhKD/KVOA1nPCQY2l75LCYwG4Ko0pDLj8xAcF2GHT4t2h1kL0 q6G8GQqIM15fD0GfZ+UK41/6nWum+HQe6SXBPuSxytTlbStgbvcERzEySMJGwsbvFR3z xo3ct6V7DjbZeGJMMK3JQHh5GGSnsYzEeA/carguG+3is1LMnekpw0CzRCTTgHlGs+rq 3+N947gt7VvSKeYvv9y4VVNFRfQx4xucTYfXCwcftt8ZAlkbArCJfFv1OY/DmRUEp7tu /wh6ccGrpEErzjumvVzG3wULAUCYki1SPyPka5JoEMtyWHV7K5NUc+25npnT48sfleBn sQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wkv0bbewm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:13 +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 424Ci79a017169; Mon, 4 Mar 2024 13:05:12 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj5qp7s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mP72Y+Lk69JsPa8tYW2UynC3zne3K4c6xbfiRo0LfYXDdv8RvTykD90JmBjQ//CZfDg03JLoj5Qc97DCuTZZ7DXr9jv5uantZrQOWktZA8BX29syEu0ktdyEpj1jlRDS1tVs7v/LppANTKoP+WpLPsYsL3ft5rNrOZLrpCELinEhbdKhrpahSYAHtXGMbhY9Wc4tFewqC5O1Q8yidJHh5y6IM1W/Mx4Rc4YxT7X510SCpoB6ixO5kmFxht08jfvOm3Gv2SqL2h+IxkY3MA3d32zQwzy7578pJflEVyjosugpHcC76HXl9X+Vloc50s4QIoqrjbxPCOecHqliYt1X3w== 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=WxFhCRvre+2cNUIUmaDBgWrH2k8gt2kohTU0lgHQQUs=; b=AbnB2USUlkJtW/3A0AsQeZy1ZKSsZezw9XeFKY24/PYVUAtFwfvAgS4fgda5hll2uu/zuO6ZBXExIKVIZB8fO9bB2JoooCfUSfX+c/RqNbXizgdwsyf5eClsgq1H30yihxagKfcQ6Y534HYWC694rOEH/2zRC9xyYGTzUGlhSRpJ7KN5HJb0wswHHctwVukYup+H+pJrOuj+0HCE6RJobJ4dg97i4xAh2cEgrtOYKMj+5M9/ziEpvEG3eVIWupTBt6K114xDCvxokFjTksKxHRQd3WDg+TUIQx56/6WqWSxDsvxMK01VEYbvVf0Zfn5TXAdtns9D0FFTCJBhmDUYQA== 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=WxFhCRvre+2cNUIUmaDBgWrH2k8gt2kohTU0lgHQQUs=; b=KsGZsrVin/vxXKGJrDoIYvKE11YvBADMZ8rNYivflx5DeGtmUY1UDjywpZQ2pyErQ5WVrTHLJ+rpl/T54vjh4tOaBwndgfNAb9+4Xdtn4APh1O+/IPXjqdC4Sw/Iip7Vvz23WvTTstPSjP9B1RBWQf8xjwzBEOeGx5k6YJA+4Tg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7805.namprd10.prod.outlook.com (2603:10b6:610:1bc::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Mon, 4 Mar 2024 13:05:10 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:10 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 06/14] fs: xfs: Do not free EOF blocks for forcealign Date: Mon, 4 Mar 2024 13:04:20 +0000 Message-Id: <20240304130428.13026-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ2PR07CA0021.namprd07.prod.outlook.com (2603:10b6:a03:505::23) 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_|CH3PR10MB7805:EE_ X-MS-Office365-Filtering-Correlation-Id: e1e2e536-adfd-4b23-4956-08dc3c4bb90c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7m6xWKHQ2NmJRocbAZezYN2imVqFPoynITOkx35RMEmhsg4KaU+2LlOXw/UelQkjVIUovPU8TPvvunZyzzSj9/Sgf9YRckk2XhIeZY1a46qfm02i+BmnFcw9lK6Y8lQDfwmso4BUM+KJ58yg6+yQ0lSjFROHx7Bk6MMU1MQpVrnfIQz70nP7AzXIFizrhhY9VXnwKgAvT7QS4kpgykuulOl+0UTEk6JITwdIP1mOSlbGNhwGAmk3PkWa9E0p9+A3GfCIuFr2f+GZm7IXOCUE2g6pbsMInVR3g3jZkefXV+692FMErM1fHSglUBWwEJi+w7wMcCC1aNCH4CiWaYpyfHXpqgVAzoRTepE5II2ilmHEWtKoirfzuMd7ZM62hp17+8B2sjzkQVZ2UWlbSsQsZpBZzU6KBF1VWbuWq8dppch+ZiIjL8lD4WziVu//k+G/caKVPYku8ollpzwbRYfHimfq9SLToeLZKnIFMvFxVhxv/PrIRAxo7OMiqObGfXm5i52H4tCDETQXw/RdiYj/936V2uVnb2/hWSRIjboAZeSDdvw/HgL6FfeUisvN2HqcWnzIG9Ae3exwtWJ4zsIXyo+IBvVhZS0bPx0QvRzrbcJj9pA19o242cUUE+zV/+c7y8n8sESCX7kAtmiV6zqvLJV0yUY5lYwj7WlCuL1ce+Y= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lIcipiJVbXttzZAystilUFrU+lB2aTaIJVC3UgPCWGObrIMx01y+E5R8sNx/XhbjCTGx9vvI3jKJKokXbBDFYwamm+bCja3AWHD3cWr9We0dBYCQaDwdMCnXebjJEkLDY53bkb7iW7Hz7mCJXKERsvt721/e3GhrO40X29e0nW4S9RtdoaKi28ug6riGVXbfO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ec+OXt3p7X4LusI2+5ma8AJTudeHayvVrDQUtKdjOkOealv/SbxqQU7/Z2dueodRjbyycrtGOMoRjS9XMSH14zq9cP9diHhos8Q2QtsQ4cA6bKCJggxfXcRSDtymK76wlrqbH+qylOz2PlZl2qVoYTO34wwb22+1fg/QFlWTymZ2EsXWo2xbVtmoRhZZnrE4LYWVhYdDajD4IC4tuHzuvciufyGaiiNh6eyq6m3LW/kpXz6QMhGhln4jwUMAnZkIDcOb0UZps+bJXEL6xuO6VxYDMm1eZL8dnVXvHVOqoSZSdmwhk/0c9oPm3VWvm+F+BIGrlTe1Kdu/klP13IXZry3msbGm6p4xp1NBQvqDhYg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rP1xLx47tBYbhWhYww3bWHpW2LIA3zjB8tXbqejfuTRx1idpq5TBJpRidoL2EGRLqFDn+JQhRqe4WZneSG2lfIj7vL33tzDwdT0thlBXXMr927PvTLfwxVOUQ7G8VCdm+sP6+3IMy3R8e4heeJuNyTLB6mujacDHsl4Cpazmy+dEKCC6CxBG69EH6yTj9mdIBaTCzpGAkQQV1XngkVPBj8f5zoS1oYK/FhFP/smvGTHxX5jQTujBCeo+eWfLXWItaj1EdKCuyQb05Su1ZQZc31ZpbtLi4ebtWDoQmS6uBbyQb9dTAE36T0BLFD/zh45+B6NWvrtxmzlhfTscC6VzATpOg00yGJpTeckJASLhxzdkNr5K67UHf0xe4R0siAVMnfgHNDm7SGewX9cT66Oqi50jSCnDbUH9f90eq+eXhci5Xq9NVpI/wXu/ypEJItEzq2uHkdFiCJwRpbxLHXVlf4ENRqVgLfjByY8AAqPZ2OGnJyBmotSnsVE9g5q7Pd2LlP3oWS+WKVJNAeJePC5tbt4CgHLI6PQwoltizHB0a/4NJLbnJAfwXLXY8h4QEzP/MD7haA+VO79F0Mcly9Cfqud2HhXhePFjeIUcNKVxFyc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1e2e536-adfd-4b23-4956-08dc3c4bb90c X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:10.5534 (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: GIWQGqkmad7/C936cyeqhCjTXTA7i1XVgQoyXeVuL7y2OoH5YY9mt7kW4Ae6y9RG/LkBS60rxxuU5D1utBXmmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7805 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-ORIG-GUID: 5qEmw5wsRA9CknE5NjX9jPmM-nS4v_R5 X-Proofpoint-GUID: 5qEmw5wsRA9CknE5NjX9jPmM-nS4v_R5 For when forcealign is enabled, we want the EOF to be aligned as well, so do not free EOF blocks. Add helper function xfs_get_extsz() to get the guaranteed extent size alignment for forcealign enabled. Since this code is only relevant to forcealign and forcealign is not possible for RT yet, ignore RT. Signed-off-by: John Garry --- fs/xfs/xfs_bmap_util.c | 7 ++++++- fs/xfs/xfs_inode.c | 14 ++++++++++++++ fs/xfs/xfs_inode.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index c2531c28905c..07bfb03c671a 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -542,8 +542,13 @@ xfs_can_free_eofblocks( * forever. */ end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip)); - if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1) + + /* Do not free blocks when forcing extent sizes */ + if (xfs_get_extsz(ip) > 1) + end_fsb = roundup_64(end_fsb, xfs_get_extsz(ip)); + else if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1) end_fsb = xfs_rtb_roundup_rtx(mp, end_fsb); + last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); if (last_fsb <= end_fsb) return false; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 2c439df8c47f..bbb8886f1d32 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -65,6 +65,20 @@ xfs_get_extsz_hint( return 0; } +/* + * Helper function to extract extent size. It will return a power-of-2, + * as forcealign requires this. + */ +xfs_extlen_t +xfs_get_extsz( + struct xfs_inode *ip) +{ + if (xfs_inode_forcealign(ip) && ip->i_extsize) + return ip->i_extsize; + + return 1; +} + /* * Helper function to extract CoW extent size hint from inode. * Between the extent size hint and the CoW extent size hint, we diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 82e2838f6d64..b6c42c27943e 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -547,6 +547,7 @@ 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); int xfs_init_new_inode(struct mnt_idmap *idmap, struct xfs_trans *tp, From patchwork Mon Mar 4 13:04:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580560 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 28B5A40BFE; Mon, 4 Mar 2024 13:05:33 +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=1709557534; cv=fail; b=ZblO+8KLZreXJVtIOM5H6d3WERfLRnDNsvaeJbaxUaJtKosuNQEzpQvk3RXshXYFPuvBuJiTssJsM53F5vCY5fqo5FHYChPNnkq5JkkqrDDD2OHuk25efsUakHdJGHUOeXOts2JQaN0mbYQy7iKIAAl2Lk3gYaoGkeo8ySihuqo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557534; c=relaxed/simple; bh=Q9H3linQhy3Rd+qOnEJ8VqTkPGb6qyUDCEMjTJDy+xU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Zg6MCizrmDcQ8ohapVvGzNosggGwivdexii3l4HJ0+dAycenjig2/uUr6AMTAjjDOrRGYXOMaise5Z+OQvCUBpy2sM8SFr1KWVbBm9lCHHFq4H31NkadhPkWXt9qt4AJm/hrIUfkigrN+G22Su3bA17Oglibm+SGFAttibrlKXw= 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=QIWmkrvK; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=coDD+HQb; 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="QIWmkrvK"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="coDD+HQb" 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 424BTci7013674; Mon, 4 Mar 2024 13:05:17 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=DFG5LRLYRA73VG4UeaLhU9Gze/vqNy3acuXPH7OaWNU=; b=QIWmkrvK5x+3gXk71IQ/3h1MAtRsT5IUZBkwH2ezlVrUo/kpemBOWNubTYnjZ4CKz1Yk O9LKUibV+95iDGy/JmN7Qcf+VAD4RiAwAiN3CwGyeKlyP1a6B1xPDmE6NVS+0hYO5X/r RlxbLRP7/Mdoa4gZo0LD4NeNJiL8dARA+7Mbx+AQyORTDMjdB0J99LsaUx8vYAo+kksL j/ucEYngHfH/Mq7+ErTX2/UxHLBrmszVa37a5VtLhWxugA7rD/xp+/EmA6krwBrlDvjO AmUJIgVlMaNtALuCLXW7D6NFUEtBPRWqlZGozHgvvzr4PEtiYbPHB8d0H9c3LG3EELd1 tg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wkv0bbewq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:16 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 424BBhWg015176; Mon, 4 Mar 2024 13:05:16 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj60777-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mkYQqie7simRe3SRwJvgwUvisaCBRjaIRWT7nToqyMhTvRXFavba3lemX6zimsHZOyxki101F28WzU4piWlWydNkRjYkhQ5oZFyijAHeueDJWl4MpgWlAkQIvGiV6Zx9vkQPRRkno4QohhZVlEUFGRH48WP56nYcgSuRKXujpE4aa1gVNBu942Ijn982SYHVfaoZZ7FNLEvp5uNJmNE6CxSk3sjF66R26h+J4MGsXQ6snrFIv/GgvGvtLQzDGZPqpARiXxkOMtTSDdxwdSRIco8vrAswvAFkUq9wh15E2slx2V7FHR/Y2CLirXhs3sBIZbZVd+G95trvUpCO+cD8iQ== 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=DFG5LRLYRA73VG4UeaLhU9Gze/vqNy3acuXPH7OaWNU=; b=Xs5gnHGpFZdO3/xrHenw95H2j8eKaVDd+HafUNvEC5w0sB0avt20Mq4DGvBOcL/W+tQdrmGw+eS9TxV3omE8MfUiF5Hs1XOA+WrPgWDHcT5rrtugW4I38Ss6iBDy6Ss6C0gBAVAL4SsjEk0Zd+gjApEo4+53iRIxihzT9aSd4iExuOO/W5NCJYVVKr4twLX9ZcgFjaSNUuaNDMfkYHyGURC0hmD7wpL9Uv00OzU9Tqh8gqYN9/XPcwXCAGbFjTCglI27aqWy4413nOVPR7qs2JwdrLTkOLstSXoCfjJ1wPdz67KkGZ1u9nSlh8JOyGD538vzCyNyBsxVmBHoDDQVLw== 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=DFG5LRLYRA73VG4UeaLhU9Gze/vqNy3acuXPH7OaWNU=; b=coDD+HQb6Y5KPukYkkhCtSxcphI05cEUd8S0tojtu4uxW7XG/6qUXvoPLyLKjc/a+gTY10eaXdg46OQR9ELEcQPl8llPnMl8KzwiuqQV+wGoXqmuE2ST75T2+NuPydHMhQXq4fHTq9ckWZlf2a1yG27xYqvyvqljrCpdaTNzTX0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7805.namprd10.prod.outlook.com (2603:10b6:610:1bc::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Mon, 4 Mar 2024 13:05:12 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:12 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 07/14] fs: iomap: Sub-extent zeroing Date: Mon, 4 Mar 2024 13:04:21 +0000 Message-Id: <20240304130428.13026-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR05CA0198.namprd05.prod.outlook.com (2603:10b6:a03:330::23) 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_|CH3PR10MB7805:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a1aa76a-7a4b-41b8-91f8-08dc3c4bba5f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z+GZwwPBaI4iFt0Jh3rY9xMD4EA302mn0j/JfpcS3HlvleMGBe4BdzaCwD/ae05cXAmnv/Zs6CcIQcL3Agc/GDJ/ldH/nXTS2ty2+EN0UoKzkYRVq0kCHQZjsDCiqK5GC6vF48oryPb86ISXYSQ3ZZJlrKo1yC4zPgac+h6fWBQWdds1kUXeI2S9i23psDRFxyFveMAvOj5ndXuRb6BXivJ/hzvdSo3GCbkjis5585PIcGBjDQ+ztTdDnUxG3nCo7oT3wOcXs64ATsUEAkDGIIy93UteoRvdFOT6aPVdpmNTt0thWvzoI8gVr/6/K+rYuGV2I1zGXasFf5PhDwV8tqoYQP3uD92eqOJ3D1ron0UfFVsnhqMYy9D9jkxf7En/iQxg3fjJTJdydK9AIESb0Ii/pHB/APiqg1geTdfAhCaGuA2XOH/5jVNjE4k8+1yuf0cRHdjNX/38Piq+FOyLTwLWg2whYCfW2/K8tkscjlg0XKRU2jBtL+QMjWUhUR3ZK6u21x9Yzvzelk6/uzK+btSMCo1wM2NHjTQyAWNTYR7aBCtyYhspIUW4IrR4hjnlZhlxdE4HmDbFTMwhVcREwOR1L9FwkhI3wjDel8ElRNkQjx7XhyY8MBdnQXLGETzZar4AlY2Nt2QmsdKVgVKbg0ZffNM5Z4NF3ndgzfyYCb0= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SDHLpNqgrdASdA8wZgHSn8hPbWSP9+0OMQVmN66+rHkcuUQrYRJpz8LqKtqk+vfxg0/itJw69I9m2Xd+JYJ7uIocLP4SCPgngAg5mp9IDwquq6VpM5hTWCDIJsqZHMKsdSDNoBhJsXebK1J8pZOP+WNEO8muGLjhDOdZUnttRt1oXGT/O3gtHbdx/QXNgapx8X0zyMHSAZuiACS017V4ZXtzLKXrnxh8c3Hkl3utMS372I5CKwMOQUPeEzAmAk+Vsd7FTXEZk0VWYhdenmdjZKMQ+cD5kv4ZSomLhu2fPWdlihMKpfFmBCe9zbOouLBT8wXg4LuTD/VaxkOaG3YqLp1HbnOjXWCtxZPiMbAkFgZqsAHqX/SSndiK4E9eYtiz3JI6vZ5DUPvmsJqg4mUh0CJSH2T0NamyGls2H+VoH116wwXjlQdsCPmo9/WOPzmSzAFSOq5WA7D3NeTkXd/61E/en+/ais/inRCGJPcJg1dsRdAMGbqMFPRVsM/ny9Hrr7PLPZL+gr8kI8v126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YMq0NlKuIlRfz7ZTvISesg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: F8eTPCnWkJiN2ENiaeuk4bXfth6Sb2Xkq9rj76DZbbg1zn8yC3/hrPNE0MdNDc3Nx5Hc1xY8hDHhqL45n2ryZY30CtuCrvvBsq9Z79WCmTlJgWnZyYfpBbcO1bjIgHlRe/uPqOgTzXweY2Ix/XQUChUyGYa0CdvzmuP1Nu9PKrn6HruL6i/O4U/+7dZEt6tQswjPpObWC0Vk5AhB2yn5MzMArUWc4W41MX+BJQwUXa2ITnWVwA2B0E5zrCrx3gKSrzcVZhSziNuJGGlSPfemj+c5X68CraE39ECsArrnb4w3zNaZPIIuiz3yaINrooIp0V7iRGxh+T/oSW3uboUDmtNZwClRpgRKjlTxYv3G3NyGBJVgPjP4qulz/NE8FFvi7LyfPg7dAUxCGjkbtjQ5u/xTo+BLr9EbxKfzRPf7nJM1I4lZDeCqySe5yQgptZbVCju1u5ZVMgW+0lAzAr8sMNB35gdbJ/eRc8Ncdvtri68NNbjbg8Gla7Rh3WMeBY27c4HMoKWDwv37JLkfTIBWO5lWTpmVUmMuJjibEdyXFg4GAKr0byVPE1u2nvOsmQydjzZ+jWWJQFv87m8zXnDoWG/R7i3oNSkkfBA1SVBOcFU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a1aa76a-7a4b-41b8-91f8-08dc3c4bba5f X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:12.7744 (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: rRVpNkI1iQlHVBG/TSFjeV8ns/3p1cCuMPkAnxOcL+46c4DaV1EHqGhNoEj2kvjkUVGKEww7NIJKm8LpQpAfwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7805 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-ORIG-GUID: EB1d-KFg5WCeZYecP-Rt73wVovmx94f4 X-Proofpoint-GUID: EB1d-KFg5WCeZYecP-Rt73wVovmx94f4 For FS_XFLAG_FORCEALIGN support, we want to treat any sub-extent IO like sub-fsblock DIO, in that we will zero the sub-extent when the mapping is unwritten. This will be important for atomic writes support, in that atomically writing over a partially written extent would mean that we would need to do the unwritten extent conversion write separately, and the write could no longer be atomic. It is the task of the FS to set iomap.extent_shift per iter to indicate sub-extent zeroing required. Maybe a macro like i_blocksize() should be introduced for extent sizes, instead of using extent_shift. It would also eliminate excessive use of xfs_get_extss() for XFS in future. Signed-off-by: John Garry --- fs/iomap/direct-io.c | 14 ++++++++------ include/linux/iomap.h | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index bcd3f8cf5ea4..733f83f839b6 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -277,7 +277,7 @@ 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; + unsigned int zeroing_size, pad; loff_t length = iomap_length(iter); loff_t pos = iter->pos; blk_opf_t bio_opf; @@ -288,6 +288,8 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, size_t copied = 0; size_t orig_count; + zeroing_size = i_blocksize(inode) << iomap->extent_shift; + if ((pos | length) & (bdev_logical_block_size(iomap->bdev) - 1) || !bdev_iter_is_aligned(iomap->bdev, dio->submit.iter)) return -EINVAL; @@ -354,8 +356,8 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, dio->iocb->ki_flags &= ~IOCB_HIPRI; if (need_zeroout) { - /* zero out from the start of the block to the write offset */ - pad = pos & (fs_block_size - 1); + /* zero out from the start of the region to the write offset */ + pad = pos & (zeroing_size - 1); if (pad) iomap_dio_zero(iter, dio, pos - pad, pad); } @@ -427,10 +429,10 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, zero_tail: if (need_zeroout || ((dio->flags & IOMAP_DIO_WRITE) && pos >= i_size_read(inode))) { - /* zero out from the end of the write to the end of the block */ - pad = pos & (fs_block_size - 1); + /* zero out from the end of the write to the end of the region */ + pad = pos & (zeroing_size - 1); if (pad) - iomap_dio_zero(iter, dio, pos, fs_block_size - pad); + iomap_dio_zero(iter, dio, pos, zeroing_size - pad); } out: /* Undo iter limitation to current extent */ diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 96dd0acbba44..89cd3dcbb8ec 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -97,6 +97,7 @@ struct iomap { u64 length; /* length of mapping, bytes */ u16 type; /* type of mapping */ u16 flags; /* flags for mapping */ + unsigned int extent_shift; struct block_device *bdev; /* block device for I/O */ struct dax_device *dax_dev; /* dax_dev for dax operations */ void *inline_data; From patchwork Mon Mar 4 13:04:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580559 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 0D32340BE5; Mon, 4 Mar 2024 13:05:31 +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=1709557533; cv=fail; b=AqhAkXS+IvKsZTu49K4Jnww0GDesv7E+6z1wybezbrUN23vRH3kcH/MHoLyee03CcgvLs8ifxNb6TjoS/bBIQrZWaWwDi/eCwnBlJTU2+DtEA7SlA8rixX2m2G9TaFCksGVkMJtXj6iEmZq1wqjocVFnTCpzgxVIGbaCAa4G9O8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557533; c=relaxed/simple; bh=/z4sEM9vsl+vl1q8/4TbI5aNcm10Pk2ueEnPwk/tJuI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=moVLBKud5/VA8sr/hfKB4oqCjcsI76gRholq4A2yx8S9tjvuflNEMsn8vAZBhAHdYxzwcINjByLSj62EncEe5+8Ap+ONPbWGyfyYxmQ0FTo3enogPjitnfljV1Xp3f4qdq7WL5x2R76tUJO+UJhl6WK+Z4cuUQahUxVUxgGWyxw= 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=k0/zdSqi; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=H85MLe6O; 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="k0/zdSqi"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="H85MLe6O" 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 424BTlDo006034; Mon, 4 Mar 2024 13:05:19 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=uL/AYD+j8Wm56sVAVNdKqVFkqBHuZvDY74wwcEjR92c=; b=k0/zdSqiwXaD/REFbOvseE0nop7yGlRIIQGJYSnyUFmgjiJI22Di9g0UZC51qeDkCbp7 1+8a+O7vst6X3acmL1seT3g0lDP/mXuqcy8gQX4F1/y3p0FQdNhMuxjrd0JcRbgtlcwX Ns805NecDUOWlRl7mtcUyhID5Od1zQSdewwBlITC93PL0PoTBoDseCyfXjzDWJqKL9gO 5Qfsrvee/VOTjEflJLSJaUnnui5Mnuyb3ncTtgVQXo8sxv670K2WmCN5BKBCbj9HDviR 2tijDuT7RfpBGF43QK+JewTWBjoTJSnM96IQRkPFIRBZsPdhI1VTynxMt1fdAlV82RIO 9g== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wku1cbh7x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:18 +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 424BBOAI018965; Mon, 4 Mar 2024 13:05:17 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj5qgxq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I9BH1q8/+MxmT9DC5yx3SR3ZLukCFeU28k6TKo6xIhUO9EHR+bsi9Eq+ommPl2ed7gWmeKsgshyVWKUgY2kMBxItyERJnkXVcY9Kh7BeRsJhzQKnh5oh2pXSf9b61LOulMXqt61UKKdkuxVAyH/Ehl1YD/SzWI7m46UIjlKr0lh4NN4AquNuzpWfidCPN/wKynFcaPqlv4fWCy1sI8rPOzpn9QfNtlZrlqWNk3kvDPoVlEPAyQv5bsC0IGMeKS4EaCBZmvQWniodcdKZScVgTFcmPpdb70vhh6uMcepvGvK0MNfyp6Il0G5dy+WnHD7Jz0iNX5Glpyr62poDXiS8UA== 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=uL/AYD+j8Wm56sVAVNdKqVFkqBHuZvDY74wwcEjR92c=; b=dKifVh6VrrJdR6a2ucm2ucd3JRQzR4h2FXrgPF19tv0aAOhWBWBsOTG7kjYmHXHzMb1lbf4IixYvykU5FjVAOXEVYo2sQ0KfbonMs3bXw7XrKJCiS2EUG9BwnSqI26DBLPA6E+9jtTnMplw+GpptE6nanOZlJ4S6pvLnqFFh+JDt/DQFuynpk1viX3UslXzmcFporhaR54SFL2HxhQZKBr+REsE8m+a5owKRT8FTNQ4XUfa5tlVae0JLSAq1OWerfHCaVOmXYiGBIr6Bc9UctN9+XWt5Ey6zx8VyGPqzqN7JHrIF2Eq49xjJEwybwoUkctdOtXWCr1Ao0BKIhDuwAw== 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=uL/AYD+j8Wm56sVAVNdKqVFkqBHuZvDY74wwcEjR92c=; b=H85MLe6OxIwPwMuRRnrpRiq3aLpeBI/JWIaTFdqF4GbGBIU3vO4i60bs6BM3Hr2MexzIvR7kb/RfQOmoTAA2opuzmbrInGwntJRT0ILFMUZYuvIY+sSCz4gUaioH/KYwKrga+N8Ml5eCedPcl0YX2fV3hhR9pbkUNOz7h/MNlrY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7805.namprd10.prod.outlook.com (2603:10b6:610:1bc::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Mon, 4 Mar 2024 13:05:15 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:14 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 08/14] fs: xfs: iomap: Sub-extent zeroing Date: Mon, 4 Mar 2024 13:04:22 +0000 Message-Id: <20240304130428.13026-9-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0072.namprd03.prod.outlook.com (2603:10b6:a03:331::17) 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_|CH3PR10MB7805:EE_ X-MS-Office365-Filtering-Correlation-Id: 84bf7950-e820-4e23-84dc-08dc3c4bbb9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LMhQFY0DcaAChZnqlaYzmpewnwVyrQKUrw5pooS6cuqr/3wCtRgzFZe5rIYFWQlobTidlTUf9+Cqakq72NeHz+ZD9AMzCyuTQ6ZXWk8U9FMDwNQjBhKx1wHBirit9ajlXjJhZynlYugnfYj4yYd2HSOEcL0YguCStNGb/53iFCwGvN2F0Yek5baeCGziAT+MZ67ufymG6wSfm+AjY7JiEs3Q1OL2ullH/zNyrkq4QotlzhfhBs4TSA5tR0Iic6JdSKoaqltYydv+1751QlvMtLraqI1vlkpR22QUCI4SO+gUdCYRCk95eGgEbVgYDSVsknpr1z22rJairTn5KN2aoj5yzubUZB4YHEWORCvKcr0aTEqhBt+YN8hX5ETpWPBza2n1GWslpmJ3YzFt4J8sjKvcherKymXEhEj4Eyy1tRTxHMiU4sC3EB4CyQpH1TEQJeC/GWpJJV1Tvb4kyhhqea4td6vRsj9ob9Xi7fjhUx9fB3hcv3tY7MMJ7tBfM6YLHoMuKGKNMZU7/+rVew7vrbQyROkVO9b9C7rMX6ZjgleFjpnKIhZJxOD9DPWMnKuLYx1axPOF0/D7ZxbneLa85HKxes81BFEFRNfnSedohEe5AvY1IbSsoRbzweqlaeZ0OgnttVrJ/3BByrjYAD5tHoYdzqhpxDPfgHIGYMu2dDc= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OPGEKnwU5GVI87FnhPP9f6FnxVFNMKbjLuSNDcGcu6L09gCypcBNtcJM/ulTdhmmd/oVircte1/C6tOQsYNKZTYfRhDiv+nZF2B62sF5wV5wfqlYSWjWA/lxqXjYV3sGselAfNn2iLyrcmjEdWtgjfvYMfN4w89zWCIgojH7AqC4Yt0PxE9mQGpOQvRguKFtLLdkt+8Jw4NbSIaH1bm5qw1gD1f6M9bh8Ota0CGW1AK9vsdS50YpgeA2DUvboZ75Pe0RdQMcovEBXQD1TvU65rlD7rYaYO3dSCUEIH7EEZNhaHTi6nANIalmpfVy+5+RlHKFseHr4sYu3d8jS0t6JdKg8iUctdp2EX3BNWeJNFYNg1oFgarSZ4uMnLdYb04vVTHYzL9m2KfSbf0FiKJ0AT+/VqbKnhPwJlouEebO63HVIPevX0+XCOuE2Xvar7dT/k+rlbG+Dv3MHnUN2pYV+K1g7yhaL2NFpRmpVgQ44Rsk1Q10f7vC3KxCqtv5SQuXwUoVGEhx1vFt7TN6mf3aXxbLzuIdR7dEgCBj8RecaDYPIYyNk+q5clRTcmuqEU7ss95G5S46uM1HJUPM8cMXM/ZdW05/jrvf3rg4pg3OZvKx5GCwqw55XdAMo+gvAYVk36TnTD2s6nEdUWzkcPQ7F5ZjjSQyl8b0tC78AsGI2QlbjwgJBSn+6nMkMaYo7MUm9skcsotEAAiCRQ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ajXJGDKeHpzx40vFPR1tvvjamPYViePvk+p/UkqRT+UwydO1CyQAQ/ztp7Y7eIvkF1ONo07gC7nfcooLdGsZg1a3Ik7lM5lhDijcYd8PF2R8Ck1GRDigKdjBVyKw8veyZIYt/2Qji9ZCotpHjKbiNUWTjKoa6aAdUB33HEjgdEG02TPmAw3XH/cr68p4iV/CippIFIs/HFLX6sFD7yoP7LXU9uR2v8YtNS/iHvr3hhM07jJPWtuQomtqV5D6T5f6dggbWl3DLsTm/701JUZDx0A9nOnbM6L/9+DFErSO+jKvpv+aBhiGdHHO2pztcy9Ye8NFbZ0RNE49mzwEW61X2U3o/AU3jG7VVTUCFSgDGr6SuXouCOqjjbnE1nfgswXmy+UjkQeCQj5ED4ozYQRmBPOnThEypXed+zAxsAT51sF0FV2ruekoyEnKm25rEs9iSNixfdMQ+Jk1LF7f4GtvvWhvb6CT82iu2InuEtYWM6bIxg/JjNSK/QFZXpIHeLtNeidlhc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84bf7950-e820-4e23-84dc-08dc3c4bbb9d X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:14.8995 (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: KqNGMyOf/Ah9kXQ3rXeKgi8SGnW0lTztFlFSAgyc/6Q7apEn1iOJWcWkPqbNOW/vgjUJyuhTYfjjOTGcZxmnDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7805 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-ORIG-GUID: e8lg22jpYYc021IiyK1Mvmy4VjYVbQzX X-Proofpoint-GUID: e8lg22jpYYc021IiyK1Mvmy4VjYVbQzX Set iomap->extent_shift when sub-extent zeroing is required. We treat a sub-extent write same as an unaligned write, so we can leverage the existing sub-FSblock unaligned write support, i.e. try a shared lock with IOMAP_DIO_OVERWRITE_ONLY flag, if this fails then try the exclusive lock. In xfs_iomap_write_unwritten(), FSB calcs are now based on the extsize. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 28 +++++++++++++++------------- fs/xfs/xfs_iomap.c | 15 +++++++++++++-- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index e33e5e13b95f..d0bd9d5f596c 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -617,18 +617,19 @@ xfs_file_dio_write_aligned( * Handle block unaligned direct I/O writes * * In most cases direct I/O writes will be done holding IOLOCK_SHARED, allowing - * them to be done in parallel with reads and other direct I/O writes. However, - * if the I/O is not aligned to filesystem blocks, the direct I/O layer may need - * to do sub-block zeroing and that requires serialisation against other direct - * I/O to the same block. In this case we need to serialise the submission of - * the unaligned I/O so that we don't get racing block zeroing in the dio layer. - * In the case where sub-block zeroing is not required, we can do concurrent - * sub-block dios to the same block successfully. + * them to be done in parallel with reads and other direct I/O writes. + * However if the I/O is not aligned to filesystem blocks/extent, the direct + * I/O layer may need to do sub-block/extent zeroing and that requires + * serialisation against other direct I/O to the same block/extent. In this + * case we need to serialise the submission of the unaligned I/O so that we + * don't get racing block/extent zeroing in the dio layer. + * In the case where sub-block/extent zeroing is not required, we can do + * concurrent sub-block/extent dios to the same block/extent successfully. * * Optimistically submit the I/O using the shared lock first, but use the * IOMAP_DIO_OVERWRITE_ONLY flag to tell the lower layers to return -EAGAIN - * if block allocation or partial block zeroing would be required. In that case - * we try again with the exclusive lock. + * if block/extent allocation or partial block/extent zeroing would be + * required. In that case we try again with the exclusive lock. */ static noinline ssize_t xfs_file_dio_write_unaligned( @@ -643,9 +644,9 @@ xfs_file_dio_write_unaligned( ssize_t ret; /* - * Extending writes need exclusivity because of the sub-block zeroing - * that the DIO code always does for partial tail blocks beyond EOF, so - * don't even bother trying the fast path in this case. + * Extending writes need exclusivity because of the sub-block/extent + * zeroing that the DIO code always does for partial tail blocks + * beyond EOF, so don't even bother trying the fast path in this case. */ if (iocb->ki_pos > isize || iocb->ki_pos + count >= isize) { if (iocb->ki_flags & IOCB_NOWAIT) @@ -709,13 +710,14 @@ xfs_file_dio_write( struct iov_iter *from) { struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp)); + struct xfs_mount *mp = ip->i_mount; struct xfs_buftarg *target = xfs_inode_buftarg(ip); size_t count = iov_iter_count(from); /* direct I/O must be aligned to device logical sector size */ if ((iocb->ki_pos | count) & target->bt_logical_sectormask) return -EINVAL; - if ((iocb->ki_pos | count) & ip->i_mount->m_blockmask) + if ((iocb->ki_pos | count) & (XFS_FSB_TO_B(mp, xfs_get_extsz(ip)) - 1)) return xfs_file_dio_write_unaligned(ip, iocb, from); return xfs_file_dio_write_aligned(ip, iocb, from); } diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 70fe873951f3..88cc20bb19c9 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -98,6 +98,7 @@ xfs_bmbt_to_iomap( { struct xfs_mount *mp = ip->i_mount; struct xfs_buftarg *target = xfs_inode_buftarg(ip); + xfs_extlen_t extsz = xfs_get_extsz(ip); if (unlikely(!xfs_valid_startblock(ip, imap->br_startblock))) return xfs_alert_fsblock_zero(ip, imap); @@ -134,6 +135,8 @@ xfs_bmbt_to_iomap( iomap->validity_cookie = sequence_cookie; iomap->folio_ops = &xfs_iomap_folio_ops; + if (extsz > 1) + iomap->extent_shift = ffs(extsz) - 1; return 0; } @@ -563,11 +566,19 @@ xfs_iomap_write_unwritten( xfs_fsize_t i_size; uint resblks; int error; + xfs_extlen_t extsz = xfs_get_extsz(ip); trace_xfs_unwritten_convert(ip, offset, count); - offset_fsb = XFS_B_TO_FSBT(mp, offset); - count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); + if (extsz > 1) { + xfs_extlen_t extsize_bytes = XFS_FSB_TO_B(mp, extsz); + + offset_fsb = XFS_B_TO_FSBT(mp, round_down(offset, extsize_bytes)); + count_fsb = XFS_B_TO_FSB(mp, round_up(offset + count, extsize_bytes)); + } else { + offset_fsb = XFS_B_TO_FSBT(mp, offset); + count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); + } count_fsb = (xfs_filblks_t)(count_fsb - offset_fsb); /* From patchwork Mon Mar 4 13:04:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580561 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 B2FA73D578; Mon, 4 Mar 2024 13:05:33 +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=1709557536; cv=fail; b=uN2tG7sM8dEgeQfaq9dxqGk9styrteY9JtvHIPHk52spIzkvfLl/A9SPo+WDedYTDQQgai9iRFQzRYHZK5ft9d7MsgU/vM/VKdDrdkwzIYZyew0BQCSbZlPrtz+cuY4iU7QDVyBLUoS5kA1QOl0T9RyYAMwdoZ8P6DbkjDcI34Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557536; c=relaxed/simple; bh=UytkUkRUwEIxo66vkcZ7o4fT5aovX3iG7tkjcKfwUCY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=FqC8iRNKhJJJhlGmymMGog7Q7bPg0DBGwHFrtMI8nUmTHUqyB7IhbbXLw5br0FZ6d2vvBHiIVsWyLAGqcjsXb7sbFv6kYKRAOZuMZG5pwBpZjUcqWa0OZtk9JicaT4iYuHzhwryEV0hcO1KUrwEyzqODunXk79/NJQmtJbgxpPw= 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=H2yDCtvb; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Uod+Qcax; 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="H2yDCtvb"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Uod+Qcax" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 424BTBGw006563; Mon, 4 Mar 2024 13:05:19 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=Kq12PPaf62RHqquV+EQx7IAGXFa73lUNESxSMMKVvhY=; b=H2yDCtvbB0YWyCsmo3aZASz7Wu5C9WEPJYeinN/1XbjinElYRVys2qdhaEJFGphU9WTK GiI3g6T51PkfhsNOw61yHhTROH4QI1Drvnh+JQgRdB2OkDGS2AZz9CCC9xHFH1eNCY6x p7KzQ6EBV9eIdlP2GSL+wDfMTV8kL9XxqkqpjpvywR+n/1n+3Yh//yutRk93Vfu6aUx0 BiiONbBkdjxpuKttsedbh3B/J4U8inIoA7ug10h7DMbRrfiytYqttjHjzo9sXrXByOTw Vp4fyxXNyBAfJ9VsUQLTNNGyLHGdrX8DPqyxstWesjxN40gAdkop0KIkWRUfGIDGNVZ6 TQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wkthebku6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:19 +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 424BC3nJ017048; Mon, 4 Mar 2024 13:05:18 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj5qpea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HGkYoDhxNE4Gfq7ch6bilTw6Z6qnCzcax6fBydKTC9gic+REOQpNiRO9jZZ/TZbzjxHXrcObS5cjmkwANoeQIMZzf95jKRfCLPpHTAww18wizmhPHjN8sgBmx03o4Q1kvzP34rJk9/CX53nsGTAzjtOL4DL3oIIzS6PLcqK1+Zr1rlToJsmhJ+lz3t0GTsaTlrHeVQZHYabm1BRBcI84fmwQMfS+QYoO+fOn83ksh6n1WWlV7CnoJdTJFpQOFi/9UBNEv4Q+08trVEVIhzalI3dHrFdn45Y6kql4RETlzUmBway0kxM8DDDyeihG0CtsPGUZ+1ZWsdvdYVlt4gQQ0A== 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=Kq12PPaf62RHqquV+EQx7IAGXFa73lUNESxSMMKVvhY=; b=WoEj5Kkd7j/YbUdlMwemBzjJSvkj17AYBn/vRjPtWvjSwxSpeM3HMoAC4Fee5wxToMEPF5imAuuHu/N5QDmKn4q2tyF9D7ebq0Blr2PwbSN+a7CJFAly9Br+519SPap/X5UuHVmxEQzxb5OojkqFETulxrt3wyTVzxlqK8+PTI0MooziH6tFSPq0F5Zb1phE1I3LCIQ33nLdzzxtXgOgMHnEgA/eCQpTOl0O7wkneTeN1yXn5CNfqZeg71Y7B8DZQa7DJ6SaMUJhrTz8yrlIu4BUzmMMhr15hY6mgqYVs4IRjEWyrYUo9x869TNxITJHX82diMG20kx1jlRsI59xBA== 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=Kq12PPaf62RHqquV+EQx7IAGXFa73lUNESxSMMKVvhY=; b=Uod+QcaxJBskQrNM8vQZ4sC1m1OPwXBE++McweLh9IPZw3iLBk6avn5y2UT+wGI1KdIoflY7/eCQ151BPygagIKiFD5visoOQpumFwlvYfeLJn8jPVpGtF9aPCcWQEdCl6PzEQGksgZX9J0+6+nfDt8zEeQxh7M7CBVSDVP3S/0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7805.namprd10.prod.outlook.com (2603:10b6:610:1bc::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Mon, 4 Mar 2024 13:05:17 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:17 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 09/14] fs: Add FS_XFLAG_ATOMICWRITES flag Date: Mon, 4 Mar 2024 13:04:23 +0000 Message-Id: <20240304130428.13026-10-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: BY3PR03CA0015.namprd03.prod.outlook.com (2603:10b6:a03:39a::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_|CH3PR10MB7805:EE_ X-MS-Office365-Filtering-Correlation-Id: 864638a3-0828-402f-8846-08dc3c4bbce5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JUpsY5Rfm9Ch9246VzLAxbGP8gKFdvKDFH4QwdtJPGAMWbm1jbE1tW5TTS2DsKr2nspCbMeVstftHiAe2gkF85K/sek8/MgcsbPokou+La30ZsdTGm5VHK/qQF/2sNjh3+5/37wx2lWQayDiuhPMQn81WtuMt7Nh8E9H03KS07/c+vY6zz8TvAkiaj13SDyBA/Pli6MBe6aEw08ywrpjylUi+Xl4Vj+Wj+j1AD4LyZJz20kiNcB0DZqPuPDcgXge9O5g53DfU73fDmC8uys0In7iJ3+UwBB40QfEtEVv4SKaRzGRVx10fSAl4dMu9P59OcHjHOTX6l/99kVtglwVXZicA685VCLYIQbaukbZgNd8ns4NXz/kEkGNVJq+UtYjXWyvBsSMGr5kySTA6+LwTghkeIF0PL+GNSwkwIYT1mQ2Av4ttC4uFLg48lyE1cuN/akWXJfQt1e1bTdS8t5iTaZFcNklMKWv6q5hWgGHZatvZSu3q+UIP+4QbNw0gP307jnS2O7f/oKubqklnDVyc50+2gTNIV+DUyehBFnXnuIMNtoILJvjy5SfQZO+W6ZnTLbm42tf0v+WQaiyYSnyLgAOwnV8Ng7fP9XULrOR2+yE4gqI/xeAo4gK8Mbo6uI8DQ51sDs6VRxQgAuEBU0qVfd82230ji67+R+dTgG5Zco= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Ex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ch2Z9Q8agKFw404ZD6AEKNbZZ15bUV7T8hZZ9sS/EK0m3iYD8OZfLu3YAhzZoE1Dx+8zCU0RAn07BBz4j1U0koIFUIIPHosjtuyHupaOeRGzENNsjvB5DCOn+PCUV7TfesC1PzA5/JKcy/OrYMXM1c6pxz5di/Qfnvbsdo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 864638a3-0828-402f-8846-08dc3c4bbce5 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:17.0289 (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: oLfT69SeyeN1ZlNthLoPhbTmhkocGyqLCatcYap+L274A3PmUbnBEKYzA5BqT3a8Naw5tmg6/LPE4W/IQ/+YRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7805 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-ORIG-GUID: DtBp3BB9H2BKAKNeFeKDzOWsE1LfBMJC X-Proofpoint-GUID: DtBp3BB9H2BKAKNeFeKDzOWsE1LfBMJC Add a flag indicating that a regular file is enabled for atomic writes. This 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. 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 8828822331bf..aacf54381718 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -142,6 +142,7 @@ struct fsxattr { #define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */ /* data extent mappings for regular files must be aligned to extent size hint */ #define FS_XFLAG_FORCEALIGN 0x00020000 +#define FS_XFLAG_ATOMICWRITES 0x00040000 /* 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 Mar 4 13:04:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580564 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 3C8AC3E479; Mon, 4 Mar 2024 13:06:35 +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=1709557596; cv=fail; b=GJD8TYtoxwDQuf2sD/Q5ypcwU+IFXa9/2mJFLhM7VvKqRAIA0sr9UX++P6HpCwGc9Q3y5xYEyRjGMTN/lYpB0zO3RR3yDJ5Qm3XdRi18uNsR/lFF/y0EoK5sFcbk+rsYaMdTjiL8L0nrHX/Hy5G0DLtAa/Hom9hVDQWzvktiXno= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557596; c=relaxed/simple; bh=tBgXuR/8sAHQntFICvMGTRRv3wsqjgKBJ5Qh6WRnrjw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Q5JaSjM0rvu4NwDpVgR/zPWgyoh2brfkgu+VDn9RjZWKvzsugnYKPU0yghrlprq7biTu9s7G0tqyvH4gDNtrtCipIPOTLMHu1o1LqYz/KRhBfR6DUYehp6XEDf+3JrUFTa2+2fv2rpixgSuD0Q8kHQSxNpPKHZA2jTLmAgswRJY= 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=i1GJJDYh; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ATjYkODY; 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="i1GJJDYh"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ATjYkODY" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 424BTmf9028485; Mon, 4 Mar 2024 13:05:22 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=zk4e0dToTTEsqQ87dpyQx5aKdhodoJj2t2vw4pr0zyU=; b=i1GJJDYhACtKHGcblepYn8z5Vxuz5FoFIYwUR/L8jYMzb8SRf/ho8P1xR9Hcwax0QO8h ZZbNf9AK5vCLe9dILWE52rADYOubQqgTT/buuzQ+xTF/MNr7Fmk6cIl/7elPNWeHA5qK I0EsmOExmu1xeRhTSJURKRoec7UsOXeb+yN+yusX+7EMxSPxwlOE61PDcb8z6YiFVfPW aXzT2upShFkVjPwUBONV/48IoGQDh7hL4gp3NdyhY7hjjEmW9HZJ9QCsUHKbrJlAhRVF HFwIMCAcapmJhLBkv1SouiVfPsffYNrJqCGno+9cQgQ8dJ7pT+rlXfd5+Ep+s7CW95nr CQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wkvnuufah-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:22 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 424BYo4M033901; Mon, 4 Mar 2024 13:05:21 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj63tnd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B0WUtl6V9MtEEHJIhZRxqzWKw0swalljMigJ+iC8rTqLHIvj+QPKOuT4VcELM4kboRXYB3m/y4sjKGc/Vqm0cFvbSadHRl/BTjumQA3FblMKzNwaOdiZodXVrmL8llzJ2LGSIwoufg8y2wZFojxWIox1787WV2SMmWu2/LY3+5ASkfljP7SEsttpRg5wF3mGRtdLORHByXXhSPI9ncO0H+g/wEbkHYT9Mw/zinhNPNNmwo6qmvXPpgXow1J7b2LLUGhYS5qvlU/4E+6apfPjCzsLFQOeJ5Gl6mqr76n3yqVc/LzI4Ee7hIG1NI/5gjmjacin08rAymCA/+VPjXjmEQ== 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=zk4e0dToTTEsqQ87dpyQx5aKdhodoJj2t2vw4pr0zyU=; b=OCf1QzbZ/VbjJK81GAEFafyMC9mB5pjM+h+59PpZEq4UVbTXvS2Zoz8WoQzusjIwsYxN+iF8Y03ZLgf7JGnLBZQDYny5u2gj8qv3zAtNDXbdj7lnjT+5MeQTKAd+V5bxBQszd3EbpJfWO4toEOvnbawXamoaWPDhIq6f7r1A5pek13GS7Un8PV8sItQqYBN1GNZQ7WwoyVchnQ8Mbp5E7Ci4OOcOk7O78ZwGsiOLQDMvy/fv2iha0N2kVe/GsZM5Gak4ELp2+iThFpEdvXATkC5MazEPnWrTWQ62MgVST223mhJb5s9B9TwySd6vu4acyF/BNJWn+CIh8qUOEOXtYA== 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=zk4e0dToTTEsqQ87dpyQx5aKdhodoJj2t2vw4pr0zyU=; b=ATjYkODY+sCS1Wmj+JSTCp/TniW4Mtjz0bezqpm5xY2XKgdwGYw1a99xyC5vuqwh0TulvEGYupD/Lu9z/Nm2U2zjsuehMc9pZ2bk0AcWsh8WCMpVQgVbWkfggorhWuSEbY02mjuhZvlwJ/SFdG07g5ImErJ8Vv1JmTXNHxR7JB4= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB6860.namprd10.prod.outlook.com (2603:10b6:610:14d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Mon, 4 Mar 2024 13:05:19 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:19 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 10/14] fs: iomap: Atomic write support Date: Mon, 4 Mar 2024 13:04:24 +0000 Message-Id: <20240304130428.13026-11-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0293.namprd03.prod.outlook.com (2603:10b6:a03:39e::28) 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_|CH3PR10MB6860:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a4c495d-046f-4c68-b901-08dc3c4bbe2d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9LNi9gRVqT5iReJXEITjnLO1DXkyL940qWIzqpatrpJWZjGDrlnwaOHm9QbLBjV2+OOQEhwC5dKaQRJF5hUa0r0//IPvYYvUVTZ7CDnax1GgEfiFgR1CEPrmAIALhv8d2jVx312gyOMc8N8Fh1f4m9qqF84Aq//xQE3+2l6+Aiwqn35NpRs77C+fkoS5W2kHBUyySHQWBBjbxBsm37JAYIKb+vWm2SUAdq8vxIogoTFffGuracXqAwU8ylT1Iow/v5mOdA142aczYq+7CH2wQxX56dwAV3yC7nggbu3pFuH4eDuhCL9VakUEjLpvp0L7cXv/pPgSeBsB6YbAmYFB6u6dU9QFFVIdmPuhjxz3WhIKumZdSDsydnDvmBkzX8WgV/aYcxXqMDfEVIUj67aKe2a1rumvwSzBWof+uBkkP0bcAxzj56rP2nMLt+fGEaHAH4DGUZYKk6qRfA9hOUIR6QTU0bldJhLgIaWTKKjANQqtFgmfN5MqEVrc8vCiGgsRftTnUKcXAxat1G/ZdWynIJy5SbB3Qhvim+zqE+3Hw3Kdb0oq6OJ9OdRF0cTDWtO+Yws57N5N17McYd7RkN0V8aQdba0aJ/5wSX2AdEU9FQN8rBAzHt3JK6KjMU8FVF4ckiyTB9p4VhAMy0aApFWVSz7PsysmR7B9vKVosj994lY= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YmrGQ53tnEzVfiBnNXduov1weHpWhXDyhuYMc9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16nP2ooEkUugrpAMEhMmGcZIhqTAkjn+HVYi0hMK4gsq+j5dB+iQWMbVOyAeXpmrsMUuTM/Qlai9kBeDlTj460vtZoXAzB88/NCR6Ocgq+8bf3mb5YXKjpZrBI7plRJsP6is= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a4c495d-046f-4c68-b901-08dc3c4bbe2d X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:19.1779 (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: RPTE/GIsrSilqvAsnHC0yNxjHBpyt46xuT0ClxNDifGZgJae57k9rGDUH7JpFa7tONvqqhdcyp1agO4cu1lBcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB6860 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-ORIG-GUID: Wtt1xs-BUwvDnsC9Bj9DFpmTNnS5Wnsp X-Proofpoint-GUID: Wtt1xs-BUwvDnsC9Bj9DFpmTNnS5Wnsp Support atomic writes by producing a single BIO with REQ_ATOMIC flag set. We rely on the FS to guarantee extent alignment, such that an atomic write should never straddle two or more extents. The FS should also check for validity of an atomic write length/alignment. Signed-off-by: John Garry --- fs/iomap/direct-io.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 733f83f839b6..197f1bb6a261 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -275,6 +275,7 @@ 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 is_atomic = dio->iocb->ki_flags & IOCB_ATOMIC; const struct iomap *iomap = &iter->iomap; struct inode *inode = iter->inode; unsigned int zeroing_size, pad; @@ -383,6 +384,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 (is_atomic) + bio->bi_opf |= REQ_ATOMIC; + bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io; @@ -399,6 +403,12 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, } n = bio->bi_iter.bi_size; + if (is_atomic && (n != orig_count)) { + /* 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 { From patchwork Mon Mar 4 13:04:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580565 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 18A813F8E6; Mon, 4 Mar 2024 13:07:41 +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=1709557662; cv=fail; b=TDBwBkV4OeqdlaDcH6UOIouR6RYQtR5qb5nidrJNPOH4JQoUwUTqvNt5NPFKyAKd/ijj2Jf7ltpjmWew6x6fSF3qqe97ofovqOl1WfsYqe0mom+QFLTd02rOTGu+P9rCleSqoDLlYsOJk5FFPcoD+PFrOtKEsg96Eq+xIXJ8Oqo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557662; c=relaxed/simple; bh=4/0UaAWrYPV3jf2pMqAzhPTGodEsep2086jP9lBYW2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Ypa4Z01Bj4cCMi3rOyCIPTGvIecmdaB41BojoTH+8144vu6YCKo8cl3HNc3HrXb820uSZ0Ac76nSN7zx9pgq7ADMuG3DgQfpuHE07ySUbXHpdxbm4faAAwn2eT0oOE9fY34zwHUzsl0S52XrK6O1J1vigxBVO8bHR+8D0rlQsW8= 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=J+ZcCZpY; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=shJrmZI8; 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="J+ZcCZpY"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="shJrmZI8" 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 424BTmKP006052; Mon, 4 Mar 2024 13:05:24 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=e3OmCewsJ2y5E6Njd6QGlj9m0X84Mk2nVaejCFbJo1k=; b=J+ZcCZpYRjXhbZh1ZMDzjipzcaU27SOolCTgq0PoUwb/QHbyzm72i2oFuyf00ZRDVaxK TmpJ+sBS+RcAw/J+Kl7r0FqxbHP9lQPsWR6wd+1fH+Uk4kE1N8iJg1VAJvsO7xu18sKd PLdTPgZHwDZiHbMF2G9Og8GkXmmbDEu0wZGofkE6pL+TVy7PUE8J7SPBPX06rx74FqKJ 16RbiBDGi/YiZDh/HQXOoyDubKhL5BwPVgVgzlaLhHsQb4SKUprrq5x11uXA4TRow5iM ++BcUaDwLhOiz5bcBq8O4SegpcT699cyCVeQWptKjjSWj/1w4ipyuNKGYnAxFst6frYw vg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wku1cbh84-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:24 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 424C4NK4033209; Mon, 4 Mar 2024 13:05:23 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj63tpp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ty9ZmO9okuJ4DUESCzHRC1bzR4jHF3bCP41HDjND6aEY5U71ZKDicpz8zoofn5dIjxE0Q1u2Y1LO/QBynFOOmKlZGFIuWFLDL6v7ak43+vTS4+BrF5DaFVy3tr8TzcjpDIfM4fd/Gk7DGA2PtgFxEUqnSSCXU1n900rcgsE+b+B7DE4QaPTz2Mvjd1ddyo3a1CnGONJk+mpQ6XUkGBkDVKjG/enn2kfZoD3hRUDqyAF9/DREm+n8lV8fuD4BIQ12LuamMRkcQseZtMnIjny02+5ClADOEE/KS+w3kQY7kH8pRY1X9Ch2suVf2tOGc0fP/BKa8YIQ7wt0Ggs1lXHX/A== 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=e3OmCewsJ2y5E6Njd6QGlj9m0X84Mk2nVaejCFbJo1k=; b=eR8VPTelGXOUi91dBvBSZ1IlzVTNKeg5kHNQ/m4Nj3aKdOloHYcwyJ8r5IVGhMMiHqE13owslmABs+kmTdBn73XtKSmZnQDCdrtl8RYFC8JBRVnsAPpimflVeego7oQIf2PesfdlvoPV+EsI0UzaCIw3Rp4oqvXBnI12yASXTl7rJAWc2n5/Jtwo0+tb51iJt9XaWLB73hIa54/AMUMVW167yeKQ7Tp4rELQfHRwxb1+2XKK6vwCRk8GG4DgvC9VHOqSYv7L71+IwbOSqzoF6r1/klNKX9FKtjVEuRKrB9bfKzdDyuwqPPIasslRC9ssRuV6Fp8v3beZiXyGfuvOrw== 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=e3OmCewsJ2y5E6Njd6QGlj9m0X84Mk2nVaejCFbJo1k=; b=shJrmZI8gP3riY36Vhg80o3fD2pXaXenk3z2wL+SJAstgyXiof7faMYc+GuW/k+kPciG/NZqWk86H7pShXOBgs43IqgAH471S+FhsZm4JVdpb5YvyTtZf6sYN7jufrPoaNPcc/ukZe7niHOMEpb9Uczz7SKDe0brd/mCuowLkP0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB6860.namprd10.prod.outlook.com (2603:10b6:610:14d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Mon, 4 Mar 2024 13:05:21 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:21 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 11/14] fs: xfs: Support FS_XFLAG_ATOMICWRITES for forcealign Date: Mon, 4 Mar 2024 13:04:25 +0000 Message-Id: <20240304130428.13026-12-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: BY3PR10CA0013.namprd10.prod.outlook.com (2603:10b6:a03:255::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_|CH3PR10MB6860:EE_ X-MS-Office365-Filtering-Correlation-Id: 1685b78a-afed-47d4-c930-08dc3c4bbf4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vt27Gf6rfrfwXpvp463+ZzZDPVR7ikMJtbYbY6+W2TXo4tWN0qPI9djsIMwh1EvswKgk672/1LMwLHKnWeBkq5dvMIl7NGROBekliozSp2eCfFYLVw6f62gJHwmzQvsjpBBMgt5tstupaqndGey6xe+n8t+vnilQxVW590wuwWq5wSeDIYBkgntbNLpMksk/aEreDJj8XocTi9/2MPdfaXj3sSI/lPzyO2whoLEfUaj6xUoYdkEADZgwO76M6AmmFSvRfqITdXK5O+r2J9gwcbPeOK2bSb+bw1EoJMjw6Nsu9K7a8CiKsI6EsNfDjWpd6NYPNlT3yHUFtmevkIrjofvmbWPsM7fy8ZfFmvtZlhzxIPYPu6GMky/mHE0W9Zg4SoIL7hoxcP+Ektf4s7cHd4CXiklmizGaCaRd/vN5Uav66BhXOwdTM+mHO561H5s7xFG7OWyRhwutbenKUxV9/AfL80GNrovydEerC/z3AfDwCco3yL7O/RbXjaCYQIZXdtq+FtM4yGtUiITRJugOjN+sttYC7PH1Z7Y+4Msa3vPlSF8VLpb/739ksQxO33DNwTV9VidQ6gc6bFQfOADFjCaPXkWZQGSESV3ESQ2BApvCMVHXzp0SyXJ6TqH2dE3HRRd0mY/6GDWqruCU8BaM7JbtvePKjA/QxwLdfzK7F/0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG: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smJ8zjreZ/3NOBWX1qvgPCqCxbX0Ozp3i5D5GF78Es5jeNQ+WvWg7mDwahRWhj3DeO9v9Gg7I5mfAFVvV/f+Qs0foyk9UWy9uBbcYoR0oa/I+8HlwNovF69bBA+zplwTS+uHAIYdog3QVFf6zg/mR9mjFfooSOiOip2hCtw4u8Q+kpxuPvixo68QIqjT/43fC/8RoWMoI8bZA38PNYYKpefFvpEoKgP+wp114v4v7I4O//dinNM9UI1YbgE2NP1gOFab1bYHJCJ0wUp2tWA7WNQR9cAah/HUc1eH44CHZ9iFEm3Q5iWlvRHkcDHtcaHpg1JfnqBvm2t06I= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1685b78a-afed-47d4-c930-08dc3c4bbf4b X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:21.1532 (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: LpN6fTFGdVHmhyaGYHc+/KMORZTZazmFlDL7yFg1jLEw6JvPaZ1X0BfT0hLarNNd9sqBGRjCGGXDIq+PmowJng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB6860 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-ORIG-GUID: 51tZ7tmXIsdxhnYh6LACNUw2hQ1_5-BD X-Proofpoint-GUID: 51tZ7tmXIsdxhnYh6LACNUw2hQ1_5-BD Add initial support for FS_XFLAG_ATOMICWRITES for forcealign enabled. 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 also guarantees extent alignment, but we are basing support initially on forcealign, which is not supported for rtvol yet. Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 13 ++++++++++--- fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_inode.c | 2 ++ fs/xfs/xfs_inode.h | 5 +++++ fs/xfs/xfs_ioctl.c | 15 +++++++++++++-- fs/xfs/xfs_mount.h | 2 ++ fs/xfs/xfs_super.c | 4 ++++ 7 files changed, 38 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 2d9f5430efc3..5f54f9b3755e 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -354,12 +354,16 @@ xfs_sb_has_compat_feature( #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_FORCEALIGN (1 << 30) /* aligned file data extents */ +#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_FORCEALIGN) + XFS_SB_FEAT_RO_COMPAT_INOBTCNT| \ + XFS_SB_FEAT_RO_COMPAT_FORCEALIGN| \ + 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( @@ -1089,6 +1093,7 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DIFLAG2_NREXT64_BIT 4 /* large extent counters */ /* data extent mappings for regular files must be aligned to extent size hint */ #define XFS_DIFLAG2_FORCEALIGN_BIT 5 +#define XFS_DIFLAG2_ATOMICWRITES_BIT 6 #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) @@ -1096,10 +1101,12 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT) #define XFS_DIFLAG2_NREXT64 (1 << XFS_DIFLAG2_NREXT64_BIT) #define XFS_DIFLAG2_FORCEALIGN (1 << XFS_DIFLAG2_FORCEALIGN_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_FORCEALIGN) + XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64 | XFS_DIFLAG2_FORCEALIGN | \ + 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 f2c16a028fae..d7bb3e34dd69 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -165,6 +165,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_INOBTCNT; if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_FORCEALIGN) features |= XFS_FEAT_FORCEALIGN; + 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 bbb8886f1d32..14020ab1450c 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -645,6 +645,8 @@ xfs_ip2xflags( flags |= FS_XFLAG_COWEXTSIZE; if (ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN) flags |= FS_XFLAG_FORCEALIGN; + 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 b6c42c27943e..f56bdbb74ad7 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -310,6 +310,11 @@ static inline bool xfs_inode_forcealign(struct xfs_inode *ip) return ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN; } +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. */ diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 867d8d51a3d0..f118a1ae39b5 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1112,6 +1112,8 @@ xfs_flags2diflags2( di_flags2 |= XFS_DIFLAG2_COWEXTSIZE; if (xflags & FS_XFLAG_FORCEALIGN) di_flags2 |= XFS_DIFLAG2_FORCEALIGN; + if (xflags & FS_XFLAG_ATOMICWRITES) + di_flags2 |= XFS_DIFLAG2_ATOMICWRITES; return di_flags2; } @@ -1124,10 +1126,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. */ + /* Can't change RT or atomic flags 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; } @@ -1164,6 +1168,13 @@ xfs_ioctl_setattr_xflags( return -EINVAL; } + if (atomic_writes) { + if (!xfs_has_atomicwrites(mp)) + return -EINVAL; + if (!(fa->fsx_xflags & FS_XFLAG_FORCEALIGN)) + 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 e1ef31675db3..3b60d8a1d396 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -290,6 +290,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_FORCEALIGN (1ULL << 27) /* aligned file data extents */ +#define XFS_FEAT_ATOMICWRITES (1ULL << 28) /* atomic writes support */ /* Mount features */ #define XFS_FEAT_NOATTR2 (1ULL << 48) /* disable attr2 creation */ @@ -354,6 +355,7 @@ __XFS_HAS_FEAT(bigtime, BIGTIME) __XFS_HAS_FEAT(needsrepair, NEEDSREPAIR) __XFS_HAS_FEAT(large_extent_counts, NREXT64) __XFS_HAS_FEAT(forcealign, FORCEALIGN) +__XFS_HAS_FEAT(atomicwrites, ATOMICWRITES) /* * Mount features diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 74dcafddf6a9..efe4b4234b2e 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1712,6 +1712,10 @@ xfs_fs_fill_super( xfs_warn(mp, "EXPERIMENTAL forced data extent alignment feature in use. Use at your own risk!"); + 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, From patchwork Mon Mar 4 13:04:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580563 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 D30C040876; Mon, 4 Mar 2024 13:05:48 +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=1709557550; cv=fail; b=TrHMEOEywnr0G9apTmjsB/EHeaRa8iS97PtAp0eBYsfjG0ov12M6YWrINP+T/T+iT5yPAn8TN+MetBR5OqAx/nyatzl87j10/A3plQBKG4Bm3sz9SA9bT+BqO4jT1GY3LYAQ2u2VSUTQ6dola0mj+0xzUy3PUqvYcr7irPsLgyo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557550; c=relaxed/simple; bh=lYLobJ0MIuTtMdARP2KnNZVfpWyfaiPCypqfxE9xGfw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=d7ewmkxQMfiH1vP8E3F2foaxhOCZi5pqydut9qsqrGomX05aN4X+v48pvak/YFvEGl8FJAteE2U/HxV9aVAYo1BnLS7frjXIjAAxjWK61ZjtoNRm3FkFjPZuMsWMKNU69LvpcG7BgH/LBpfiI4tAemaRNRGXNSGBmArZ8Vw7fXg= 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=Oupaye51; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=JCtr/d8c; 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="Oupaye51"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="JCtr/d8c" 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 424BTm1n027762; Mon, 4 Mar 2024 13:05:26 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=Y9Wo9Yza8bnad1n1qNYTg8nNKyoC48u5aWvcAt5RRo0=; b=Oupaye51m91lyhUBun0gdw4bP2D7HyVQKEm+GHURFwhrxBqd0obf2WPtTa4nWmaf6ikT azQotYqFsPKIRiio+RYpNo+t1aBuCUCh0f4KiRA+SdJoWrlqDQ0tiIOEiKYXZDpZWvFv NP2Ml8YCxELXW8uhpDS7gkxcoAkKHteg7ErmY/QlLCOUjJJt8IdLyPk88+Xq5XcMwJi9 SM9unOEVUaG27shdQp/RVVSnwSQ0gp5qooHvB+KhMyG3Pl3MDpmGloplRi+j3p3NwBOg CbMwrXL5++rpVl7dQHkyColyExtPmm2A89BVkJrBDnbV2pxDVQKjuO5zi3vYOmGcCDYd 5Q== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wktq23hn1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:26 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 424Co7Yf033255; Mon, 4 Mar 2024 13:05:25 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj63tqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mlm4yn4K+KmJniU1BXYUItOePqPwDzuj/GsZWXkNkv0zyBRR+vQ6fEJPGR9dRtWEASJl7X2tKETOhMakegnjT/X1/pCpGKTw7YPLk2skmCBOEn1mJlk+XF8be4u1G6vHVYGakZj1STCBy+H8KIJf8XcLhKJ1iuS5Z0ToBCD+tZOlUS+QqKB/pAVUE8z5enfEFKQVHU6gGLah2QnGin9YekNQYP0ecYp4SWknclV07PIlupdC2Z9NXG/dGB3IIWVbq27XNzRXg8RtJ8Gbpnnk3ureTX+7/ClvACEns3qUQi+HaZ938jLy+36mRY3elvii1nVAw2oxT3Ll224pie+CZw== 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=Y9Wo9Yza8bnad1n1qNYTg8nNKyoC48u5aWvcAt5RRo0=; b=CBBJzQ2Iupjk4ndLVcrjK/jiol/okMv0mILnELm/QrYKusKzYPEG1PInFGyawcAYnT6raiRyhFd3A4WpnsJ/l68JODixmtnVIs5Z2juZJmTzpnjQ1cAwU6rYp46GWARNUA/L0rc2Xtu6cUBl7oYcKLAelR2sT0R0Jq7NnJo/hfI9QTYsks8ibMjmZz/wDO2WhVuLVP+ZsvXlcD5+8c750/IuF+KLOTB2o0NmNJgMyirxKzenOXU4/WJqioTZCNPHdfenb5eq/mLCvf6oxzF49ERqc+1gZJf4nC6osIZp0aQhBJu8uo9hhZdQ4UkkK7S6J+7ffYjMI3BNRXVc5FXaNw== 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=Y9Wo9Yza8bnad1n1qNYTg8nNKyoC48u5aWvcAt5RRo0=; b=JCtr/d8chmValTnUQHm/UVlK5pesOOFmS/3sSkuoyi+IZvoF1J0Q/MLT7y9MpAqadiiBwnYktGUdHD2MJbWB9/Yzfq3QrbJgcJjDDxC/CtOMYygamVAkGhyWDHkcBQLXks9AM5UNn2GyY646ZNUGK9xY4o0M2waiUVf+Tggk36o= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB6860.namprd10.prod.outlook.com (2603:10b6:610:14d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Mon, 4 Mar 2024 13:05:23 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:23 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 12/14] fs: xfs: Support atomic write for statx Date: Mon, 4 Mar 2024 13:04:26 +0000 Message-Id: <20240304130428.13026-13-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0191.namprd03.prod.outlook.com (2603:10b6:a03:2ef::16) 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_|CH3PR10MB6860:EE_ X-MS-Office365-Filtering-Correlation-Id: 212e7776-e5c5-4cf3-00cc-08dc3c4bc082 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sf8nsuokU6CludR1Iup44bOBLyFehi4rqUx1IEkzDYj41MTSY2pv+aU2vEj1bLj04VNvfMC76643TEHlnSglus5QdVLFcovlBjXkgwO+0Q01CIFk1TYBhmXzoFtq4eKMHq2lOHWFS33NG3Voo4Y5YwjweM8a8CMFUDjfRohdXBJfCzJhQN8xkojBjs9FlilbvSE+J3e8sWgfDmZF9EpEndj5gVuvRP/qskaYPa3dWzuR4xfpOMVJSJ8mWaFICcYmsMJB9Bxx35MIxIOrY6PP1atjYMi1IAcvhIJn7QWsPObK7CPVBKrNegQ9ZQflb5IkIR3SAUGrnPIdwZZfgeoPG2oY0DIhD1Syrq6tIIIFKKYur+TJSb6M9MOxs6oIRuZQ4BiHaWQP5seoVP5hAh57OL2h4hQy797ZYwSiDthQput0IHbMKVLfjQQWaD3LVNOILQnt8Z98aFDGfHdMJCYtWk6hzD3RD3TWpG/Fxx7k/0WjP1qD3FPJi9887YKaqW0aZ0iaTpW1YxU+Bar3rM5YKaMAkQOLUGbD7vLvuBNSRX/oCqjAZy4t9dsltS/J9zZmw2MeBFhMcGovOQUMbrhCFmEY4GJ4sk4tFtMvpGFVrcOXUILAuYuFEtBoyuNgva9qQg2q5S9FNpWCKykzdLS4jgtklpXkG2PKAORv74Ioea0= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tLru9ud7ntP31SKZ3KIfMOAuib3DobDG4N+Y8hO3qwpTUTUe6/+DdEwOPFTbLYzbnpiTQmh9WT+N4WDykySbaV+shd17UEp2r/aSL2pUg6hKF7NF5J4z1hvYh87QHPdTZpizf7BLNpj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k= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 212e7776-e5c5-4cf3-00cc-08dc3c4bc082 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:23.0921 (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: w7sb4EoaOocLYp4ERGBVWct32PTuTFPaRaRsmHARIfx5UomQR12q5uEqehVtM6bHeoLNW3VC1wnXfUaJjKqYhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB6860 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-GUID: 2o3Jqdu9fm3IFtY5nYK_o1lUI64ZPMC9 X-Proofpoint-ORIG-GUID: 2o3Jqdu9fm3IFtY5nYK_o1lUI64ZPMC9 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. This is required by iomap DIO. 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 | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index a0d77f5f512e..6316448083d2 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -546,6 +546,37 @@ xfs_stat_blksize( return PAGE_SIZE; } +static 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; + struct request_queue *q = bdev->bd_queue; + struct xfs_mount *mp = ip->i_mount; + struct xfs_sb *sbp = &mp->m_sb; + unsigned int awu_min, awu_max; + unsigned int extsz_bytes = XFS_FSB_TO_B(mp, extsz); + + awu_min = queue_atomic_write_unit_min_bytes(q); + awu_max = queue_atomic_write_unit_max_bytes(q); + + if (sbp->sb_blocksize > awu_max || awu_min > sbp->sb_blocksize || + !xfs_inode_atomicwrites(ip)) { + *unit_min = 0; + *unit_max = 0; + return; + } + + /* Floor at FS block size */ + *unit_min = max(sbp->sb_blocksize, awu_min); + + *unit_max = min(extsz_bytes, awu_max); +} + STATIC int xfs_vn_getattr( struct mnt_idmap *idmap, @@ -619,6 +650,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 Mar 4 13:04:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580566 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 4AB3B3F9C2; Mon, 4 Mar 2024 13:07:42 +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=1709557663; cv=fail; b=UJO6cDgrDdP5J9uHPoXBKhqMYp3mK1WtiytOZt214MtFzLCfGn6mrV0CLsE571Ojjvk7xkG6Y9j0hWgB5Ld7TnzhICfHY6+qt1rcd7V9ErR8tQpCSFh3l2P2/xCWV2BcnbWqQI+otVCaya1XwS+UIzW9/+vd4uLkqIoCiTVKXew= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557663; c=relaxed/simple; bh=bya5+n1lE9I2rj+emKMw47YgA+nop4TXUk+4hhTNEbw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=auzyBL7h+Z0XzIIOD/e2MUr5eJawi0Xdrrdnmd5bszceCYNxuX+Sg1ETKZkD/4+rbhoJwgDRpEUQMJTklyTzk2Cj75JaekjiTUEFFNACEC38RYMHGJ9bcIXoIdurGUvKXASDMj8hAs3bcubxodAeggEicks7786lKxWu293JgyU= 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=aA0lwIoW; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=QnwwdA8Q; 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="aA0lwIoW"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="QnwwdA8Q" 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 424BT879016931; Mon, 4 Mar 2024 13:05:28 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=YKeU5/UbS9tXv6rTbtg85ISQ6CHZttBeC7rs34WbSAM=; b=aA0lwIoWkbS4znMDQyG1rOXUmdF5zWmeIUWIngKvrNVq6Qy7QFFM2R+4FCiUt34aHbLQ Mdo7bHvZlywyr0DA/l3nM1T1p3874lgropE6g3IH2raGZs3495iUey9PQMxBsShMllfW h6CYLH04Up8xg65eU8ugScNyR9v1Vt86dKTTHgUJ9Eo89H8iHo3GsbViPEuCU3gWzeSA 5bFPKtTpaTKDwHoXGRh1OUCbBfjy4Tg1o5U7Qx/vzYbWmIkLWtqzyl482C8NutWjMyF9 fU/8VH4U8fiigy18orp2wrG60Ws6ifu72xjSxQ43qwP5bUUBPnfrfm5RhxLVTQ2VdRM2 5w== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wkv5dbkbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:28 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 424Cc6gG015200; Mon, 4 Mar 2024 13:05:27 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj607gn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AAFCtZNIdk2i041Xy5WXnjvlOHlyWVom04xg1C3tbiOoIo+xOmBP2N+d4r6Xxk99Dg3VMunJX/3XvJUhT/6ffQlDvYMwzej8sN/p7MPXQegXSWOnY+ZyodLIX8CcMhyg5qj3z1e676s8a25E/KWYZcLZwxGqIJVJSHi2OwJDRUfVTF+br4TIQOv/ssW9putJYdZGr5dVcku9DTatgUasj3/Oe5zfIuB2lQK/6ygGgUOGNiC5gNAvYo3ViZBKtz6Wzdv/e5CdLFItFJH9ZTazy5EmyJ+nvwZwp6EPrzhaRuWROmZ4eBLgkXSBOoRZkA/4li3XxPjdB1ho/QE5AEuJ9w== 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=YKeU5/UbS9tXv6rTbtg85ISQ6CHZttBeC7rs34WbSAM=; b=d2B1zaEj8duWDr3rnsKMr6aA4znB3M3hM+aANUTZVo611TDnHyDkAeDravff6/QMqmJInAiA/MOLvBFxKfdWXXjwuEeYVWg8d2lPdysDa9OdrzZeh0yoTdw0ZGqgaOFKtRyf+Mf6caKSFmJNMwjFLkfQu/KQ3NTUmRiVyAKgmMGwUWsFBhe2MoQCYNPLVVCp+oW5GeC82gKjtJHYy8HC9Q++2/+ne2EfIFGzLsEAu3VeBWO8qwAPHyDDscSVRiABhVLldyWiHDWi0alcjm5xTX9tFuYuoimnwzoO1k0sEpLd3yeZ0XUT8JJbLJcOyY3qDZpQsobHZFxfcQ6pNqehQw== 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=YKeU5/UbS9tXv6rTbtg85ISQ6CHZttBeC7rs34WbSAM=; b=QnwwdA8Qwiu/NWDsoazTQjtaN8WPyRzwXC8YY/AbfE9m/L6Z+FwTanPV+u0kSgK1gvsQD27a5u07wg1LBkHabBhZmv2B4TYXpOhdBz9Z+gS2bRiQOsZSOlC9PByb7zYjti5eSTFSnrUHmkdWD4SWavo4uxagnlb3Q1M/BDISoso= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB6860.namprd10.prod.outlook.com (2603:10b6:610:14d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Mon, 4 Mar 2024 13:05:25 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:25 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 13/14] fs: xfs: Validate atomic writes Date: Mon, 4 Mar 2024 13:04:27 +0000 Message-Id: <20240304130428.13026-14-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0193.namprd03.prod.outlook.com (2603:10b6:a03:2ef::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_|CH3PR10MB6860:EE_ X-MS-Office365-Filtering-Correlation-Id: 11aeb72c-93f6-4dd2-a632-08dc3c4bc1c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UF2H7eJDpIGtXh0Cwl4MQQnAab8li2phPunS+E+aOMnjxftTuez6MbEe/fHBycYKMsKuU3uiunsCyg5o6L4Ya+0kLSG2EHFBFyZL51W0wFGuXzjAbb4G74DNMHiaJ+qI3aDIP3EJEQdJig+Ka2GeBBqKzKfh42L2PnV4MiYHQHC6EOnobCpmAFG6OcuOVZ3CbPa5RmSL9mKPApg/KNKp3nHheX86xaMLJnnoNdRFMOTsg/Jz+t5BL5OfRHeogTWszjF4WODh8n39xK27NnWx+X0B7Bu49t4QYkesta95CpaOY7cJOmNY+gH6jqktdmARx5DZZGQ9DZxNy3C9++zOKSqekU5zhAc50kWsyQ+Op3cu4pEucL+oaznTR/RqrnLrOAYoqnDA5NKKfm+59xB3TL+xDwxLOMiVfZIMOqTSvJ9KTFwtSjXYxmEMNJIc5nDvlfZwmtfyaZgtVi9boRPNxmfDgTMj4MPCnvIE64dcRnIBF9pwvZdjhNIu3FsIGhZ5LMOX1P5Ojf7qh2xVLzPvghUflVh3BSsa0MT6CKmHysVm5pPk56fbDxyzW8FLMSko3S6MTbT2iXp+Es2HmDQvo2f1gr9cUO2FUEnLAbjI/Cudt2jEBudZuCS+k+SzcFUkjZDyswetlYVuIomb8969gLUAzsg37shpwQAGcvKG3SY= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6MJxle0zvcJgrXnbom0zEA1tRHlkLxt3gObr9E6KyLjhNKQqQ2vUNWlzTtMqLrCeRUwWwvzjLDXZy2OXthK9DR+z2DkhHh56TcjwAA+Cb+iC1PCPVYs570WcZ3glHSQsTttCCuepFpk82Q66AsXvFYHoOnvXXJFz+yhSMDrtkB8Or8t/9i2PtzZLmdWZM0vcLbBEaXFQwlQoh47+mXUiiFXZHp59FtK3joee4kDxj4eiFLYBeBe7JYHHMDzoPOwwbCgBF01c8s4gPAsSdzKpT+y1mq5t3hoHHBbUTZDKgBZVpj20MZCHTAj8bdXEuImAnN4wGOZtrFm7FWXKFegUbZy+u5NJZD3agOLQCqUomLGxMxy75AHMPJxBWjAJ3Wp+QhDDOJNdAYXMAH8c5sg5ZYlUDX1iuipuW2fzILzDf01p/ws7Nvhk4QqishG1rXhivzlIkFLGsvQ8zyup3OgrqHNi2SSbOucXgSca/06bMB1HbC9rSsmk/VssRmlSEJuRj19G4BZHjvf1AJVmUpK21kdRfQhDYdrSXlrM5QpCVskVrkpINIEdVkEtg+Agg/65AFVH1E6kjjfXi5QBy3u2aoKwXWSlT4KnGWTK04OOfkYHBtZz0LVQ51uNlDn5KKcHG16OgDQF0QXYMoByyR9WTKYkBCuW1OcTbOTgBYTAzV6OtYL1fy+HEc9gsSbElrEi4MmOKu6VwVCbMvtcGXhaIdTF3u2Z/deUWFYQQ9DDpAWLm3XhIHILC6/Hv8WNMNRbN3OhubPzZ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J6SooJy4r4lPBO2/DQcLjH1e67n71cE2CzkXGtif1CPR4uJSfgj3qHvNocar2TrQDLlRW01yMcpI+kP9/mERWnC5HmO8ArN8xaD+oCvMbBsOWpVxWXv9YtsTDOZq1UYThGg38BcWM2QsrMnEb1kIJj7v6OUtT26+RWrHew2YMte7bKGsalGUDLtHaJBawsvRsKVoM1IP7+1s/xoYEbLHA+V4IB2BOiqVIokaeZcJBiRKG7Ia9xBnBRlSrgZP93ATvsmhzdMamzmKiDISXaO3tRqQszmGIz9g/pl5zAoakVCf/A7DeKoMjlQjueCyLeZjeJfYWwHDGCjo/KypwigDa63ttglwyFNy89TrqMcOdUANVnBrLOJooXQup5HuBubBevERoWH9TtNswj76sT8+gep9SgBlWev+qR2St4oQQjh9YUsQeQVbcQIlWH48aSYlXNSXGbG/n6YRR147M= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11aeb72c-93f6-4dd2-a632-08dc3c4bc1c3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:25.1944 (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: a2jT+TW8QlCPaYU+plKS0p9pWyXElOLrHKhUI9jDOWl5RNvmjpQYMhl4acSceXziULVz8MVK988wu+ofhmCmjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB6860 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-GUID: OdW0a3HQdkTLDYAqz4R11zCLjRCmob6_ X-Proofpoint-ORIG-GUID: OdW0a3HQdkTLDYAqz4R11zCLjRCmob6_ Validate that an atomic write adheres to length/offset rules. Since we require extent alignment for atomic writes, this effectively also enforces that the BIO which iomap produces is aligned. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index d0bd9d5f596c..cecc5428fd7c 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -709,11 +709,20 @@ xfs_file_dio_write( struct kiocb *iocb, struct iov_iter *from) { - struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp)); + struct inode *inode = file_inode(iocb->ki_filp); + struct xfs_inode *ip = XFS_I(inode); struct xfs_mount *mp = ip->i_mount; struct xfs_buftarg *target = xfs_inode_buftarg(ip); size_t count = iov_iter_count(from); + if (iocb->ki_flags & IOCB_ATOMIC) { + if (!generic_atomic_write_valid(iocb->ki_pos, from, + i_blocksize(inode), + XFS_FSB_TO_B(mp, xfs_get_extsz(ip)))) { + 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 Mar 4 13:04:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13580562 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 59A9648781; Mon, 4 Mar 2024 13:05:45 +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=1709557546; cv=fail; b=sHjsOa0lDc4PudjKbNWIYFIyZOdgbFQOUW1UyK4tix0/6RXy09fYVV0tGfQLs7l5tIbMBV0sb599UyDeGhC20x/pm+bw35232WKZ8AHlt/cCp+oWFMg+WYQqEziDA/tl0EZpJoUhH6ioxwjfuHPa3TBbRSh97oq8zP/LWeZ8wEY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709557546; c=relaxed/simple; bh=TRyelkttK40ngjNNiq8R8M31tZsjJ1sEyxsL8ZDWMn4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=TWA8zVc1uinyXuTonc8mX2XUpu32h53sGYzC9ap6/x26Lqk5JEITf6f2ey2OGlAsKKJtdvS8v53OeMHBOSdG/VeDjTtZ6My63Bp8jk2cQIdRXQqno/dNw23hkMfnPbQuuc7zhNmZc78KmWmQQuGtJ2XsoM6iUSmFGjUqFEeos3Q= 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=jW4sHXn9; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=SHfm74Xk; 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="jW4sHXn9"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="SHfm74Xk" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 424BTl67028481; Mon, 4 Mar 2024 13:05:31 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=Ha8Tv/RMoC8p28JMKFanI9LLeN5wQEQnvUJUy47fDp4=; b=jW4sHXn9FtiL5xX2xEv1DYhLoBKJb1HILaxKrmuio9DKn19CnknHjpWvYIM2PaIAeg4d 6vqxjGX/K4yA4dSaQuIy1K0x2IpgXMBc0pD90Ou4maygPobgGEMUgq2hLFNOeT9XJ1bD czoX+wEIc6WMJepedgU8gWJkA7yJMiz33yWrXKVlRr7nZX4PJL62Iz6XPY9Eh6qdlqD/ O4Q1/OAKRD9rDzp4q1mOlwSzOs+tcWazutLH2j2vacLUbr9FXe0r2ARCool8H40XuxCt speT2z6a4hQnmh1toemP125AQ92g8GiI8iTQOxGGdonrhruemEBcRGw6Qddkt2K0gf3q Sw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wkvnuufaq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:31 +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 424CfUFM018951; Mon, 4 Mar 2024 13:05:30 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3wktj5qh5j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2024 13:05:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AJxUbVF/OInawU6SDOMo10fIy2pnD385NZqiKqrnwNAs+t+C5AhdZzMiapXTn0F8NFn1hcSeCD7V7tfCaiqV4zgC7TdaSFvy1Vyf7GV3pwjHn/0Y0Jk0uPh+GUUauZ0g1A7Rm8IuA0pez/JW2DmPsb/PYfkf8a+0bIdoS35WjcBH7F+9Rii+H7SLm3FJ6LHucaPX4DSABUp/KpcZsXDq1fp6PFTtOfbnB7ujaV0xyFPgBDAGNzJv6UTAFXyLlrd2Rd9/FMuKPcVgXRym9WhdzBcki9f3H9gfhCYj/T8mA5mN/c4lp7JZ+iwc9sTdhuTIL+I8qgM/BQ6FjLXms2yziQ== 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=Ha8Tv/RMoC8p28JMKFanI9LLeN5wQEQnvUJUy47fDp4=; b=Z1yd9oI2tv+CVIK9fQX1NR7syr1Kkjh91RQyevE1Y6zLWxXSNEPdwPg4BxbNWBxB49bccQIe60zO2sBugpf0wHMusytGiDs4kC+yntGeRfuhxZK5VPg0U7jVOeNCBjt6qc1MMf+aLLo0oYHglXN8FlhhIjvtF3lopgiBwnYkmj0ciXOFeMX6DdNTRz5bHg1mKUVuVtUpVZVG1pbNi6Ti38oELS6Wgd2N+c2qBxuhhb/F9JRY+TRngBna3ewtavDsAhbVmOOdxPh9ZCa+2we1gDAmytTpkcg07OxKDxxrS4yOdBbzQHgS4wX5mnHBJirNBytmwLTPNXuiic5EoAXz/g== 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=Ha8Tv/RMoC8p28JMKFanI9LLeN5wQEQnvUJUy47fDp4=; b=SHfm74Xk5wkupr53FdtmRh6YjSZ+q5az4HrA2k/BOGsUvY2CjRVoU6rCksP6nAV5+o8wzgipuAZrW5YEHi+W12NWoVa/Gfw+7RZ1NtXv0k2RJGs14VQeAkXFRb1Ia2D4OjaOQffnORbGp+2z0b0b7Ok53RC80zJykTHGq4gA/EY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB6860.namprd10.prod.outlook.com (2603:10b6:610:14d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Mon, 4 Mar 2024 13:05:27 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::97a0:a2a2:315e:7aff%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 13:05:27 +0000 From: John Garry To: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, david@fromorbit.com, axboe@kernel.dk 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, ritesh.list@gmail.com, linux-block@vger.kernel.org, John Garry Subject: [PATCH v2 14/14] fs: xfs: Support setting FMODE_CAN_ATOMIC_WRITE Date: Mon, 4 Mar 2024 13:04:28 +0000 Message-Id: <20240304130428.13026-15-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240304130428.13026-1-john.g.garry@oracle.com> References: <20240304130428.13026-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0288.namprd03.prod.outlook.com (2603:10b6:a03:39e::23) 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_|CH3PR10MB6860:EE_ X-MS-Office365-Filtering-Correlation-Id: a610abf4-5fa2-41bf-ec84-08dc3c4bc320 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gqo5gyh2IprpuLG3bGdIHB9valibyIq8GvMqjhmgjxeGLa40WfAMIT+WfWAKeV/+IKxO9HVfBmhF02s2Uy9/IPT6GllA5riM3FlcfMJMtH7AhOmanRBHzv37gQHUALH4Uopr/bbqv2+VCVF3q9gue5vdi5ztgF8xQcx8tCqlom3E9KmnhK6GsaghTJfzbU5vTHEBpoMcDrNf46rmYpNs2PDOyi/T14fmZXQ2dwMQIYXk6aeG/+s1Gt/hT8duCN+km5UkPksApPFMbfSl+LCkSrnVQ6+8lPTs1b/Iyc1PzVMr8y+w0Q1jpZ0HaaBKtpEI7uENhnzWOHJebIf46ZbgOomPwaLLd2Ualg4vfkQg9xjfefk9yR3kPZO01AFzTZpTa5wHxtKg1ngn9hCLAUphUH0AlfdMd5a5kf39ohHQOMO8y42HcEee8H+kXRS2WZLPTGZkEle7UsmWpfS9kGNQOmr3mXqopIWr6gNwmYdSnfaq6el9MRlVYduGZ83MZCsiC6s9zFePv+fahPVuFCe0zU/edNs3Z2Ftb0nVdqVrAH5WjSteLNhX+LBI+iZxlfIXt227qWggv13Th8yMTeJxojka+hqIpBAr/m/ZFBLQa57a5Y5EukZ6F9WcU6ah0AZyeP6pLDnlsqychjHidv/uNq+linJ9/svizJZNvYKs0f0= 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)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gwg59AP0HP2z5S7qPXlgRcd7fo+7mZDP9l31ldrsDc36aPrB/HxY8px+Y80TDpU2XGVxu2y3+wuaRtnPvU5R8jbRipX7r4bRawhQUGL4Hwo1OwZuojNQMx1PS+o0LBGipFuejhuazjcmSYXP79LG+fEKu9ekpAbtCo+leOwZKp4frEyg7rHl+AE0tSkp2Yaw+YEFUzonyfdYeqxooAEWdJ/C3ebBjbuPPMXT75XA0ByPmqgz5YXzBNeeYKj9Gr1EGR3YUC1vMYUYEbzv1zsLqVkRGn/0/65Dqmn9DiVV4HrM3SUzmq1H+s/waTP98XeNn4IYuQrn6++1LLZM+J3Q5lYQRabzFb3fowSarjWQblmSYf/77TAZWxwGKBhlLAUcZJbjuc790oZTxRxqHHNq/cyDxAKoq7UWl4jbfIgsWfLSlsofAv3WLklmlY9RPu5SRND4h031XBdmkXIP5iSz7j/yEYShgwsYVus+rwsG17cTw439Jr3PfylgVrKT9Mwyvs7SauMQOKe2M5EZe8c2wl4WPMTrvlBL3Q+exd/FDmsk7WtJiwV3SNHZmxVlnyCD9VbsK7IG0/J7ixDTNvYTX6AVU8SI+v5N3x8kSkAUtU0d7OThmZ79aFcF3ww+m5XcQyeUv8QP8KSL5AS1wOC4egsPGm/RHd8HSQrYEy13ZjHpFcquyG13L0zct7IW8oXlue4dAEA2ffVDmNlta9pH+ALE5SIW1y6nEMfV7XLqEgpsPUf0Yt9y5uxMw+6G+m2V+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S2CICTDQ0xiI+r0asUC2fIlpCrd8auKjaa3pbewb9QuTHafvV+BwS+d399u+F5ZiUQwCjGn9JBOa6MKv53Woo+4PUlRNf3Wl1gVbojQgCfYuW/UbW3Y9OiRyn1vGekm7UBgkvJlz2u+wFRaSiGhQx9aZkvVmqi1TO+GDcYScGraIEkW8MBbvBYYwhOl74+pxBrINy2eirS9FA2gX0BVNyUbLH9lRGY7h0C0QFwJBYALIfxwE8Rm4KpBSJnBzoJWMc2N25Jw44tipZ0FPFWaK0VxGG1mEWZC+8W/MiYbzM0ELa/jhgnAgp7inJBSVamOekK6S8oLen1znr44GnWEC+L3vBCYgSyNCuxiqYpHPKUmqrHYiwOAd81QsDrG9YwXB/uMs+QE/52bvMZixXX71nJROf9RzI5x9SPgx6VnxA7oru/4R9iFmHCQw6CfCj5mLJQaOktMVhcUUca1D7wo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a610abf4-5fa2-41bf-ec84-08dc3c4bc320 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 13:05:27.4821 (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: EXnc4QBlczFqCAxtfRrenSOSc24a4GQoxm0oziDsLi3eRdnz4ad8ooFckxitTpDvcSAr/iNz4/5O8iHPAHw1/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB6860 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-03-04_09,2024-03-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403040098 X-Proofpoint-ORIG-GUID: PJYtT9aPmANXv9VyL6IKpufYRqwz0rdx X-Proofpoint-GUID: PJYtT9aPmANXv9VyL6IKpufYRqwz0rdx For when an inode is enabled for atomic writes, set FMODE_CAN_ATOMIC_WRITE flag. We check for direct I/O and also check that the bdev can actually support atomic writes. We rely on the block layer to reject atomic writes which exceed the bdev request_queue limits, so don't bother checking any such thing here. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index cecc5428fd7c..e63851be6c15 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1234,6 +1234,25 @@ xfs_file_remap_range( return remapped > 0 ? remapped : ret; } +static bool xfs_file_open_can_atomicwrite( + struct inode *inode, + struct file *file) +{ + struct xfs_inode *ip = XFS_I(inode); + struct xfs_buftarg *target = xfs_inode_buftarg(ip); + + if (!(file->f_flags & O_DIRECT)) + return false; + + if (!xfs_inode_atomicwrites(ip)) + return false; + + if (!bdev_can_atomic_write(target->bt_bdev)) + return false; + + return true; +} + STATIC int xfs_file_open( struct inode *inode, @@ -1243,6 +1262,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_file_open_can_atomicwrite(inode, file)) + file->f_mode |= FMODE_CAN_ATOMIC_WRITE; return generic_file_open(inode, file); }