Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Aug 2013 07:56:41 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r254275 - head/sys/geom/raid
Message-ID:  <201308130756.r7D7uf9o086164@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Tue Aug 13 07:56:40 2013
New Revision: 254275
URL: http://svnweb.freebsd.org/changeset/base/254275

Log:
  Return error when opening read-only volumes (like RAID4/5/...) for writing.
  Previously opens succeeded, but actual write operations returned errors.
  
  Requested by:	peter
  MFC after:	2 weeks

Modified:
  head/sys/geom/raid/g_raid.c
  head/sys/geom/raid/g_raid.h
  head/sys/geom/raid/tr_raid5.c

Modified: head/sys/geom/raid/g_raid.c
==============================================================================
--- head/sys/geom/raid/g_raid.c	Tue Aug 13 07:31:27 2013	(r254274)
+++ head/sys/geom/raid/g_raid.c	Tue Aug 13 07:56:40 2013	(r254275)
@@ -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: head/sys/geom/raid/g_raid.h
==============================================================================
--- head/sys/geom/raid/g_raid.h	Tue Aug 13 07:31:27 2013	(r254274)
+++ head/sys/geom/raid/g_raid.h	Tue Aug 13 07:56:40 2013	(r254275)
@@ -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: head/sys/geom/raid/tr_raid5.c
==============================================================================
--- head/sys/geom/raid/tr_raid5.c	Tue Aug 13 07:31:27 2013	(r254274)
+++ head/sys/geom/raid/tr_raid5.c	Tue Aug 13 07:56:40 2013	(r254275)
@@ -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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308130756.r7D7uf9o086164>