From 90bde110350493b1d07b12f692a829b4d2cab617 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Tue, 26 Jul 2011 23:25:18 -0600 Subject: [PATCH] LU-540 lloop: fix LLOOP_INFO to return FID Instead of returning an inode number to userspace for the LLOOP_INFO ioctl, instead return a FID value. This does not pose compatibility problems, because the ioctl() number was already different between Lustre 1.x and 2.x, and the lctl needed for using lloop devices is always built with the kernel modules. Change-Id: Ia3ee6dab830ad65e2a11d9248982c82ce76221f1 Signed-off-by: Andreas Dilger Reviewed-on: http://review.whamcloud.com/1149 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustre_user.h | 2 +- lustre/llite/lloop.c | 9 ++++++--- lustre/utils/obd.c | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h index 7a8faf0..0b42fa9 100644 --- a/lustre/include/lustre/lustre_user.h +++ b/lustre/include/lustre/lustre_user.h @@ -142,7 +142,7 @@ struct obd_statfs { #define LL_IOC_GETOBDCOUNT _IOR ('f', 168, long) #define LL_IOC_LLOOP_ATTACH _IOWR('f', 169, long) #define LL_IOC_LLOOP_DETACH _IOWR('f', 170, long) -#define LL_IOC_LLOOP_INFO _IOWR('f', 171, long) +#define LL_IOC_LLOOP_INFO _IOWR('f', 171, struct lu_fid) #define LL_IOC_LLOOP_DETACH_BYDEV _IOWR('f', 172, long) #define LL_IOC_PATH2FID _IOR ('f', 173, long) #define LL_IOC_GET_CONNECT_FLAGS _IOWR('f', 174, __u64 *) diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c index f7d4654..3b13aab 100644 --- a/lustre/llite/lloop.c +++ b/lustre/llite/lloop.c @@ -641,6 +641,7 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { struct lloop_device *lo = bdev->bd_disk->private_data; + struct inode *inode = lo->lo_backing_file->f_dentry->d_inode; #else static int lo_ioctl(struct inode *inode, struct file *unused, unsigned int cmd, unsigned long arg) @@ -660,12 +661,14 @@ static int lo_ioctl(struct inode *inode, struct file *unused, } case LL_IOC_LLOOP_INFO: { - __u64 ino = 0; + struct lu_fid fid; if (lo->lo_state == LLOOP_BOUND) - ino = lo->lo_backing_file->f_dentry->d_inode->i_ino; + fid = ll_i2info(inode)->lli_fid; + else + fid_zero(&fid); - if (put_user(ino, (__u64 *)arg)) + if (copy_to_user((struct lu_fid *)arg, &fid, sizeof(fid))) err = -EFAULT; break; } diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 0ff3100..2a84949 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -2455,7 +2455,7 @@ int jt_blockdev_info(int argc, char **argv) { char *filename; int rc, fd; - __u64 ino; + struct lu_fid fid; if (argc != 2) return CMD_HELP; @@ -2468,17 +2468,17 @@ int jt_blockdev_info(int argc, char **argv) return CMD_HELP; } - rc = ioctl(fd, LL_IOC_LLOOP_INFO, &ino); + rc = ioctl(fd, LL_IOC_LLOOP_INFO, &fid); if (rc < 0) { rc = errno; fprintf(stderr, "error: %s\n", strerror(errno)); goto out; } fprintf(stdout, "lloop device info: "); - if (ino == 0ULL) + if (fid_is_zero(&fid)) fprintf(stdout, "Not attached\n"); else - fprintf(stdout, "attached to inode "LPU64"\n", ino); + fprintf(stdout, "attached to inode "DFID"\n", PFID(&fid)); out: close(fd); return -rc; -- 1.8.3.1