All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] check for maximal device size in set_lv
@ 2008-12-19 11:49 Milan Broz
  2008-12-19 14:34 ` Alasdair G Kergon
  0 siblings, 1 reply; 2+ messages in thread
From: Milan Broz @ 2008-12-19 11:49 UTC (permalink / raw)
  To: lvm-devel

Do not issue write violating LV size.

pvcreate $DEV
vgcreate -s 1k vg_test $DEV
lvcreate -l 1 -n lv1 vg_test
..
/dev/vg_test/lv1: write failed after 1024 of 4096 at 0: No space left on device

Just check for maximum write size in set_lv.

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 lib/metadata/lv_manip.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Index: LVM2/lib/metadata/lv_manip.c
===================================================================
--- LVM2.orig/lib/metadata/lv_manip.c	2008-12-19 12:26:26.000000000 +0100
+++ LVM2/lib/metadata/lv_manip.c	2008-12-19 12:37:57.000000000 +0100
@@ -2698,9 +2698,13 @@ int set_lv(struct cmd_context *cmd, stru
 	if (!dev_open_quiet(dev))
 		return_0;
 
-	dev_set(dev, UINT64_C(0),
-		sectors ? (size_t) sectors << SECTOR_SHIFT : (size_t) 4096,
-		value);
+	if (!sectors)
+		sectors = 4096 >> SECTOR_SHIFT;
+
+	if (sectors > lv->size)
+		sectors = lv->size;
+
+	dev_set(dev, UINT64_C(0), (size_t) sectors << SECTOR_SHIFT, value);
 	dev_flush(dev);
 	dev_close_immediate(dev);
 





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] check for maximal device size in set_lv
  2008-12-19 11:49 [PATCH] check for maximal device size in set_lv Milan Broz
@ 2008-12-19 14:34 ` Alasdair G Kergon
  0 siblings, 0 replies; 2+ messages in thread
From: Alasdair G Kergon @ 2008-12-19 14:34 UTC (permalink / raw)
  To: lvm-devel

On Fri, Dec 19, 2008 at 12:49:03PM +0100, Milan Broz wrote:
> Do not issue write violating LV size.
 
Ack.

Alasdair
-- 
agk at redhat.com



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-12-19 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-19 11:49 [PATCH] check for maximal device size in set_lv Milan Broz
2008-12-19 14:34 ` Alasdair G Kergon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.