Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0b0382b authored by Al Viro's avatar Al Viro
Browse files

->encode_fh() API change



pass inode + parent's inode or NULL instead of dentry + bool saying
whether we want the parent or not.

NOTE: that needs ceph fix folded in.

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 6d42e7e9
Loading
Loading
Loading
Loading
+4 −11
Original line number Original line Diff line number Diff line
@@ -13,15 +13,14 @@
					     parent_root_objectid) / 4)
					     parent_root_objectid) / 4)
#define BTRFS_FID_SIZE_CONNECTABLE_ROOT (sizeof(struct btrfs_fid) / 4)
#define BTRFS_FID_SIZE_CONNECTABLE_ROOT (sizeof(struct btrfs_fid) / 4)


static int btrfs_encode_fh(struct dentry *dentry, u32 *fh, int *max_len,
static int btrfs_encode_fh(struct inode *inode, u32 *fh, int *max_len,
			   int connectable)
			   struct inode *parent)
{
{
	struct btrfs_fid *fid = (struct btrfs_fid *)fh;
	struct btrfs_fid *fid = (struct btrfs_fid *)fh;
	struct inode *inode = dentry->d_inode;
	int len = *max_len;
	int len = *max_len;
	int type;
	int type;


	if (connectable && (len < BTRFS_FID_SIZE_CONNECTABLE)) {
	if (parent && (len < BTRFS_FID_SIZE_CONNECTABLE)) {
		*max_len = BTRFS_FID_SIZE_CONNECTABLE;
		*max_len = BTRFS_FID_SIZE_CONNECTABLE;
		return 255;
		return 255;
	} else if (len < BTRFS_FID_SIZE_NON_CONNECTABLE) {
	} else if (len < BTRFS_FID_SIZE_NON_CONNECTABLE) {
@@ -36,19 +35,13 @@ static int btrfs_encode_fh(struct dentry *dentry, u32 *fh, int *max_len,
	fid->root_objectid = BTRFS_I(inode)->root->objectid;
	fid->root_objectid = BTRFS_I(inode)->root->objectid;
	fid->gen = inode->i_generation;
	fid->gen = inode->i_generation;


	if (connectable && !S_ISDIR(inode->i_mode)) {
	if (parent) {
		struct inode *parent;
		u64 parent_root_id;
		u64 parent_root_id;


		spin_lock(&dentry->d_lock);

		parent = dentry->d_parent->d_inode;
		fid->parent_objectid = BTRFS_I(parent)->location.objectid;
		fid->parent_objectid = BTRFS_I(parent)->location.objectid;
		fid->parent_gen = parent->i_generation;
		fid->parent_gen = parent->i_generation;
		parent_root_id = BTRFS_I(parent)->root->objectid;
		parent_root_id = BTRFS_I(parent)->root->objectid;


		spin_unlock(&dentry->d_lock);

		if (parent_root_id != fid->root_objectid) {
		if (parent_root_id != fid->root_objectid) {
			fid->parent_root_objectid = parent_root_id;
			fid->parent_root_objectid = parent_root_id;
			len = BTRFS_FID_SIZE_CONNECTABLE_ROOT;
			len = BTRFS_FID_SIZE_CONNECTABLE_ROOT;
+2 −0
Original line number Original line Diff line number Diff line
@@ -247,7 +247,9 @@ static struct dentry *ceph_fh_to_parent(struct super_block *sb,
}
}


const struct export_operations ceph_export_ops = {
const struct export_operations ceph_export_ops = {
#ifdef CEPH_BREAKAGE_FIXED
	.encode_fh = ceph_encode_fh,
	.encode_fh = ceph_encode_fh,
#endif
	.fh_to_dentry = ceph_fh_to_dentry,
	.fh_to_dentry = ceph_fh_to_dentry,
	.fh_to_parent = ceph_fh_to_parent,
	.fh_to_parent = ceph_fh_to_parent,
};
};
+19 −14
Original line number Original line Diff line number Diff line
@@ -304,24 +304,23 @@ static int get_name(struct vfsmount *mnt, struct dentry *dentry,


/**
/**
 * export_encode_fh - default export_operations->encode_fh function
 * export_encode_fh - default export_operations->encode_fh function
 * @dentry:  the dentry to encode
 * @inode:   the object to encode
 * @fh:      where to store the file handle fragment
 * @fh:      where to store the file handle fragment
 * @max_len: maximum length to store there
 * @max_len: maximum length to store there
 * @connectable: whether to store parent information
 * @parent:  parent directory inode, if wanted
 *
 *
 * This default encode_fh function assumes that the 32 inode number
 * This default encode_fh function assumes that the 32 inode number
 * is suitable for locating an inode, and that the generation number
 * is suitable for locating an inode, and that the generation number
 * can be used to check that it is still valid.  It places them in the
 * can be used to check that it is still valid.  It places them in the
 * filehandle fragment where export_decode_fh expects to find them.
 * filehandle fragment where export_decode_fh expects to find them.
 */
 */
static int export_encode_fh(struct dentry *dentry, struct fid *fid,
static int export_encode_fh(struct inode *inode, struct fid *fid,
		int *max_len, int connectable)
		int *max_len, struct inode *parent)
{
{
	struct inode * inode = dentry->d_inode;
	int len = *max_len;
	int len = *max_len;
	int type = FILEID_INO32_GEN;
	int type = FILEID_INO32_GEN;


	if (connectable && (len < 4)) {
	if (parent && (len < 4)) {
		*max_len = 4;
		*max_len = 4;
		return 255;
		return 255;
	} else if (len < 2) {
	} else if (len < 2) {
@@ -332,14 +331,9 @@ static int export_encode_fh(struct dentry *dentry, struct fid *fid,
	len = 2;
	len = 2;
	fid->i32.ino = inode->i_ino;
	fid->i32.ino = inode->i_ino;
	fid->i32.gen = inode->i_generation;
	fid->i32.gen = inode->i_generation;
	if (connectable && !S_ISDIR(inode->i_mode)) {
	if (parent) {
		struct inode *parent;

		spin_lock(&dentry->d_lock);
		parent = dentry->d_parent->d_inode;
		fid->i32.parent_ino = parent->i_ino;
		fid->i32.parent_ino = parent->i_ino;
		fid->i32.parent_gen = parent->i_generation;
		fid->i32.parent_gen = parent->i_generation;
		spin_unlock(&dentry->d_lock);
		len = 4;
		len = 4;
		type = FILEID_INO32_GEN_PARENT;
		type = FILEID_INO32_GEN_PARENT;
	}
	}
@@ -352,11 +346,22 @@ int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len,
{
{
	const struct export_operations *nop = dentry->d_sb->s_export_op;
	const struct export_operations *nop = dentry->d_sb->s_export_op;
	int error;
	int error;
	struct dentry *p = NULL;
	struct inode *inode = dentry->d_inode, *parent = NULL;


	if (connectable && !S_ISDIR(inode->i_mode)) {
		p = dget_parent(dentry);
		/*
		 * note that while p might've ceased to be our parent already,
		 * it's still pinned by and still positive.
		 */
		parent = p->d_inode;
	}
	if (nop->encode_fh)
	if (nop->encode_fh)
		error = nop->encode_fh(dentry, fid->raw, max_len, connectable);
		error = nop->encode_fh(inode, fid->raw, max_len, parent);
	else
	else
		error = export_encode_fh(dentry, fid, max_len, connectable);
		error = export_encode_fh(inode, fid, max_len, parent);
	dput(p);


	return error;
	return error;
}
}
+4 −5
Original line number Original line Diff line number Diff line
@@ -752,10 +752,9 @@ static struct dentry *fat_fh_to_dentry(struct super_block *sb,
}
}


static int
static int
fat_encode_fh(struct dentry *de, __u32 *fh, int *lenp, int connectable)
fat_encode_fh(struct inode *inode, __u32 *fh, int *lenp, struct inode *parent)
{
{
	int len = *lenp;
	int len = *lenp;
	struct inode *inode =  de->d_inode;
	u32 ipos_h, ipos_m, ipos_l;
	u32 ipos_h, ipos_m, ipos_l;


	if (len < 5) {
	if (len < 5) {
@@ -771,9 +770,9 @@ fat_encode_fh(struct dentry *de, __u32 *fh, int *lenp, int connectable)
	fh[1] = inode->i_generation;
	fh[1] = inode->i_generation;
	fh[2] = ipos_h;
	fh[2] = ipos_h;
	fh[3] = ipos_m | MSDOS_I(inode)->i_logstart;
	fh[3] = ipos_m | MSDOS_I(inode)->i_logstart;
	spin_lock(&de->d_lock);
	fh[4] = ipos_l;
	fh[4] = ipos_l | MSDOS_I(de->d_parent->d_inode)->i_logstart;
	if (parent)
	spin_unlock(&de->d_lock);
		fh[4] |= MSDOS_I(parent)->i_logstart;
	return 3;
	return 3;
}
}


+5 −12
Original line number Original line Diff line number Diff line
@@ -627,12 +627,10 @@ static struct dentry *fuse_get_dentry(struct super_block *sb,
	return ERR_PTR(err);
	return ERR_PTR(err);
}
}


static int fuse_encode_fh(struct dentry *dentry, u32 *fh, int *max_len,
static int fuse_encode_fh(struct inode *inode, u32 *fh, int *max_len,
			   int connectable)
			   struct inode *parent)
{
{
	struct inode *inode = dentry->d_inode;
	int len = parent ? 6 : 3;
	bool encode_parent = connectable && !S_ISDIR(inode->i_mode);
	int len = encode_parent ? 6 : 3;
	u64 nodeid;
	u64 nodeid;
	u32 generation;
	u32 generation;


@@ -648,14 +646,9 @@ static int fuse_encode_fh(struct dentry *dentry, u32 *fh, int *max_len,
	fh[1] = (u32)(nodeid & 0xffffffff);
	fh[1] = (u32)(nodeid & 0xffffffff);
	fh[2] = generation;
	fh[2] = generation;


	if (encode_parent) {
	if (parent) {
		struct inode *parent;

		spin_lock(&dentry->d_lock);
		parent = dentry->d_parent->d_inode;
		nodeid = get_fuse_inode(parent)->nodeid;
		nodeid = get_fuse_inode(parent)->nodeid;
		generation = parent->i_generation;
		generation = parent->i_generation;
		spin_unlock(&dentry->d_lock);


		fh[3] = (u32)(nodeid >> 32);
		fh[3] = (u32)(nodeid >> 32);
		fh[4] = (u32)(nodeid & 0xffffffff);
		fh[4] = (u32)(nodeid & 0xffffffff);
@@ -663,7 +656,7 @@ static int fuse_encode_fh(struct dentry *dentry, u32 *fh, int *max_len,
	}
	}


	*max_len = len;
	*max_len = len;
	return encode_parent ? 0x82 : 0x81;
	return parent ? 0x82 : 0x81;
}
}


static struct dentry *fuse_fh_to_dentry(struct super_block *sb,
static struct dentry *fuse_fh_to_dentry(struct super_block *sb,
Loading