Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2054901yba; Mon, 15 Apr 2019 04:07:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBUg6N42S4/j4Jl/MTJE9Al2B6KWJEg2ge0r5V/UTCShQCrqszFHRBpvr+gvPsz1V23+So X-Received: by 2002:a62:4ec8:: with SMTP id c191mr73820262pfb.138.1555326445065; Mon, 15 Apr 2019 04:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555326445; cv=none; d=google.com; s=arc-20160816; b=fPPWPdbUrAZyg3qVi57IHYUckF3emKQjqGDq5PzeXbkGDwWsvry4dfKFOw6UYcRLBq TSaKQnL3IvwOEZnWAex/5ietKDh5IeUef5KMHek+KSlHnwPwW58SR/FNiqgVH97zEyOM GqdM7OKrslnc3uoK5PpqN4oA8UmcaJrQwJhIdPKmGDKBUadCKKTIu0E+W0nHnpM1Wtdz g5b0UDKREBpUKM4wFSJ3gWfS9yDbfppE8GWcaEM/tHevp2/9iBniWrKU3EqkJBihAKxW BbBTdaLbtAEIGs2Kct/4JDglYLOC2MOUX3rKO8sPbz68dEp5MK5+w9xo5FoqdxzOKDGX JgZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3TqFcWqXoSiXCLR4PSmxQUw0FwFcqtG3GY86OQIH+YQ=; b=xg4N1LJ4QHvWLPUCX90KvQbAPutMAal7eL6mUlFXFT428F+j8iaDp2PiyRCzYgn6or pF+O41kZONI0KhIb5NZCA7sHGdEii+G8ixfTHVUr4EvZDGDyfCx5KHnYFn8tZ/y4ZjQv LRgyREKCyHAONGC+pkzzFpU0FaeEG6IcC4/Rawk5qFK06Sh69UNnrZ+E+oNSa/qIkhSC 3j9gi5sga7HIWDYTAOOf6OfqocFvQegWzYMun++ZqVktL+SGpkqSbDeYiB6zMZe9PUOl L0Fx0TAFdbMzcbOQQeFZXdQiLdDRexB0obzUFZhcUUjZNaFOCcoK8Af3oNsTHHe1gnWo JY+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V2K5u0+7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h17si47160364pfj.38.2019.04.15.04.07.08; Mon, 15 Apr 2019 04:07:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V2K5u0+7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727352AbfDOLEd (ORCPT + 99 others); Mon, 15 Apr 2019 07:04:33 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:38256 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726556AbfDOLEc (ORCPT ); Mon, 15 Apr 2019 07:04:32 -0400 Received: by mail-qt1-f194.google.com with SMTP id d13so18539347qth.5 for ; Mon, 15 Apr 2019 04:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3TqFcWqXoSiXCLR4PSmxQUw0FwFcqtG3GY86OQIH+YQ=; b=V2K5u0+7fkacnueTk+B2AaQbKEGv18hQGRWA/lVjK1VB/RyQJXR1coHvYvKUxKLr5M PgbdPNgYfKKpSsuy/+Euqex/DdbNifK6Zj5zbhf7/Q/xI7k2OBLD6cff64Ea3YCMk6a5 qyeyiTTwVSWWqbOXXzEbI2Royk7rCw/jtSPA4gcX2DMSu7MdM+gvCD0qBNLutxxBRt96 4P4esrEw0nsVI8u++UYGbyu6FJ9KB/823UBuOgIeHYbJYPsAiUAvzCLNxCAHu7mjo4yQ RrWzos9ChhVNY/Mpjq5SBiJWNVZJt8WCaeoghI3JezyWT32NMq8QEQpGXZlnOqYEujpE 9puA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3TqFcWqXoSiXCLR4PSmxQUw0FwFcqtG3GY86OQIH+YQ=; b=tBrZLwcRSwNhTD+K8CumPvznbycprTNh89owbbMm216i5vODrj+5cwgz5QEvmPSJ3y 3xTvo2NCpmTCfzR4cHJGm8afW6VhoTCTY+T3qQF+7LuIRqH1QHvBMr97hNDwaiZ1aDu7 TxV6aArYyN9pnqSMXtnPRd9lMdM4bsoq4JwL2TErSEox595ZbJXkSo0MgGA941Da8xSX EXkziS0IjrbNIOAbGJISLnN9/cEygspb0mAetLa9eiksbS7VmQWmHyWcTEa5Mb47VVi0 d1jMhDHS4xKTzX5kq7EBZDzVkmbonrqsSsVNgRX8FGl7eiiUhSOztkZGChEMWoO95djQ oWbA== X-Gm-Message-State: APjAAAUy0/uD5LVfzEumtTnzaEl987kjx73rmGSyCQrFLbv2LTjz+Q9X iwLpS1OHZZiMR8Gm8zzhtmAxbxayg835cVeaFQU= X-Received: by 2002:a0c:d4a2:: with SMTP id u31mr60943733qvh.139.1555326270326; Mon, 15 Apr 2019 04:04:30 -0700 (PDT) MIME-Version: 1.0 References: <20190415073054.2577-1-yuchao0@huawei.com> <20190415073054.2577-5-yuchao0@huawei.com> In-Reply-To: From: Ju Hyung Park Date: Mon, 15 Apr 2019 20:04:19 +0900 Message-ID: Subject: Re: [f2fs-dev] [PATCH 13/13] f2fs: don't recovery orphan inode on readonly device To: Chao Yu Cc: Jaegeuk Kim , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the explanation. And yes, this patch fixed it, the kernel log is now clean. Thanks! [ 22.506553] F2FS-fs (loop0): write access unavailable, skipping orphan cleanup [ 22.506555] F2FS-fs (loop0): recover fsync data on readonly fs [ 22.506556] F2FS-fs (loop0): quota file may be corrupted, skip loading it [ 22.507015] F2FS-fs (loop0): Mounted with checkpoint version = 26e7ba3e On Mon, Apr 15, 2019 at 5:57 PM Chao Yu wrote: > > On 2019/4/15 16:10, Ju Hyung Park wrote: > > Hi, > > > > Thanks for the fix. I'll try this sooner than later. > > > > One minor request though, can you change > > "JuHyung Park " > > to > > "Park Ju Hyung "? > > > > That's my preference and I'd like to avoid any inconsistencies. > > Sure, will update it in next version. :) > > > > > One additional question from reviewing the code surrounding it: > > does it really makes sense to cleanup orphan inodes even when the "ro" > > mount option is passed? > > It's an explicit request from the user not to write to the block device/image. > > Now, f2fs follows the rule that ext4 kept, you can check codes in > ext4_orphan_cleanup() > > if (bdev_read_only(sb->s_bdev)) { > ext4_msg(sb, KERN_ERR, "write access " > "unavailable, skipping orphan cleanup"); > return; > } > ... > if (s_flags & SB_RDONLY) { > ext4_msg(sb, KERN_INFO, "orphan cleanup on readonly fs"); > sb->s_flags &= ~SB_RDONLY; > } > > There are two points in above codes: > - if block device is readonly, filesystem should not execute any recovery flow > which can trigger write IO. > - if filesystem was mounted as readonly one, and recovery is needed, it will > ignore readonly flag and update data in device for journal recovery during mount. > > So IMO, readonly mountoption sematics is only try to restrict data/meta update > behavior that is triggered by user from mountpoint, but filesystem still can do > any updates on a writable device if it needs, mostly like recovery flow. > > Anyway, if you want to limit any updates on block device, making it readonly > will be a good choice. :) > > Thanks, > > > > > Thanks. > > > > On Mon, Apr 15, 2019 at 4:31 PM Chao Yu wrote: > >> > >> As JuHyung Park reported in mailing list: > >> > >> https://sourceforge.net/p/linux-f2fs/mailman/message/36639787/ > >> > >> generic_make_request: Trying to write to read-only block-device loop0 (partno 0) > >> WARNING: CPU: 0 PID: 23437 at block/blk-core.c:2174 generic_make_request_checks+0x594/0x630 > >> > >> generic_make_request+0x46/0x3d0 > >> submit_bio+0x30/0x110 > >> __submit_merged_bio+0x68/0x390 > >> f2fs_submit_page_write+0x1bb/0x7f0 > >> f2fs_do_write_meta_page+0x7f/0x160 > >> __f2fs_write_meta_page+0x70/0x140 > >> f2fs_sync_meta_pages+0x140/0x250 > >> f2fs_write_checkpoint+0x5c5/0x17b0 > >> f2fs_sync_fs+0x9c/0x110 > >> sync_filesystem+0x66/0x80 > >> f2fs_recover_fsync_data+0x790/0xa30 > >> f2fs_fill_super+0xe4e/0x1980 > >> mount_bdev+0x518/0x610 > >> mount_fs+0x34/0x13f > >> vfs_kern_mount.part.11+0x4f/0x120 > >> do_mount+0x2d1/0xe40 > >> __x64_sys_mount+0xbf/0xe0 > >> do_syscall_64+0x4a/0xf0 > >> entry_SYSCALL_64_after_hwframe+0x44/0xa9 > >> > >> print_req_error: I/O error, dev loop0, sector 4096 > >> > >> If block device is readonly, we should never trigger write IO from > >> filesystem layer, but previously, orphan recovery didn't consider > >> such condition, result in triggering above warning, fix it. > >> > >> Reported-by: JuHyung Park > >> Signed-off-by: Chao Yu > >> --- > >> fs/f2fs/checkpoint.c | 6 ++++++ > >> 1 file changed, 6 insertions(+) > >> > >> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c > >> index a7ad1b1e5750..90e1bab86269 100644 > >> --- a/fs/f2fs/checkpoint.c > >> +++ b/fs/f2fs/checkpoint.c > >> @@ -674,6 +674,12 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi) > >> if (!is_set_ckpt_flags(sbi, CP_ORPHAN_PRESENT_FLAG)) > >> return 0; > >> > >> + if (bdev_read_only(sbi->sb->s_bdev)) { > >> + f2fs_msg(sbi->sb, KERN_INFO, "write access " > >> + "unavailable, skipping orphan cleanup"); > >> + return 0; > >> + } > >> + > >> if (s_flags & SB_RDONLY) { > >> f2fs_msg(sbi->sb, KERN_INFO, "orphan cleanup on readonly fs"); > >> sbi->sb->s_flags &= ~SB_RDONLY; > >> -- > >> 2.18.0.rc1 > >> > >> > >> > >> _______________________________________________ > >> Linux-f2fs-devel mailing list > >> Linux-f2fs-devel@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > > . > >