Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1910986yba; Mon, 15 Apr 2019 00:33:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlt8JHSNtKWLEcVAQt0SA1nYGN1KBrnR3kvTYWiu+JASX1pVml9U/SnInv7A8datT8MJS4 X-Received: by 2002:a17:902:1e2:: with SMTP id b89mr74429300plb.278.1555313610430; Mon, 15 Apr 2019 00:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555313610; cv=none; d=google.com; s=arc-20160816; b=bxoI7RDI5YFs6SW8bqdvV9AmV/EpUqWFdOMJ9ikXImqVJX2le65W9yMK2SE+P5Cgty oh//hWMO5XCNQRLwxu0rGWSPf5Q9i4WcgVTSmU1mOvwL2euSBAQ7xN6mp1uLtyUD5JjA fePYPrBalfGMn/y5aYF1mkvkfeMiAKE+B1PqrCO4fex4n1MR+OtviSAebS5wab5qtBXJ KV1pE9mol40MLOFuxvuYwAndsOD5TWybx8iGehotDUhqMY/cpJOO+rVx1P2BBjzBk7FR CH49QR9a5sBiC4FNFgHACoY0OBG5MvCLgb+MIfz46wXRWyfMmlJAxx9hlvihaJy9QI0y CLcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=YcVOH6LsgEo0qnB9SeydowXUocMUhRR+qhGxAfY+fu0=; b=A2tCnuft6harKXSSrY8JmxtOiLDvXQOSVR465R77qDgdFznP/M7llcJLqIdaXR8+66 tWt8rRnPXL45BOHNCKL0k3kF4hweEwRuuCzbkWyYX0FGklcwrD6W883+zX5+s7zzu7YF D4s24R0b1Ee7YqzSP2mnMHnez1Ec77EaZkOQQXu2+UwTVmo9R4oCKyHjWwwuY/6BdSTI xZMXttHUR7QfP8DBlax+fWWOP014T6EkcNKHVgj2WzOteUFrbR3+dD8gzUyuXIDQlUzy AibXuGlOiVh62CYPYGlJuYQ599dd3aByKG7Zx3H3Yk99La3zyXniyHl3ycXy4OEWY7k/ RHzQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si24585418plb.107.2019.04.15.00.33.14; Mon, 15 Apr 2019 00:33:30 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbfDOHbI (ORCPT + 99 others); Mon, 15 Apr 2019 03:31:08 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:45664 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726481AbfDOHbG (ORCPT ); Mon, 15 Apr 2019 03:31:06 -0400 Received: from DGGEMM406-HUB.china.huawei.com (unknown [172.30.72.54]) by Forcepoint Email with ESMTP id 8DBECCE26A4DDC442823; Mon, 15 Apr 2019 15:31:04 +0800 (CST) Received: from dggeme763-chm.china.huawei.com (10.3.19.109) by DGGEMM406-HUB.china.huawei.com (10.3.20.214) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 15 Apr 2019 15:31:04 +0800 Received: from szvp000201624.huawei.com (10.120.216.130) by dggeme763-chm.china.huawei.com (10.3.19.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 15 Apr 2019 15:31:03 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH 13/13] f2fs: don't recovery orphan inode on readonly device Date: Mon, 15 Apr 2019 15:30:54 +0800 Message-ID: <20190415073054.2577-5-yuchao0@huawei.com> X-Mailer: git-send-email 2.18.0.rc1 In-Reply-To: <20190415073054.2577-1-yuchao0@huawei.com> References: <20190415073054.2577-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.120.216.130] X-ClientProxiedBy: dggeme710-chm.china.huawei.com (10.1.199.106) To dggeme763-chm.china.huawei.com (10.3.19.109) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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