From: Davidlohr Bueso <dave@gnu.org>
To: Phillip Susi <psusi@cfl.rr.com>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 2/4] partx: add BLKPG_RES_PARTITION support
Date: Tue, 06 Dec 2011 19:55:06 +0100 [thread overview]
Message-ID: <1323197706.3283.1.camel@offbook> (raw)
In-Reply-To: <1323115372-3983-2-git-send-email-psusi@cfl.rr.com>
On Mon, 2011-12-05 at 15:02 -0500, Phillip Susi wrote:
> Add new respart shell command and enhance partx update command to use
> BLKPG_RES_PARTITION to resize an existing partition while it is in use.
>
> Signed-off-by: Phillip Susi <psusi@cfl.rr.com>
> ---
> partx/Makefile.am | 4 ++--
> partx/partx.c | 9 +++++++++
> partx/partx.h | 19 +++++++++++++++++++
> partx/respart.8 | 46 ++++++++++++++++++++++++++++++++++++++++++++++
> partx/respart.c | 31 +++++++++++++++++++++++++++++++
> 5 files changed, 107 insertions(+), 2 deletions(-)
> create mode 100644 partx/respart.8
> create mode 100644 partx/respart.c
>
> diff --git a/partx/Makefile.am b/partx/Makefile.am
> index 080bc47..ce6fd5a 100644
> --- a/partx/Makefile.am
> +++ b/partx/Makefile.am
> @@ -1,7 +1,7 @@
> include $(top_srcdir)/config/include-Makefile.am
>
> -usrsbin_exec_PROGRAMS = addpart delpart
> -dist_man_MANS = addpart.8 delpart.8
> +usrsbin_exec_PROGRAMS = addpart delpart respart
> +dist_man_MANS = addpart.8 delpart.8 respart.8
>
> usrsbin_exec_PROGRAMS += partx
> partx_SOURCES = partx.c partx.h \
> diff --git a/partx/partx.c b/partx/partx.c
> index 87443c4..2510ffb 100644
> --- a/partx/partx.c
> +++ b/partx/partx.c
> @@ -467,6 +467,15 @@ static int upd_parts(int fd, const char *device, dev_t devno,
> {
> if (i < nparts)
> i++;
> + if (err == -1 && errno == EBUSY)
> + {
> + /* try to resize */
> + err = partx_res_partition(fd, n, start, size);
> + if (verbose)
> + printf(_("%s: partition #%d resized\n"), device, n);
> + if (err == 0)
> + continue;
> + }
> if (err == 0 && partx_add_partition(fd, n, start, size) == 0) {
> if (verbose)
> printf(_("%s: partition #%d added\n"), device, n);
> diff --git a/partx/partx.h b/partx/partx.h
> index b40fa8f..f85f75b 100644
> --- a/partx/partx.h
> +++ b/partx/partx.h
> @@ -41,4 +41,23 @@ static inline int partx_add_partition(int fd, int partno,
> return ioctl(fd, BLKPG, &a);
> }
>
> +static inline int partx_res_partition(int fd, int partno,
> + unsigned long start, unsigned long size)
> +{
> + struct blkpg_ioctl_arg a;
> + struct blkpg_partition p;
> +
> + p.pno = partno;
> + p.start = start << 9;
> + p.length = size << 9;
> + p.devname[0] = 0;
> + p.volname[0] = 0;
> + a.op = BLKPG_RES_PARTITION;
I like the idea, but we should wait until your BLKPG resize patches are
accepted in mainline before applying here. Also, assuming they make it
into the kernel, this patch would break partx compilation on older
kernels.
- Davidlohr
next prev parent reply other threads:[~2011-12-06 18:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-05 20:02 [PATCH 2/4] partx: add BLKPG_RES_PARTITION support Phillip Susi
2011-12-06 18:55 ` Davidlohr Bueso [this message]
2011-12-06 19:04 ` Phillip Susi
2011-12-08 12:15 ` Karel Zak
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=1323197706.3283.1.camel@offbook \
--to=dave@gnu.org \
--cc=psusi@cfl.rr.com \
--cc=util-linux@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).