From patchwork Sun Nov 3 17:06:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 3133671 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4803FBEEB2 for ; Sun, 3 Nov 2013 17:07:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 66E362031C for ; Sun, 3 Nov 2013 17:07:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 331C620278 for ; Sun, 3 Nov 2013 17:07:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752790Ab3KCRHW (ORCPT ); Sun, 3 Nov 2013 12:07:22 -0500 Received: from mail-ea0-f174.google.com ([209.85.215.174]:59721 "EHLO mail-ea0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752149Ab3KCRHT (ORCPT ); Sun, 3 Nov 2013 12:07:19 -0500 Received: by mail-ea0-f174.google.com with SMTP id z15so2955860ead.19 for ; Sun, 03 Nov 2013 09:07:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AbK6OTVR4KCk5HSqyMF2wOrHUT4lmv7v9/WolM/7vxI=; b=Qo+gseK079Puohm/3T0QqlLUq9wUPQg28+36w+NxlAeMvFPq+ml1/YLMIBkpwow2g/ gv5k2bvnYJ7aPAnUMCkiPsRsxXsQRKonVLFBoJVH0ox6liS8mHrWMfHu1EKcJuwIuC2q 7+/6ihVBqumni0A5LypikhyHoI0l5WHK6Rqvi31B8pAHCYGasduVF/uDUxw5aM3slkSm q97mvTGv3nyKTBWF/AaAU0Pj8k/YQufRpcnDzM+uuFomjatKPyoeBW7HeyzbcC1rWSXr D/+eGVQrmQCtRLSXHM6O77YZC1NRW/D40zvjM6Ypcs0sIUwhH8Q/Yn01FyczelRw2E4/ SnvQ== X-Received: by 10.14.241.141 with SMTP id g13mr547349eer.75.1383498438760; Sun, 03 Nov 2013 09:07:18 -0800 (PST) Received: from localhost ([109.110.66.69]) by mx.google.com with ESMTPSA id d7sm35520215eem.8.2013.11.03.09.07.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 03 Nov 2013 09:07:18 -0800 (PST) From: Ilya Dryomov To: linux-btrfs@vger.kernel.org Cc: Chris Mason , idryomov@gmail.com, Jan Schmidt Subject: [PATCH 2/3] Btrfs: disable online raid-repair on ro mounts Date: Sun, 3 Nov 2013 19:06:39 +0200 Message-Id: <1383498400-21009-2-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1383498400-21009-1-git-send-email-idryomov@gmail.com> References: <1383498400-21009-1-git-send-email-idryomov@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This disables the "if needed, write the good copy back before the read is completed" part of the read sequence for read-only mounts. Cc: Jan Schmidt Signed-off-by: Ilya Dryomov --- fs/btrfs/extent_io.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index c09a40d..a0b7403 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1979,6 +1979,7 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start, struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree; int ret; + ASSERT(!(fs_info->sb->s_flags & MS_RDONLY)); BUG_ON(!mirror_num); /* we can't repair anything in raid56 yet */ @@ -2035,6 +2036,9 @@ int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb, unsigned long i, num_pages = num_extent_pages(eb->start, eb->len); int ret = 0; + if (root->fs_info->sb->s_flags & MS_RDONLY) + return -EROFS; + for (i = 0; i < num_pages; i++) { struct page *p = extent_buffer_page(eb, i); ret = repair_io_failure(root->fs_info, start, PAGE_CACHE_SIZE, @@ -2056,12 +2060,12 @@ static int clean_io_failure(u64 start, struct page *page) u64 private; u64 private_failure; struct io_failure_record *failrec; - struct btrfs_fs_info *fs_info; + struct inode *inode = page->mapping->host; + struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info; struct extent_state *state; int num_copies; int did_repair = 0; int ret; - struct inode *inode = page->mapping->host; private = 0; ret = count_range_bits(&BTRFS_I(inode)->io_failure_tree, &private, @@ -2084,6 +2088,8 @@ static int clean_io_failure(u64 start, struct page *page) did_repair = 1; goto out; } + if (fs_info->sb->s_flags & MS_RDONLY) + goto out; spin_lock(&BTRFS_I(inode)->io_tree.lock); state = find_first_extent_bit_state(&BTRFS_I(inode)->io_tree, @@ -2093,7 +2099,6 @@ static int clean_io_failure(u64 start, struct page *page) if (state && state->start <= failrec->start && state->end >= failrec->start + failrec->len - 1) { - fs_info = BTRFS_I(inode)->root->fs_info; num_copies = btrfs_num_copies(fs_info, failrec->logical, failrec->len); if (num_copies > 1) {