[PATCH for 4.15] libxfs: fix dev_t handling in inode forks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

In commit 699f676961 ("xfs: remove if_rdev"), some ancient definitions
of MAJOR/MINOR/MKDEV were ported into libxfs.  However, platform_defs.h
already has IRIX_DEV_* macros which encode a (major, minor) tuple into a
(major:14, minor:18) u32 format.  libxfs writes these values to disk
without any further interpretation.

Existing libxfs clients pass these encoded device numbers into libxfs,
which means that we cannot suddenly start interpreting the bit fields
differently.  The ported MAJOR/MINOR does this (major:8, minor:8), with
the result that proto file specs for block/char devices write
bit-shifted garbage into i_rdev.

(Or at least it would write garbage if libxfs_ialloc hadn't also lost
the ability to set i_rdev in the same patch...)

Therefore, just keep using the "IRIX" device encoding macros in
platform_defs.h, and actually set i_rdev in libxfs_ialloc when someone
tries to create a device file.  This fixes a regression in xfs/019.

Cc: sandeen@xxxxxxxxxxx
Fixes: 699f67696151d750a58c321b072360ccc694837b
Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
---
 libxfs/libxfs_priv.h |   18 ++++--------------
 libxfs/util.c        |    1 +
 2 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h
index 8c3f3b7..4c083b9 100644
--- a/libxfs/libxfs_priv.h
+++ b/libxfs/libxfs_priv.h
@@ -87,23 +87,13 @@ extern char    *progname;
 #undef ASSERT
 #define ASSERT(ex) assert(ex)
 
-#define MAJOR(dev)      ((dev)>>8)
-#define MINOR(dev)      ((dev) & 0xff)
-#define MKDEV(ma,mi) ((ma)<<8 | (mi))
-
-static inline unsigned sysv_major(uint32_t dev)
-{
-        return (dev >> 18) & 0x3fff;
-}
-
-static inline unsigned sysv_minor(uint32_t dev)
-{
-        return dev & 0x3ffff;
-}
+#define MKDEV(major, minor)	IRIX_MKDEV(major, minor)
+#define sysv_major(dev)		IRIX_DEV_MAJOR(dev)
+#define sysv_minor(dev)		IRIX_DEV_MINOR(dev)
 
 static inline uint32_t sysv_encode_dev(dev_t dev)
 {
-        return MINOR(dev) | (MAJOR(dev) << 18);
+        return IRIX_DEV_MINOR(dev) | (IRIX_DEV_MAJOR(dev) << 18);
 }
 
 #ifndef EWRONGFS
diff --git a/libxfs/util.c b/libxfs/util.c
index 90f96f8..792a17f 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -336,6 +336,7 @@ libxfs_ialloc(
 	case S_IFBLK:
 		ip->i_d.di_format = XFS_DINODE_FMT_DEV;
 		flags |= XFS_ILOG_DEV;
+		VFS_I(ip)->i_rdev = rdev;
 		break;
 	case S_IFREG:
 	case S_IFDIR:
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux