From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FC93C433B4 for ; Tue, 13 Apr 2021 13:56:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AD5C61249 for ; Tue, 13 Apr 2021 13:56:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231688AbhDMN4x (ORCPT ); Tue, 13 Apr 2021 09:56:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:47524 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbhDMN4x (ORCPT ); Tue, 13 Apr 2021 09:56:53 -0400 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 7BA89AFC4; Tue, 13 Apr 2021 13:56:32 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 471041E37A2; Tue, 13 Apr 2021 15:56:32 +0200 (CEST) Date: Tue, 13 Apr 2021 15:56:32 +0200 From: Jan Kara To: Christoph Hellwig Cc: Jan Kara , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, Ted Tso , Amir Goldstein , Dave Chinner Subject: Re: [PATCH 2/7] mm: Protect operations adding pages to page cache with i_mapping_lock Message-ID: <20210413135632.GD15752@quack2.suse.cz> References: <20210413105205.3093-1-jack@suse.cz> <20210413112859.32249-2-jack@suse.cz> <20210413125746.GB1366579@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210413125746.GB1366579@infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue 13-04-21 13:57:46, Christoph Hellwig wrote: > > if (error == AOP_TRUNCATED_PAGE) > > put_page(page); > > + up_read(&mapping->host->i_mapping_sem); > > return error; > > Please add an unlock_mapping label above this up_read and consolidate > most of the other unlocks by jumping there (put_and_wait_on_page_locked > probablt can't use it). Yeah, I've actually simplified the labels even a bit more like: ... error = filemap_read_page(iocb->ki_filp, mapping, page); goto unlock_mapping; unlock: unlock_page(page); unlock_mapping: up_read(&mapping->host->i_mapping_sem); if (error == AOP_TRUNCATED_PAGE) put_page(page); return error; and everything now jumps to either unlock or unlock_mapping (except for put_and_wait_on_page_locked() case). > > truncated: > > unlock_page(page); > > @@ -2309,6 +2324,7 @@ static int filemap_update_page(struct kiocb *iocb, > > return AOP_TRUNCATED_PAGE; > > The trunated case actually seems to miss the unlock. > > Similarly I think filemap_fault would benefit from a common > unlock path. Right, thanks for catching that! Honza -- Jan Kara SUSE Labs, CR