From owner-svn-src-all@FreeBSD.ORG Sat Sep 14 10:11:10 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 79147A86; Sat, 14 Sep 2013 10:11:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4B1B22DB4; Sat, 14 Sep 2013 10:11:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8EABAc9031985; Sat, 14 Sep 2013 10:11:10 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r8EAB9nn031981; Sat, 14 Sep 2013 10:11:09 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201309141011.r8EAB9nn031981@svn.freebsd.org> From: Alexander Motin Date: Sat, 14 Sep 2013 10:11:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r255565 - stable/9/sys/geom/raid X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Sep 2013 10:11:10 -0000 Author: mav Date: Sat Sep 14 10:11:09 2013 New Revision: 255565 URL: http://svnweb.freebsd.org/changeset/base/255565 Log: MFC r254275: Return error when opening read-only volumes (like RAID4/5/...) for writing. Previously opens succeeded, but actual write operations returned errors. Modified: stable/9/sys/geom/raid/g_raid.c stable/9/sys/geom/raid/g_raid.h stable/9/sys/geom/raid/tr_raid5.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/geom/raid/g_raid.c ============================================================================== --- stable/9/sys/geom/raid/g_raid.c Sat Sep 14 10:10:01 2013 (r255564) +++ stable/9/sys/geom/raid/g_raid.c Sat Sep 14 10:11:09 2013 (r255565) @@ -1863,6 +1863,11 @@ g_raid_access(struct g_provider *pp, int error = ENXIO; goto out; } + /* Deny write opens for read-only volumes. */ + if (vol->v_read_only && acw > 0) { + error = EROFS; + goto out; + } if (dcw == 0) g_raid_clean(vol, dcw); vol->v_provider_open += acr + acw + ace; Modified: stable/9/sys/geom/raid/g_raid.h ============================================================================== --- stable/9/sys/geom/raid/g_raid.h Sat Sep 14 10:10:01 2013 (r255564) +++ stable/9/sys/geom/raid/g_raid.h Sat Sep 14 10:11:09 2013 (r255565) @@ -306,6 +306,7 @@ struct g_raid_volume { int v_stopping; /* Volume is stopping */ int v_provider_open; /* Number of opens. */ int v_global_id; /* Global volume ID (rX). */ + int v_read_only; /* Volume is read-only. */ TAILQ_ENTRY(g_raid_volume) v_next; /* List of volumes entry. */ LIST_ENTRY(g_raid_volume) v_global_next; /* Global list entry. */ }; Modified: stable/9/sys/geom/raid/tr_raid5.c ============================================================================== --- stable/9/sys/geom/raid/tr_raid5.c Sat Sep 14 10:10:01 2013 (r255564) +++ stable/9/sys/geom/raid/tr_raid5.c Sat Sep 14 10:11:09 2013 (r255565) @@ -185,8 +185,9 @@ g_raid_tr_start_raid5(struct g_raid_tr_o struct g_raid_volume *vol; trs = (struct g_raid_tr_raid5_object *)tr; - vol = tr->tro_volume; trs->trso_starting = 0; + vol = tr->tro_volume; + vol->v_read_only = 1; g_raid_tr_update_state_raid5(vol, NULL); return (0); }