From patchwork Wed Jul 8 08:49:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikanth Karthikesan X-Patchwork-Id: 34581 X-Patchwork-Delegate: agk@redhat.com Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n688mYje012376 for ; Wed, 8 Jul 2009 08:48:35 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id D6B9B618C0B; Wed, 8 Jul 2009 04:48:34 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n688mWnI032109 for ; Wed, 8 Jul 2009 04:48:32 -0400 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n688mVCl027742; Wed, 8 Jul 2009 04:48:31 -0400 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n688mGSW024497; Wed, 8 Jul 2009 04:48:16 -0400 Received: from relay2.suse.de (relay-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id B31A186391; Wed, 8 Jul 2009 10:48:15 +0200 (CEST) From: Nikanth Karthikesan Organization: suse.de To: Alasdair G Kergon Date: Wed, 8 Jul 2009 14:19:20 +0530 User-Agent: KMail/1.11.1 (Linux/2.6.31-rc2-0.1-default; KDE/4.2.1; x86_64; ; ) MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200907081419.20857.knikanth@suse.de> X-RedHat-Spam-Score: -3.864 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.31 X-loop: dm-devel@redhat.com Cc: device-mapper development Subject: [dm-devel] [PATCH] Allow switch device-mapper tables to READ-WRITE X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com From: Hannes Reinecke Subject: Allow switch device-mapper tables to READ-WRITE Switching a device-mapper table to READ-ONLY works quite well, but we can't switch back to READ-WRITE as this change will be masked out. So get rid of this masking and use the flags directly. And implement a fallback to automatically switch to read-only. Signed-off-by: Hannes Reinecke Signed-off-by: Nikanth Karthikesan --- -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6-dm/drivers/md/dm-table.c =================================================================== --- linux-2.6-dm.orig/drivers/md/dm-table.c +++ linux-2.6-dm/drivers/md/dm-table.c @@ -403,10 +403,15 @@ static int upgrade_mode(struct dm_dev_in dd_new = dd_old = *dd; - dd_new.dm_dev.mode |= new_mode; + dd_new.dm_dev.mode = new_mode; dd_new.dm_dev.bdev = NULL; r = open_dev(&dd_new, dd->dm_dev.bdev->bd_dev, md); + if (r == -EROFS) { + dd_new.dm_dev.mode &= ~FMODE_WRITE; + r = open_dev(&dd_new, dd->dm_dev.bdev->bd_dev, md); + } + if (r) return r; @@ -473,7 +478,7 @@ static int __table_get_device(struct dm_ atomic_set(&dd->count, 0); list_add(&dd->list, &t->devices); - } else if (dd->dm_dev.mode != (mode | dd->dm_dev.mode)) { + } else if (dd->dm_dev.mode != mode) { r = upgrade_mode(dd, mode, t->md); if (r) return r;