[Ocfs2-tools-devel] [RESEND][PATCH] Improvement to tunefs.ocfs2 online resize to handle symbolic link
Joel Becker
Joel.Becker at oracle.com
Thu Mar 18 15:21:44 PDT 2010
On Wed, Mar 17, 2010 at 11:38:44PM +0800, Jiaju Zhang wrote:
> This is a simple patch which fixes the issue that tunefs.ocfs2 online
> resize can't handle symbolic link file. My environemnt is ocfs2 with
> user-space cluster stack and LVM being used. The user may often run
> the command like 'tunefs.ocfs2 -S /dev/vg1/lv1' when online and then
> fails.
>
> After some debugging, I found for now the code doesn't know
> '/dev/vg1/lv1' is a symbolic link to '/dev/mapper/vg1-lv1' but
> actually they are the same device. So I use stat and get the st_rdev
> to identify if those two are the same. I haven't used the method like
> judging if one file is a symbolic link to another is because we also
> need to handle the scenario that if one is not a symbolic link and
> just two device names but they indicate the identical device, like
> '/dev/mapper/vg1-lv1' and '/dev/dm-0'.
>
> Thanks a lot for your time, review and comments;-)
>
> Thanks,
> Jiaju
> ---
> ocfs2_controld/mount.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/ocfs2_controld/mount.c b/ocfs2_controld/mount.c
> index 36459d1..076f727 100644
> --- a/ocfs2_controld/mount.c
> +++ b/ocfs2_controld/mount.c
> @@ -260,11 +260,13 @@ static void add_service(struct mountgroup *mg, const char *device,
> const char *service, int ci, int fd)
> {
> struct service *ms;
> + struct stat st1, st2;
>
> log_debug("Adding service %s to device %s uuid %s",
> service, device, mg->mg_uuid);
>
> - if (strcmp(mg->mg_device, device)) {
> + if (!stat(mg->mg_device, &st1) && !stat(device, &st2)
> + && st1.st_rdev != st2.st_rdev) {
> fill_error(mg, EINVAL,
> "Trying to mount fs %s on device %s, but it is already mounted from device %s",
> mg->mg_uuid, device, mg->mg_device);
I think you are on track, but you need to be more specific in
your error checking. Each stat call should be checked for error and
fill_error() called. If they both succeed, then you can compare the
rdevs.
Joel
--
"Under capitalism, man exploits man. Under Communism, it's just
the opposite."
- John Kenneth Galbraith
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
More information about the Ocfs2-tools-devel
mailing list