linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for 4.15] libxfs: fix dev_t handling in inode forks
@ 2017-11-16  1:15 Darrick J. Wong
  2017-11-16 19:13 ` Eric Sandeen
  2017-11-17 16:57 ` Christoph Hellwig
  0 siblings, 2 replies; 6+ messages in thread
From: Darrick J. Wong @ 2017-11-16  1:15 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

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@sandeen.net
Fixes: 699f67696151d750a58c321b072360ccc694837b
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 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:

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-11-28 14:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-16  1:15 [PATCH for 4.15] libxfs: fix dev_t handling in inode forks Darrick J. Wong
2017-11-16 19:13 ` Eric Sandeen
2017-11-17 16:57 ` Christoph Hellwig
2017-11-27 19:26   ` Eric Sandeen
2017-11-27 20:16     ` Eric Sandeen
2017-11-28 14:04       ` Christoph Hellwig

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).