Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2376304ybt; Sun, 21 Jun 2020 18:26:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF3MtQOk6c6yt1NridNtoFiIjX/+aavjzCFmM5zPyOqvmmGNfqX4yDXUJkBKqNLy1ne77x X-Received: by 2002:a17:907:216c:: with SMTP id rl12mr14446647ejb.156.1592789217613; Sun, 21 Jun 2020 18:26:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1592789217; cv=pass; d=google.com; s=arc-20160816; b=GeTfAKMMbwYKNl/3CyoriioXgo3x4m2aKBzc7gBRtcVP2KNZ9p89nj7Qx7j83wzIwI /MPD7Eh05dNw7WjJdXGWgHksEgZialUJs+sGpxvTWuefbIRs2tPtxm0vruwe1k2f3lw0 c9Vxtln/HESLW0wPtfAFwHSp577gJgUSFIY1HaXcbNSEdq2aeuBsXxt6AgII2nlzu2m4 Qga29kTC1tslEG3GXoQOM7kOYScJe7Ygrq8Y0w6kdjjyVUc++WbAn51I6PzWLPsheRuG SBaFd9U3PT1uvCtQMzp/7M5PO2dVFIKqdabMybd5ci6AaXYG/g2CdC5kAv5v0ggOkpOX K5+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=b43/ZsLyB1cGwYIJQZDZaDv/9N8+3bn4PgmRq2R7HeA=; b=upV/OBBEUOhx8gSlgZ6TMYs2Ay//zsIq4fUX8uiUVgAEoYgeFjJvZMPkfXZBTGq8jE jB/E7GUuwriSS4012oax94SEMyG9eSnNa0zAYReJWTW9q9BQGRHKWyLSkLobeyVD6Lsu y3HnqQAtsA23QRXp51EFF+cvYtcEoxBZ2Lax3bk1C7Oz+j4531EFibY9WOIVWqkxFd7k SmJSk+Cl/yEnhZ8N5Rdz5myTUvX6e8NauV2W3u4b9EyjxPcVoNkyBp6TvohFvcgtxc9q nwhrMf+U/3WYWIwGSy8goeCN5yifUeutym9PM4tNpFXMaDpnvYW4FDT9rYcpTRAcTVmz BXjA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=Es1T5Ito; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si7866399edk.69.2020.06.21.18.26.22; Sun, 21 Jun 2020 18:26:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=Es1T5Ito; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726529AbgFVBZt (ORCPT + 99 others); Sun, 21 Jun 2020 21:25:49 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17134 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726603AbgFVBZt (ORCPT ); Sun, 21 Jun 2020 21:25:49 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1592789142; cv=none; d=zoho.com.cn; s=zohoarc; b=nAgALmoUAJXr/CoFtaujNpAHMNvhaptM2+TPW0E79cRP6vyWilUu992sWWoB2Z+L1tLTSaBzzXPngheeN5jZt5zmV3zvL9n/RC5zhsrcRUlSf7av6fbJwcosbRmzzmkAP7MlEc0UE2YVTNPKnqmJ4exXWv+iZA/w7uPVjhDB7yU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1592789142; h=Cc:Date:From:Message-ID:Subject:To; bh=b43/ZsLyB1cGwYIJQZDZaDv/9N8+3bn4PgmRq2R7HeA=; b=W8nAjn01yV3HGqtADQnFJVaFPXkpsspZAdIMfdIb6sPn1hu1F8rIruS4/XN0DwSyZr8oQd2jBTeYSP7JK1lkHSBx28XX83cr3Y9SToy8U9OkLF09H6Y0Nnwl3WWms+2LAXjxEXRC3L2ax6kV0BLCn2OjjtTQqjTdZOSUDStNXWc= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1592789142; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Subject:Date:Message-Id; bh=b43/ZsLyB1cGwYIJQZDZaDv/9N8+3bn4PgmRq2R7HeA=; b=Es1T5ItoHbgrcj9Ya3Qi3PprGY7Y0IVbM5ErX2Pfk66Wo7fDwNA28ymYgs4GI+Gp m6joG0Ldl+p0fVFejOKP7zfc6zTDm6u0YFzRrwFMAkXWhJFDd42iJZvT55hFCBCfLu0 ziIsqzCFNBGQMj89KZgmRJsEdRZrbilSsRUKybWU= Received: from localhost.localdomain (113.87.88.87 [113.87.88.87]) by mx.zoho.com.cn with SMTPS id 1592789140551601.152588810136; Mon, 22 Jun 2020 09:25:40 +0800 (CST) From: Chengguang Xu To: jack@suse.com Cc: linux-ext4@vger.kernel.org, Chengguang Xu Subject: [PATCH] ext2: delay discarding block reservation Date: Mon, 22 Jun 2020 09:25:26 +0800 Message-Id: <20200622012526.4688-1-cgxu519@mykernel.net> X-Mailer: git-send-email 2.17.2 X-ZohoCNMailClient: External Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Currently block reservation will be discard when a write mode file structure is released. It is not efficent for concurrent writing, so change to discard block reservation when last writer release file structure. Signed-off-by: Chengguang Xu --- fs/ext2/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 60378ddf1424..28eaf429138b 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -139,7 +139,7 @@ static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) */ static int ext2_release_file (struct inode * inode, struct file * filp) { - if (filp->f_mode & FMODE_WRITE) { + if ((filp->f_mode & FMODE_WRITE) && (atomic_read(&inode->i_writecount) == 1)) { mutex_lock(&EXT2_I(inode)->truncate_mutex); ext2_discard_reservation(inode); mutex_unlock(&EXT2_I(inode)->truncate_mutex); -- 2.17.2