This is a simple patch which fix the issue that tunefs.ocfs2 online resize can't handle symbolic link of a device file. For example, in the LVM using scenario, '/dev/vg1/lv1' and '/dev/mapper/vg1-lv1' are the same device, '/dev/vg1/lv1' is just a symbolic link to '/dev/mapper/vg1-lv1'. But if we try to do online resize like 'tunefs.ocfs2 -S /dev/vg1/lv1', it fails. Signed-off-by: Jiaju Zhang --- ocfs2_controld/mount.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ocfs2_controld/mount.c b/ocfs2_controld/mount.c --- a/ocfs2_controld/mount.c +++ b/ocfs2_controld/mount.c @@ -260,13 +260,27 @@ 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", + 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)) { + fill_error(mg, errno, "Failed to stat device \"%s\": %s", + mg->mg_device, strerror(errno)); + return; + } + + if (stat(device, &st2)) { + fill_error(mg, errno, "Failed to stat device \"%s\": %s", + device, strerror(errno)); + return; + } + + if (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", + "Trying to mount fs \"%s\" on device \"%s\", " + "but it is already mounted from device \"%s\"", mg->mg_uuid, device, mg->mg_device); return; }