xfs_dm_rdwr() needs to pass a vfsmount to dentry_open()
PATCH 1/1 xfs_dm_rdwr() needs to pass a vfsmount to dentry_open()
There's a new check added to dentry_open():
if (!mnt) {
printk(KERN_WARNING "%s called with NULL vfsmount\n", __func__);
dump_stack();
return ERR_PTR(-EINVAL);
}We need to pass a mountpoint in the call to dentry_open() in xfs_dm_rdwr() to avoid this code.
xfs/dmapi/xfs_dm.c renamed from xfs/dmapi/xfs_dm.c_1.72 +0 -0
@@ -52,6 +52,8 @@
#include <dmapi_kern.h>
#include "xfs_dm.h"
+#include <linux/mount.h>
+
#define MAXNAMLEN MAXNAMELEN
#define MIN_DIO_SIZE(mp) ((mp)->m_sb.sb_sectsize)
@@ -1121,7 +1123,7 @@ xfs_dm_rdwr(
return ENOMEM; }
- file = dentry_open(dentry, NULL, oflags);
+ file = dentry_open(dentry, mntget(ip->i_mount->m_vfsmount), oflags);
if (IS_ERR(file)) {
return -PTR_ERR(file);
}xfs/linux-2.6/xfs_super.c renamed from xfs/linux-2.6/xfs_super.c_1.416 +0 -0
@@ -1397,8 +1397,14 @@ xfs_fs_get_sb(
void *data, struct vfsmount *mnt)
{
- return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super,
+ int error;
+
+ error = get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super,
mnt);
+ if (!error)
+ ((struct xfs_mount *)mnt->mnt_sb->s_fs_info)->m_vfsmount = mnt;
+
+ return error;
}
static struct super_operations xfs_super_operations = {
xfs/xfs_mount.h renamed from xfs/xfs_mount.h_1.265 +0 -0
@@ -337,6 +337,7 @@ typedef struct xfs_mount {
spinlock_t m_sync_lock; /* work item list lock */
int m_sync_seq; /* sync thread generation no. */
wait_queue_head_t m_wait_single_sync_task;
+ struct vfsmount *m_vfsmount;
} xfs_mount_t;
/*
Quoted 14 lines · Lachlan McIlroy
There's a new check added to
dentry_open():if (!mnt) { printk(KERN_WARNING "%s called with NULL vfsmount\n", __func__); dump_stack(); return ERR_PTR(-EINVAL); }We need to pass a mountpoint in the call to
dentry_open()inxfs_dm_rdwr()to avoid this code.
xfs/dmapi/xfs_dm.c line 55
Quoted 4 lines
xfs/dmapi/xfs_dm.c renamed from xfs/dmapi/xfs_dm.c_1.72 +1
-0@@ -52,6 +52,8 @@#include <dmapi_kern.h> #include "xfs_dm.h" +#include <linux/mount.h>
Should be defined in fs/xfs/linux-2.6/xfs_linux.h, right?
Quoted 18 lines
xfs/dmapi/xfs_dm.c renamed from xfs/dmapi/xfs_dm.c_1.72 +2
-1+#define MAXNAMLEN MAXNAMELEN#define MIN_DIO_SIZE (mp) ((mp)->m_sb.sb_sectsize)@@ -1121,7 +1123,7 @@ xfs_dm_rdwr(return ENOMEM ; } - file =dentry_open (dentry,NULL , oflags); + file =dentry_open (dentry,mntget (ip->i_mount->m_vfsmount), oflags);if (IS_ERR (file)) {return -PTR_ERR (file); }xfs/linux-2.6/xfs_super.c renamed from xfs/linux-2.6/xfs_super.c_1.416 +0
-0@@ -1397,8 +1397,14 @@ xfs_fs_get_sb(void *data, struct vfsmount *mnt)
xfs/linux-2.6/xfs_super.c xfs_fs_get_sb( · line 1407
Quoted 10 lines
xfs/linux-2.6/xfs_super.c renamed from xfs/linux-2.6/xfs_super.c_1.416 +5
-1{ -return get_sb_bdev (fs_type, flags, dev_name, data, xfs_fs_fill_super, +int error; + + error =get_sb_bdev (fs_type, flags, dev_name, data, xfs_fs_fill_super, mnt); +if (!error) + ((struct xfs_mount *)mnt->mnt_sb->s_fs_info)->m_vfsmount = mnt;
As I previously suggested, please use XFS_M(mnt->mnt_sb) for this.
Cheers,
Dave.
Signature · 3 lines
Dave Chinner Principal Engineer SGI Australian Software Group
Quoted 18 lines · David Chinner
Quoted 17 lines · Lachlan McIlroy
There's a new check added to
dentry_open():if (!mnt) { printk(KERN_WARNING "%s called with NULL vfsmount\n", __func__); dump_stack(); return ERR_PTR(-EINVAL); }We need to pass a mountpoint in the call to
dentry_open()inxfs_dm_rdwr()to avoid this code.xfs/dmapi/xfs_dm.c renamed from xfs/dmapi/xfs_dm.c_1.72 +0
-0@@ -52,6 +52,8 @@#include <dmapi_kern.h> #include "xfs_dm.h"
Quoted 3 lines
xfs/dmapi/xfs_dm.c line 55
Quoted 1 line
xfs/dmapi/xfs_dm.c renamed from xfs/dmapi/xfs_dm.c_1.72 +1
-0+#include <linux/mount.h> Should be defined in
fs/xfs/linux-2.6/xfs_linux.h, right?
It's not currently in xfs_linux.h. It's needed for mntget(). I saw that xfs_ioctl.c uses mntget() and pulls in linux/mount.h directly so I followed suit. I can add it to xfs_linux.h if you prefer.
Quoted 23 lines
Quoted 23 lines
xfs/dmapi/xfs_dm.c renamed from xfs/dmapi/xfs_dm.c_1.72 +2
-1+#define MAXNAMLEN MAXNAMELEN#define MIN_DIO_SIZE (mp) ((mp)->m_sb.sb_sectsize)@@ -1121,7 +1123,7 @@ xfs_dm_rdwr(return ENOMEM ; } - file =dentry_open (dentry,NULL , oflags); + file =dentry_open (dentry,mntget (ip->i_mount->m_vfsmount), oflags);if (IS_ERR (file)) {return -PTR_ERR (file); }xfs/linux-2.6/xfs_super.c renamed from xfs/linux-2.6/xfs_super.c_1.416 +2
-1@@ -1397,8 +1397,14 @@ xfs_fs_get_sb(void *data, struct vfsmount *mnt) { - return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super, + int error; +
Quoted 8 lines
xfs/linux-2.6/xfs_super.c xfs_fs_get_sb( · line 1407
Quoted 6 lines
xfs/linux-2.6/xfs_super.c renamed from xfs/linux-2.6/xfs_super.c_1.416 +3
-0+ error =get_sb_bdev (fs_type, flags, dev_name, data, xfs_fs_fill_super, mnt); +if (!error) + ((struct xfs_mount *)mnt->mnt_sb->s_fs_info)->m_vfsmount = mnt;As I previously suggested, please use
XFS_M(mnt->mnt_sb)for this.
Sorry, missed that one.
Quoted 19 lines · Lachlan McIlroy
Quoted 18 lines · David Chinner
Quoted 17 lines · Lachlan McIlroy
There's a new check added to
dentry_open():if (!mnt) { printk(KERN_WARNING "%s called with NULL vfsmount\n", __func__); dump_stack(); return ERR_PTR(-EINVAL); }We need to pass a mountpoint in the call to
dentry_open()inxfs_dm_rdwr()to avoid this code.xfs/dmapi/xfs_dm.c renamed from xfs/dmapi/xfs_dm.c_1.72 +0
-0@@ -52,6 +52,8 @@#include <dmapi_kern.h> #include "xfs_dm.h"
Quoted 6 lines
Quoted 3 lines
xfs/dmapi/xfs_dm.c line 55
Quoted 1 line
xfs/dmapi/xfs_dm.c renamed from xfs/dmapi/xfs_dm.c_1.72 +1
-0+#include <linux/mount.h> Should be defined in
fs/xfs/linux-2.6/xfs_linux.h, right?It's not currently in
xfs_linux.h. It's needed formntget(). I saw thatxfs_ioctl.cusesmntget()and pulls inlinux/mount.hdirectly so I followed suit. I can add it toxfs_linux.hif you prefer.
Typically we include linux specific headers in code outside fs/xfs/linux-2.6 via an implicit include (xfs.h pulls in linux-2.6/xfs_linux.h) to try and keep platform specific headers out of the core code. Whether that rule applies to dmapi is a good question - the dmapi code needs so much cleaning up anyway I'm not sure it matters.....
Cheers,
Dave.
Signature · 3 lines
Dave Chinner Principal Engineer SGI Australian Software Group
xfs/xfs_mount.h typedef struct xfs_mount { · line 341
Quoted 8 lines · Lachlan McIlroy
xfs/xfs_mount.h renamed from xfs/xfs_mount.h_1.265 +1
-0@@ -337,6 +337,7 @@ typedef struct xfs_mount {spinlock_t m_sync_lock;/* work item list lock */ int m_sync_seq;/* sync thread generation no. */ wait_queue_head_t m_wait_single_sync_task; +struct vfsmount *m_vfsmount; } xfs_mount_t;
there can be multiple vfsmounts for a single xfs_mount. In addition to that please don't mess up core xfs for dmapi braindamage.