Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13840566pxu; Mon, 4 Jan 2021 06:03:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzgoHMNg6EaxBZ1MJ6eQg43qiwx8t8tm22c1eVTG3tvlXQKL1SCFwHf0dHi+HfF64Z+NUCF X-Received: by 2002:a17:906:440e:: with SMTP id x14mr27656380ejo.77.1609769013373; Mon, 04 Jan 2021 06:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609769013; cv=none; d=google.com; s=arc-20160816; b=M1MzjhI2rq2us6DG/+jxYxjzPKuIOxzY4EFqIRrODguYCcT5nHy2Y+yo4m4bF+vNDp g8YEgWjziAHTKwe/+pGJ/maqshrOU8DK7asAtjhen+TwRZtnFsbFvw2DU5wKlpmPk3y/ Wkzapr324pdpQf7IXw7wuWngbr7/iyybcPdwPsZkuSYo+ABV688onqWp1WsTNGn+nEm0 JFwNYwYQsWE1QYZs1AaKNN6B+KBROVlGSKMheJLXv/LJoGBmmuHr9sJva1r7vX/l2PCN dUxlYdRQroV+0IyGJ2GJ3trP/PAZYdLK+hvKkzW+AKDLQ3/ZSuvXkHWCqmNSLEi3CLJo VQrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=gZ5Ts1EdGZQcABw/VrL6P9F6VUWbPHo7t6mLHehXhPI=; b=PssIVIw4BrNrkT0SJb9Repbg5RlaFjEpvKVCJSptr3ByHsPNOIXBT4tsmXVBduSzQc 9cBrVOQo3QrUA0CCWDzuzknCq6nBR+lxJCn9nciu1uzGygAcxbzvtB6DN3J0MsfLq8gc yDYQxiJ6DBZEgOr4fkIo+PgiSI7KlRvrW5tKJdRXZdtIoNq2oV25y/G/mGyiT4/YUySK CVLFTWiLx7smrPcZIcgigai2xfrzg7619Q1gF5Q+e2q2tvLs8VB/PtVMQMHV6Vxjjq2j azElSu0MzTt7VOgeLex67oBk3Xwu825MmzsqOvFFNuc4WtVqbzP/XdWkYNgarG4qJKHw kSMQ== ARC-Authentication-Results: i=1; mx.google.com; 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 dm18si30514320edb.422.2021.01.04.06.03.05; Mon, 04 Jan 2021 06:03:33 -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; 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 S1726640AbhADOCd (ORCPT + 99 others); Mon, 4 Jan 2021 09:02:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:44890 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbhADOCd (ORCPT ); Mon, 4 Jan 2021 09:02:33 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BB05AAF2C; Mon, 4 Jan 2021 14:01:51 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 33B651E07FD; Mon, 4 Jan 2021 15:01:51 +0100 (CET) Date: Mon, 4 Jan 2021 15:01:51 +0100 From: Jan Kara To: Chengguang Xu Cc: jack@suse.com, linux-ext4@vger.kernel.org Subject: Re: [PATCH] ext2: discard block reservation on last writable file release Message-ID: <20210104140151.GD4018@quack2.suse.cz> References: <20210102101805.355106-1-cgxu519@mykernel.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210102101805.355106-1-cgxu519@mykernel.net> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sat 02-01-21 18:18:05, Chengguang Xu wrote: > Currently reserved blocks are discarded on every writable > file release, it's not efficient for multiple writer case. > > Signed-off-by: Chengguang Xu Thanks for the patch. I agree that in principle something like this is desirable but there's a small catch. i_writecount is also elevated from vfs_truncate() which does not have inode open. So it can happen that ->release() gets called, sees inode->i_writecount > 1, but never gets called again (and thus reservation is not properly released). So I prefer to leave ext2 as is until this gets resolved - especially since ext2 fs driver isn't really used on any performance sensitive multi-writer workloads AFAIK (ext4 driver is usually used in such cases). Honza > --- > 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 > -- Jan Kara SUSE Labs, CR