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=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham 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 E569FC2BA83 for ; Fri, 14 Feb 2020 15:11:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCE9224650 for ; Fri, 14 Feb 2020 15:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729338AbgBNPLh (ORCPT ); Fri, 14 Feb 2020 10:11:37 -0500 Received: from mx2.suse.de ([195.135.220.15]:51764 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727822AbgBNPLh (ORCPT ); Fri, 14 Feb 2020 10:11:37 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 945B2AE2C; Fri, 14 Feb 2020 15:11:34 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id D3C961E0B38; Fri, 14 Feb 2020 16:11:33 +0100 (CET) Date: Fri, 14 Feb 2020 16:11:33 +0100 From: Jan Kara To: Andreas Gruenbacher Cc: Alexander Viro , David Sterba , Jeff Layton , Theodore Ts'o , Chao Yu , Richard Weinberger , linux-fsdevel@vger.kernel.org, Jan Kara Subject: Re: [PATCH 1/7] fs: Un-inline page_mkwrite_check_truncate Message-ID: <20200214151133.GB22815@quack2.suse.cz> References: <20200213202423.23455-1-agruenba@redhat.com> <20200213202423.23455-2-agruenba@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200213202423.23455-2-agruenba@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Thu 13-02-20 21:24:17, Andreas Gruenbacher wrote: > Per review comments from Jan and Ted, un-inline page_mkwrite_check_truncate > and move it to mm/filemap.c. This function doesn't seem worth inlining. > > Signed-off-by: Andreas Gruenbacher > Cc: Jan Kara > Cc: Theodore Y. Ts'o Looks good to me. You can add: Reviewed-by: Jan Kara Honza > > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h > index ccb14b6a16b5..6c9c5b88924d 100644 > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -636,32 +636,6 @@ static inline unsigned long dir_pages(struct inode *inode) > PAGE_SHIFT; > } > > -/** > - * page_mkwrite_check_truncate - check if page was truncated > - * @page: the page to check > - * @inode: the inode to check the page against > - * > - * Returns the number of bytes in the page up to EOF, > - * or -EFAULT if the page was truncated. > - */ > -static inline int page_mkwrite_check_truncate(struct page *page, > - struct inode *inode) > -{ > - loff_t size = i_size_read(inode); > - pgoff_t index = size >> PAGE_SHIFT; > - int offset = offset_in_page(size); > - > - if (page->mapping != inode->i_mapping) > - return -EFAULT; > - > - /* page is wholly inside EOF */ > - if (page->index < index) > - return PAGE_SIZE; > - /* page is wholly past EOF */ > - if (page->index > index || !offset) > - return -EFAULT; > - /* page is partially inside EOF */ > - return offset; > -} > +int page_mkwrite_check_truncate(struct page *page, struct inode *inode); > > #endif /* _LINUX_PAGEMAP_H */ > diff --git a/mm/filemap.c b/mm/filemap.c > index 1784478270e1..edcb4a8a6121 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -2678,6 +2678,34 @@ const struct vm_operations_struct generic_file_vm_ops = { > .page_mkwrite = filemap_page_mkwrite, > }; > > +/** > + * page_mkwrite_check_truncate - check if page was truncated > + * @page: the page to check > + * @inode: the inode to check the page against > + * > + * Returns the number of bytes in the page up to EOF, > + * or -EFAULT if the page was truncated. > + */ > +int page_mkwrite_check_truncate(struct page *page, struct inode *inode) > +{ > + loff_t size = i_size_read(inode); > + pgoff_t index = size >> PAGE_SHIFT; > + int offset = offset_in_page(size); > + > + if (page->mapping != inode->i_mapping) > + return -EFAULT; > + > + /* page is wholly inside EOF */ > + if (page->index < index) > + return PAGE_SIZE; > + /* page is wholly past EOF */ > + if (page->index > index || !offset) > + return -EFAULT; > + /* page is partially inside EOF */ > + return offset; > +} > +EXPORT_SYMBOL(page_mkwrite_check_truncate); > + > /* This is used for a general mmap of a disk file */ > > int generic_file_mmap(struct file * file, struct vm_area_struct * vma) > -- > 2.24.1 > -- Jan Kara SUSE Labs, CR