All of lore.kernel.org
 help / color / mirror / Atom feed
From: Milan Broz <mbroz@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH] check for maximal device size in set_lv
Date: Fri, 19 Dec 2008 12:49:03 +0100	[thread overview]
Message-ID: <494B8A2F.9050305@redhat.com> (raw)

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);
 





             reply	other threads:[~2008-12-19 11:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-19 11:49 Milan Broz [this message]
2008-12-19 14:34 ` [PATCH] check for maximal device size in set_lv Alasdair G Kergon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=494B8A2F.9050305@redhat.com \
    --to=mbroz@redhat.com \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.