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=-2.0 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 59616C4CECE for ; Tue, 15 Oct 2019 02:22:34 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 082C32089C for ; Tue, 15 Oct 2019 02:22:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dltxS1i1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 082C32089C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46sfMq6dlpzDqv4 for ; Tue, 15 Oct 2019 13:22:31 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::544; helo=mail-pg1-x544.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dltxS1i1"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46sfKj3B2wzDqsD for ; Tue, 15 Oct 2019 13:20:41 +1100 (AEDT) Received: by mail-pg1-x544.google.com with SMTP id p30so11153558pgl.2 for ; Mon, 14 Oct 2019 19:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8H4x/0PzSc+cFgDx1YZ5+BsoHRjAf/XAcn/2vvNKiII=; b=dltxS1i19yhHH709eXXysC7QrJFjh2Ra7frwS53c0XKyRv95OMf9qIQd+7bqlNHGoJ x+DF9gvatAOdsY6Vz414vk54AyAU2eQ0TD5eNQ4hWJYvBwo9Mal8FUWnXkoie8e2JxVb MIkOVxxE9jhdAGZsbUXCIqnloynfoEuSOeWr43Rr2qE4TeaxWVrkYYCcySX5x058AC/C BIdgJnOJ/plwzzw4OBia4mLfcA6oZt+B5FtinPCw5tkXEBb3P8xBVQwmkrEfuvioc5P4 paqo9h8erqF+ZMX5z2IUJpVCEVkmlQFC2VXoZHAP71gIvejmGAE1+SGFpX0i9Hlfd24d RvJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8H4x/0PzSc+cFgDx1YZ5+BsoHRjAf/XAcn/2vvNKiII=; b=kygj1GITON1EI/ly5sBXBXItFt1LyKUenBBW1rEg8S8IdaDYpABNkGjsc4ysufxyiw xqqmvyieNUISjTTecQxIFynI1+KPxBSs3DXIpIPtMWdwgjCZcu0BBONY8MCF7Rzg7sDX QW0CymnayR6xZMDkptnLtWZzAM9HO6PwXs/qxLewS/4MiR1xzOJryKP+w1te/KL+p+Ko wIkkMZJWrkLt92vUoP9NsWgR+suDd2veWjj/6rRAKGK4ho57XBgvFpRpgOQzMk9x7k9Q izj3ZwhXu1NJcoDHtRnQ7BlaDZgEhVoBT1pK84h2sB3e2/cudY9TI5BSdhWthusaujOq 0eew== X-Gm-Message-State: APjAAAW7azmvDQikcjCEPqPZDm0kdINWiN6wwyNjy3oQso5RBbTBtjW0 qGpJ6DT9CRQG2isnxxGBbQ== X-Google-Smtp-Source: APXvYqzOXpShh56uDCVPgANcyM3B+A2AAhIkbDujovTmxMJALaZxxy0iXsrKcX4LEPjKigJevZPUYw== X-Received: by 2002:a17:90a:c094:: with SMTP id o20mr39731453pjs.37.1571106037499; Mon, 14 Oct 2019 19:20:37 -0700 (PDT) Received: from mypc ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id m5sm18914736pgt.15.2019.10.14.19.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 19:20:36 -0700 (PDT) Date: Tue, 15 Oct 2019 10:20:26 +0800 From: Pingfan Liu To: Jan Kara Subject: Re: [PATCH] xfs: introduce "metasync" api to sync metadata to fsblock Message-ID: <20191015022026.GC14327@mypc> References: <1570977420-3944-1-git-send-email-kernelfans@gmail.com> <20191013163417.GQ13108@magnolia> <20191014083315.GA10091@mypc> <20191014094311.GD5939@quack2.suse.cz> <20191014200303.GF5939@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191014200303.GF5939@quack2.suse.cz> User-Agent: Mutt/1.11.3 (2019-02-01) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Sandeen , "Darrick J. Wong" , Jan Kara , Eric Sandeen , linux-xfs@vger.kernel.org, Dave Chinner , linux-fsdevel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Hari Bathini Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon, Oct 14, 2019 at 10:03:03PM +0200, Jan Kara wrote: > On Mon 14-10-19 08:23:39, Eric Sandeen wrote: > > On 10/14/19 4:43 AM, Jan Kara wrote: > > > On Mon 14-10-19 16:33:15, Pingfan Liu wrote: > > > > On Sun, Oct 13, 2019 at 09:34:17AM -0700, Darrick J. Wong wrote: > > > > > On Sun, Oct 13, 2019 at 10:37:00PM +0800, Pingfan Liu wrote: > > > > > > When using fadump (fireware assist dump) mode on powerpc, a mismatch > > > > > > between grub xfs driver and kernel xfs driver has been obsevered. Note: > > > > > > fadump boots up in the following sequence: fireware -> grub reads kernel > > > > > > and initramfs -> kernel boots. > > > > > > > > > > > > The process to reproduce this mismatch: > > > > > > - On powerpc, boot kernel with fadump=on and edit /etc/kdump.conf. > > > > > > - Replacing "path /var/crash" with "path /var/crashnew", then, "kdumpctl > > > > > > restart" to rebuild the initramfs. Detail about the rebuilding looks > > > > > > like: mkdumprd /boot/initramfs-`uname -r`.img.tmp; > > > > > > mv /boot/initramfs-`uname -r`.img.tmp /boot/initramfs-`uname -r`.img > > > > > > sync > > > > > > - "echo c >/proc/sysrq-trigger". > > > > > > > > > > > > The result: > > > > > > The dump image will not be saved under /var/crashnew/* as expected, but > > > > > > still saved under /var/crash. > > > > > > > > > > > > The root cause: > > > > > > As Eric pointed out that on xfs, 'sync' ensures the consistency by writing > > > > > > back metadata to xlog, but not necessary to fsblock. This raises issue if > > > > > > grub can not replay the xlog before accessing the xfs files. Since the > > > > > > above dir entry of initramfs should be saved as inline data with xfs_inode, > > > > > > so xfs_fs_sync_fs() does not guarantee it written to fsblock. > > > > > > > > > > > > umount can be used to write metadata fsblock, but the filesystem can not be > > > > > > umounted if still in use. > > > > > > > > > > > > There are two ways to fix this mismatch, either grub or xfs. It may be > > > > > > easier to do this in xfs side by introducing an interface to flush metadata > > > > > > to fsblock explicitly. > > > > > > > > > > > > With this patch, metadata can be written to fsblock by: > > > > > > # update AIL > > > > > > sync > > > > > > # new introduced interface to flush metadata to fsblock > > > > > > mount -o remount,metasync mountpoint > > > > > > > > > > I think this ought to be an ioctl or some sort of generic call since the > > > > > jbd2 filesystems (ext3, ext4, ocfs2) suffer from the same "$BOOTLOADER > > > > > is too dumb to recover logs but still wants to write to the fs" > > > > > checkpointing problem. > > > > Yes, a syscall sounds more reasonable. > > > > > > > > > > (Or maybe we should just put all that stuff in a vfat filesystem, I > > > > > don't know...) > > > > I think it is unavoidable to involve in each fs' implementation. What > > > > about introducing an interface sync_to_fsblock(struct super_block *sb) in > > > > the struct super_operations, then let each fs manage its own case? > > > > > > Well, we already have a way to achieve what you need: fsfreeze. > > > Traditionally, that is guaranteed to put fs into a "clean" state very much > > > equivalent to the fs being unmounted and that seems to be what the > > > bootloader wants so that it can access the filesystem without worrying > > > about some recovery details. So do you see any problem with replacing > > > 'sync' in your example above with 'fsfreeze /boot && fsfreeze -u /boot'? > > > > > > Honza > > > > The problem with fsfreeze is that if the device you want to quiesce is, say, > > the root fs, freeze isn't really a good option. > > I agree you need to be really careful not to deadlock against yourself in > that case. But this particular use actually has a chance to work. > Yeah, normally there is a /boot partition in system, and if so, fsfreeze can work. > > But the other thing I want to highlight about this approach is that it does not > > solve the root problem: something is trying to read the block device without > > first replaying the log. > > > > A call such as the proposal here is only going to leave consistent metadata at > > the time the call returns; at any time after that, all guarantees are off again, > > so the problem hasn't been solved. > > Oh, absolutely agreed. I was also thinking about this before sending my > reply. Once you unfreeze, the log can start filling with changes and > there's no guarantee that e.g. inode does not move as part of these But just as fsync, we only guarantee the consistency before a sync. If the involved files change again, we need another sync. > changes. But to be fair, replaying the log isn't easy either, even more so > from a bootloader. You cannot write the changes from the log back into the > filesystem as e.g. in case of suspend-to-disk the resumed kernel gets > surprised and corrupts the fs under its hands (been there, tried that). So > you must keep changes only in memory and that's not really easy in the > constrained bootloader environment. Sigh, this is more complicated than I had thought. I guess it will be a long time to go with this bug, and use fsfreeze as a work around. Thanks and regards, Pingfan > > So I guess we are left with hacks that kind of mostly work and fsfreeze is > one of those. If you don't mess with the files after fsfreeze, you're > likely to find what you need even without replaying the log. > > Honza > -- > Jan Kara > SUSE Labs, CR