From patchwork Mon Feb 26 03:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RnJhbmsgSHNpYW8g6JWt5rOV5a6j?= X-Patchwork-Id: 13571255 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2122.outbound.protection.outlook.com [40.107.215.122]) (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 BBC311B7E1 for ; Mon, 26 Feb 2024 03:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.215.122 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708919158; cv=fail; b=G52R7Vn7aqTe20tTCwtKoYLp0ma+QWUuCWCd6qfXt7CAOwbeIOp6pKlSL5mwIzqc7Vo01jKBX3JNevUn4BI/TX3D7QJ7SLo1qnKWEviverm+IPY67ZWoFM3TS3bFFT7Nor2YsC3RbMsUmFfhlQ7CSG+os14WCNOr1liU9UKWDdM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708919158; c=relaxed/simple; bh=pHijPo7EC4F+31H7gi8jbnyMoAiE51Q8jkyjCr4yinQ=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=ad7WtDM8Ht3J397rfWWw6Jjk0/KwZeORNwC24UoQDkSMtlAHOXABU6V0oXGu3AZ7gT44ROzU5psali12qODTDJfyvy8MVWqoNG+8D0vvaIdblmOkPFVM8LdoGBMvon6ywbuLGDKKkSijQi/0C8iHm0UIq8VvjqjyWzhVNiMjVcU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qnap.com; spf=pass smtp.mailfrom=qnap.com; dkim=pass (2048-bit key) header.d=qnap.com header.i=@qnap.com header.b=D/y1rFtO; arc=fail smtp.client-ip=40.107.215.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qnap.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qnap.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qnap.com header.i=@qnap.com header.b="D/y1rFtO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=me8mSkHNmsisT4yZFnLsNY31A85vYi8dUVh4bMkEHEgms/Z0ywB6vU0psD+L2umedph0HXJvDZKypxkq/R2LbGoWeUSZONYd9qmztJwIQ6b2E3FoVtQWK86pDGrMe12j8KEnYLS0ZAuElLsP9WgnpFVWTBCthtB+DXLIFJumCihqleL1m4QZxLBi1nB2/oJNgFIg60gu4vbDq3Kl1fHiq14LR2SN6e272ZJykDSORyptGCzJzys1y4/6blduQOcbsSYop/CesndPzlMlEGIJoUJTJgED+RWNAkjT8XvTIAja3jCHOs+dYkwtUDqVbFxNBYfbOv8iqJzoKU4WKI9tuA== 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=pHijPo7EC4F+31H7gi8jbnyMoAiE51Q8jkyjCr4yinQ=; b=AuQvI+Rnyd8vWV5jfA+4MxxxckhR3zVfXYISbkkCtGvCA/zrhLb6vQzBBbEozFMRb+sV71Qjw/xDM5MHu3OEDNbrfdXc5QqpZv+AVjc4diENKr5v4A+kFudty7qzB/TniIFRyh06M6GsEoY1kBM8BYFM0/YnMlZtcyRPV8F3QBb/zt4I/UPCehCX5wq7xd0yXSRG4TOUqEXKuPpN5leUb1jMimu/0BXMWPf/pLAZGRUy+kQNNd6ttjrbdOvYQMyEXMMDpmuhfdLOhz8kyYZOTnnrQlUIQwA0/klep3AXBujfeUGm0wGUke3Bct300tZlzlarnvo+WMJWOaaiDgc30w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=qnap.com; dmarc=pass action=none header.from=qnap.com; dkim=pass header.d=qnap.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qnap.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pHijPo7EC4F+31H7gi8jbnyMoAiE51Q8jkyjCr4yinQ=; b=D/y1rFtOdgmY5OXRB2uzt2wjsiQE6yp1x2mS5xpaOM2KsKEyGz1VULhnJwAjU53qb3DjroVQ53d6pMqxMW9JSql49gcevsXWY75LJUp4U/69I2PeofdW2lQiYZfXcSZ3E/a/MZD+l6djTKfmN/r18dy3SNPyhhXA+p38DGbJztpL5faWizF1OoaA4Np1vrckEB44OwUT+IPvuK0clBLZhbyzB/7+zXy928AEywjDfQiYbIncb1jcFjoiVE4gMvyHijms5QsQCi9LFkl6flGOD2eMFtqDH1MDGn3if35p8UG63LZmOArWbepOCu22kgH+KqBwW7ZdaQ+DcYMO6DAyRA== Received: from SEZPR04MB6972.apcprd04.prod.outlook.com (2603:1096:101:ef::7) by TYUPR04MB6743.apcprd04.prod.outlook.com (2603:1096:400:352::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.33; Mon, 26 Feb 2024 03:45:51 +0000 Received: from SEZPR04MB6972.apcprd04.prod.outlook.com ([fe80::4aff:c1d:f18b:5e0]) by SEZPR04MB6972.apcprd04.prod.outlook.com ([fe80::4aff:c1d:f18b:5e0%4]) with mapi id 15.20.7316.023; Mon, 26 Feb 2024 03:45:51 +0000 From: =?big5_tw?b?RnJhbmsgSHNpYW8gv72qa6vF?= To: "xiubli@redhat.com" CC: "ceph-devel@vger.kernel.org" Subject: =?big5_tw?b?pl7C0DogW1BBVENIIHYyIDEvMl0gY2VwaDogc2tpcCBjb3B5aW5nIHRo?= =?big5_tw?b?ZSBkYXRhIGV4dGVuZHMgdGhlIGZpbGUgRU9G?= Thread-Topic: [PATCH v2 1/2] ceph: skip copying the data extends the file EOF Thread-Index: AQHaZZIF9yaN96YFq0e2GCNr/Yguw7EcASRQ Date: Mon, 26 Feb 2024 03:45:51 +0000 Message-ID: References: <20240222131900.179717-1-xiubli@redhat.com> <20240222131900.179717-2-xiubli@redhat.com> In-Reply-To: <20240222131900.179717-2-xiubli@redhat.com> Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=qnap.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SEZPR04MB6972:EE_|TYUPR04MB6743:EE_ x-ms-office365-filtering-correlation-id: de651a5d-b1f7-48f5-f489-08dc367d6d44 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: CwoAuUckDRb548XMiGT1b5KZeyhxJUZ6htySW8K1wveEJVSot+7RPkauefqsc3QObewlJmbot0uYhRh9S9Vwt5IYIllSTqyX2Zcu5T+goJJ3bEyGrLhqm/lkbXt1LfUygIRoTPep8U+DrhTXL3BnbFJN5SPydl1XwvUO8GLQUUQ2qJjOyBrcJUtIbKSYckKwZ8Xa16UYIl7ZSBu5I7rqdpgONonk/Uuh7svkrPMDd4BRwQcivZk/kBM4KmkopCEsPLurpduCCZueTtBL6mSIMsh0Rr3L4RipaDUordWtrcF63x0GuANGPrWAcqwN4T3QVk/LAU6jKw+I8vGjG0TH3/n9Ni1hzDjmDEu4e7/q9DwjZI5fXT9OnLa3klanlDLqH0KoSwIXwQVzbT1z/qU42wpJPAJat0uPcqYsfZjcQWNF9ALSZYqQr3GTP7jhk4lMMs3qnT9cSKglKB+mEQA+V9Y7NQyn0tO/1KghWSg09BUyCEHNqqMu+GcDRdIyU5g0qFckOPN10vz6fnbXxrUCfKyvtGe4AynQiuYoeMvbaDsTbnGQ9QlGyAYlH/2RvkO+rp2vz4+BZvD8vKzTmOOAeUvYg+5LQNwutVPdxUBH2dyj5TDjbSvYl9ZduJMUAWHR66mhZEMWNQGNpfa9eO/+cYOMpyj0LoJI8c0DNAkHYRAlkdoBCQiKXZ3sqWZNfwE5 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-tw;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR04MB6972.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(38070700009);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?big5_tw?b?c0pNeXdBL0pKSEdXTkZQSUwwRkRV?= =?big5_tw?b?REg0TDhxQ0N5YlVqZlJ5eTVNOG1PdThXZVl3NnpQaFcvRitja2w5UGhVcDEzRWRV?= =?big5_tw?b?dVRQYm9YUnE3ZkNKMkxPaTV3VCtieHVWa2xrUUdrTUt6aFVyTm1HVEpEUjg0Z2lQ?= =?big5_tw?b?UHNwWVBlWWNXR05kVkNRTVM1RWFobEFqdWtMRSszYm9QQ1BjdmplWVYwUnViSFpP?= =?big5_tw?b?K2FacWk1T3ZDQTMxbElBVWFZMWpFcmxMUnVBaGg1SzVYa3ZsNXloblJ2cWVuczR4?= =?big5_tw?b?NHp4aHlWYWR4MkpqNkg2WG1PK1l6OFJwRjJqQnprNTZoNklWSVFUTE13YjJDN1p3?= =?big5_tw?b?T3JuS2EyRSs4cnBPa2xvaTAxdUdjRHQxcFdvQzE4Y3hJdWlvZ3VybXhBVXZZVmF6?= =?big5_tw?b?cHlWQmJBeHVMMVBuSnBBTVZGSXhFa0I5SC9oRE5reUxreHIvenJEdlNLY081WlBO?= =?big5_tw?b?czJVWXZpdER0dGVzVXhPVHAvTDJoVjlFa1VKRDJHZmdFWjY2dWpnSHBV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JHUDV6VnBpeUM0bDBPY1JLdEJTeCtZ?= =?big5_tw?b?Q2lmdE95eDhZd2g2YVVqWVRaaVRpc1lpL01SaXBTV3lnRkM5U3JLR291UkpLbTFI?= =?big5_tw?b?Um50Mkt1eTdvTzNKOVZSNmNDVEtnRWZGdDJ1dFpReUY0U2IxcEQ2dXM5MUdoaXI2?= =?big5_tw?b?RHdFbmM1dzA4UlFFd0tZNGFIR1JIV2NIbUtwZ1BSMU91cHU0TU5Id2QzZUZ6MStq?= =?big5_tw?b?aE5tQWEyWlIzTWJ2bC9XUk5XTG12dGNkbVE4OVBVaU5KbDg1by9YTDlYV0srUjhm?= =?big5_tw?b?Rkc5WTl2dnc0em5tS0xBNGJGMkVQMTZVQU9hNnBscEZoYmNPKzdFNHd3S3FpMkxi?= =?big5_tw?b?NUJNbmEyL1ZUTS93VVhKWjZ2UFpXWlJpU0RoUndJaElrdUo5LzZaY0IwL2NUTUJw?= =?big5_tw?b?NFZPUExUZnNBQU1VZC83dWR6b1g2ckRpSHpUVi9KWjV4cVFLWU1hNnhEdWNhcFhJ?= =?big5_tw?b?M01qbkdlSGhFZVZOVm9WZFNZU2dJSThvZThZaE5aR1BHS1hjVjNlYkZvbmhXUGJS?= =?big5_tw?b?Y1ExWG1mS2ZsTnB6UHFzcEZMTXVwbXJsa0w5T1VrMmJWb3hiVGo5d3FPclRLK2Vx?= =?big5_tw?b?ZmVmV3oxOUJuNk50d2pKeG8rZnlLQUEydHcrMXFEclJialRvZnRqejV3QnJVdlEx?= =?big5_tw?b?azVzSmdiVTMvOU1VOGhvRG9SeWZxOD0=?= Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: qnap.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SEZPR04MB6972.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: de651a5d-b1f7-48f5-f489-08dc367d6d44 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Feb 2024 03:45:51.1589 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6eba8807-6ef0-4e31-890c-a6ecfbb98568 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bC+K6NAArT4qE/ZkA6dG656Fcaz9jrQyCI70tK9PDF4jdXF6Y3Nfom7NZJKrwfVtydCmJRHalnnJgy1uIQXvIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYUPR04MB6743 Tested-by: Frank Hsiao 蕭法宣 diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 71d29571712d..2b2b07a0a61b 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1195,7 +1195,7 @@ ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos, } idx = 0; - left = ret > 0 ? ret : 0; + left = ret > 0 ? umin(ret, i_size) : 0; while (left > 0) { size_t plen, copied; @@ -1224,15 +1224,13 @@ ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos, } if (ret > 0) { - if (off > *ki_pos) { - if (off >= i_size) { - *retry_op = CHECK_EOF; - ret = i_size - *ki_pos; - *ki_pos = i_size; - } else { - ret = off - *ki_pos; - *ki_pos = off; - } + if (off >= i_size) { + *retry_op = CHECK_EOF; + ret = i_size - *ki_pos; + *ki_pos = i_size; + } else { + ret = off - *ki_pos; + *ki_pos = off; } if (last_objver)