Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp12533897pxu; Sat, 2 Jan 2021 02:20:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzT3/Om1v55L3HmCE2QKy7/gy6ApZ/dRefoCBZPTIT3f9l1UUAKHXGcCLpCpTIys/hQfBrB X-Received: by 2002:a05:6402:a52:: with SMTP id bt18mr63384837edb.228.1609582837228; Sat, 02 Jan 2021 02:20:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1609582837; cv=pass; d=google.com; s=arc-20160816; b=XzgqzebNHQp2qhPUQTmTjYoF5KrxYd2TGFv0n0wYh8g0QBH5aiqzptnDOW2dpsfZCD UMg+xtS6fD/uOxrPSw9y8hQQtAp/2hNJTZ01VKO8dgwxhSGXZZ+54O/DAWSF5/vOjxjA 1SBtgbaIpCxJVs92yBPLXdkRE/RzH7FezKdt8mWjAotj1wfS43N4M7JLt6LjAY8fqjic 5Am22rpElxw1fpV0wpT4381Xk3UzZONqRjHicr+MuBfR3aDY0mNjtLWr/vRx9Ki0zb1h Qyj4mDLgpvJC88pRBduCHh7F13yAPa6ZwKPjDCsZy9i58DsbzrihcGN7J48niJCCQNBb 4vNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=vBQ8Ol2bVfFyBZ+Z7YjllAF9Pv7KoufdmTTzSUVOt78=; b=j02293Y6KwI8Q7nelCNfLZFg4XqWrwEGrqyNyc+8YjS5/KkbjIk4ROudhPNgkj+UzL FFE59nAs+KOU9lulZ+tV47yXfWA9XwT/9f93CKlkcL9ls6qPjhDIMhqEzSuK6hXHT0q1 tqymbisiZ1HkjSb4sZJGFNx+iZOBMqjPIeoQtJaNTgZtO/yEtw3lqu767t01Moklu5i6 +Z2CwEizsxkBMXnTRG+a1r5Q6Y9cdGFr/C2uyOAoRa6TS+FgrOjjEv6xhwJEtXp/12Xi AS18bjAau0xBYulirFC+oxvSpL2qeHQWOOi+Ss4wKxEe0/FmlJL07wmf+kn8ZgLmQsqs 7pVQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=Pu50XBEL; 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 e22si31671670edu.45.2021.01.02.02.20.07; Sat, 02 Jan 2021 02:20:37 -0800 (PST) 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=Pu50XBEL; 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 S1726486AbhABKT2 (ORCPT + 99 others); Sat, 2 Jan 2021 05:19:28 -0500 Received: from sender2-pp-o92.zoho.com.cn ([163.53.93.251]:25364 "EHLO sender2-pp-o92.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726327AbhABKT1 (ORCPT ); Sat, 2 Jan 2021 05:19:27 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1609582723; cv=none; d=zoho.com.cn; s=zohoarc; b=Ha0ZKwGH6eJCa7nwcZ627WsOVwbqO2z7P1oFjRypBjwDEkspq52h3aBvHUOdTGi6fDWgb63YdZU5ZVBu44wXbl/IasKtbgGXfDWw6dN7pU7wdAIW/L8NbxuvoIbdLI73volldcpo0LmX/eYAcUd6dQ+g1lIJyz3T27MvBWe4TxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1609582723; h=Cc:Date:From:Message-ID:Subject:To; bh=vBQ8Ol2bVfFyBZ+Z7YjllAF9Pv7KoufdmTTzSUVOt78=; b=hQJBXZWTJTP24EVV1lQ3Ynp8sKXF3XY/WBoQyKrfaAx7AIfG6BkbWUqFtR4m5IdGJtbEvcC+8Da3asy/dJMvF2iIqbx6CbzeOk/LOW/j4jcO0hNnMW1xHRsEqYHyBhlg8O7yKvNa8BbC5Xg9UqmRiItxTaTbU7MQkepY6n1Kusg= 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=1609582723; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Subject:Date:Message-Id; bh=vBQ8Ol2bVfFyBZ+Z7YjllAF9Pv7KoufdmTTzSUVOt78=; b=Pu50XBELpzY1AIqmhTF+OFgVJJhbq9DQBoRG53cv4kcjPtuadGHYimC6FQOLpcul a94/woOO5KOBuC74oeJj/G9xEz0VNKWu3pAP6nsvA8uAMsrucR68hJ2XBrZEFuTaj35 tbKJOYrDaK61Byv/piF99JDJ9TRtzPrnQSvaYIQI= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 1609582721210914.4696080792448; Sat, 2 Jan 2021 18:18:41 +0800 (CST) From: Chengguang Xu To: jack@suse.com Cc: linux-ext4@vger.kernel.org, Chengguang Xu Subject: [PATCH] ext2: discard block reservation on last writable file release Date: Sat, 2 Jan 2021 18:18:05 +0800 Message-Id: <20210102101805.355106-1-cgxu519@mykernel.net> X-Mailer: git-send-email 2.18.4 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Currently reserved blocks are discarded on every writable file release, it's not efficient for multiple writer case. 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 96044f5dbc0e..9a19d8fe7ffd 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -141,7 +141,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.18.4