Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751902AbdLNCa0 (ORCPT ); Wed, 13 Dec 2017 21:30:26 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38962 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbdLNCaY (ORCPT ); Wed, 13 Dec 2017 21:30:24 -0500 Date: Wed, 13 Dec 2017 18:30:22 -0800 From: Andrew Morton To: "Yan, Zheng" Cc: LKML , linux-fsdevel , ceph-devel@vger.kernel.org, linux-ext4@vger.kernel.org, viro@zeniv.linux.org.uk, jlayton@redhat.com, linux-mm@kvack.org Subject: Re: [PATCH] mm: save current->journal_info before calling fault/page_mkwrite Message-Id: <20171213183022.adce31de7c5e704b4315e472@linux-foundation.org> In-Reply-To: <91E1F854-7CE7-4E98-BA87-7E4E55243109@redhat.com> References: <20171213035836.916-1-zyan@redhat.com> <20171213165923.0ea4eb3e996b7d8bf1fff72f@linux-foundation.org> <91E1F854-7CE7-4E98-BA87-7E4E55243109@redhat.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1686 Lines: 36 On Thu, 14 Dec 2017 10:20:18 +0800 "Yan, Zheng" wrote: > >> + /* > >> + * If the fault happens during write_iter() copies data from > >> + * userspace, filesystem may have set current->journal_info. > >> + * If the userspace memory is mapped to a file on another > >> + * filesystem, fault handler of the later filesystem may want > >> + * to access/modify current->journal_info. > >> + */ > >> + current->journal_info = NULL; > >> ret = vma->vm_ops->fault(vmf); > >> + /* Restore original journal_info */ > >> + current->journal_info = old_journal_info; > >> if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY | > >> VM_FAULT_DONE_COW))) > >> return ret; > > > > Can you explain why you chose these two sites? Rather than, for > > example, way up in handle_mm_fault()? > > I think they are the only two places that code can enter another filesystem hm. Maybe. At this point in time. I'm feeling that doing the save/restore at the highest level is better. It's cheap. > > > > It's hard to believe that a fault handler will alter ->journal_info if > > it is handling a read fault, so perhaps we only need to do this for a > > write fault? Although such an optimization probably isn't worthwhile. > > The whole thing is only about three instructions. > > ceph uses current->journal_info for both read/write operations. I think btrfs also read current->journal_info during read-only operation. (I mentioned this in my previous reply) Quite a lot of filesystems use ->journal_info. Arguably it should be the fs's responsibility to restore the old journal_info value after having used it. But that's a ton of changes :(