Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* -*- mode: c; c-basic-offset: 8; -*-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * vim: noexpandtab sw=8 ts=8 sts=0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * export.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Functions to facilitate NFS exporting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Copyright (C) 2002, 2005 Oracle.  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <cluster/masklog.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include "ocfs2.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include "alloc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include "dir.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include "dlmglue.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "dcache.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include "export.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include "inode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include "buffer_head_io.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include "suballoc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include "ocfs2_trace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) struct ocfs2_inode_handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	u64 ih_blkno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	u32 ih_generation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static struct dentry *ocfs2_get_dentry(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		struct ocfs2_inode_handle *handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	struct ocfs2_super *osb = OCFS2_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	u64 blkno = handle->ih_blkno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	int status, set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	struct dentry *result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	trace_ocfs2_get_dentry_begin(sb, handle, (unsigned long long)blkno);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	if (blkno == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		result = ERR_PTR(-ESTALE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	inode = ocfs2_ilookup(sb, blkno);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	 * If the inode exists in memory, we only need to check it's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	 * generation number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	if (inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		goto check_gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	 * This will synchronize us against ocfs2_delete_inode() on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	 * all nodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	status = ocfs2_nfs_sync_lock(osb, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	if (status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		mlog(ML_ERROR, "getting nfs sync lock(EX) failed %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		goto check_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	status = ocfs2_test_inode_bit(osb, blkno, &set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		if (status == -EINVAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			 * The blkno NFS gave us doesn't even show up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 			 * as an inode, we return -ESTALE to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			 * nice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			status = -ESTALE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			mlog(ML_ERROR, "test inode bit failed %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		goto unlock_nfs_sync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	trace_ocfs2_get_dentry_test_bit(status, set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	/* If the inode allocator bit is clear, this inode must be stale */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	if (!set) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		status = -ESTALE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		goto unlock_nfs_sync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	inode = ocfs2_iget(osb, blkno, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) unlock_nfs_sync:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	ocfs2_nfs_sync_unlock(osb, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) check_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		if (status == -ESTALE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			trace_ocfs2_get_dentry_stale((unsigned long long)blkno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 						     handle->ih_generation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		result = ERR_PTR(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	if (IS_ERR(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		mlog_errno(PTR_ERR(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		result = ERR_CAST(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) check_gen:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (handle->ih_generation != inode->i_generation) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		trace_ocfs2_get_dentry_generation((unsigned long long)blkno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 						  handle->ih_generation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 						  inode->i_generation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		iput(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		result = ERR_PTR(-ESTALE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	result = d_obtain_alias(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	if (IS_ERR(result))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		mlog_errno(PTR_ERR(result));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) bail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	trace_ocfs2_get_dentry_end(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static struct dentry *ocfs2_get_parent(struct dentry *child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	u64 blkno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	struct dentry *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	struct inode *dir = d_inode(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	int set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	trace_ocfs2_get_parent(child, child->d_name.len, child->d_name.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			       (unsigned long long)OCFS2_I(dir)->ip_blkno);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	status = ocfs2_nfs_sync_lock(OCFS2_SB(dir->i_sb), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	if (status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		mlog(ML_ERROR, "getting nfs sync lock(EX) failed %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		parent = ERR_PTR(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	status = ocfs2_inode_lock(dir, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	if (status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		if (status != -ENOENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			mlog_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		parent = ERR_PTR(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		goto unlock_nfs_sync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	status = ocfs2_lookup_ino_from_name(dir, "..", 2, &blkno);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	if (status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		parent = ERR_PTR(-ENOENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		goto bail_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	status = ocfs2_test_inode_bit(OCFS2_SB(dir->i_sb), blkno, &set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	if (status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		if (status == -EINVAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 			status = -ESTALE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 			mlog(ML_ERROR, "test inode bit failed %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		parent = ERR_PTR(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		goto bail_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	trace_ocfs2_get_dentry_test_bit(status, set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	if (!set) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		status = -ESTALE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		parent = ERR_PTR(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		goto bail_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	parent = d_obtain_alias(ocfs2_iget(OCFS2_SB(dir->i_sb), blkno, 0, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) bail_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	ocfs2_inode_unlock(dir, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) unlock_nfs_sync:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	ocfs2_nfs_sync_unlock(OCFS2_SB(dir->i_sb), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) bail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	trace_ocfs2_get_parent_end(parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	return parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static int ocfs2_encode_fh(struct inode *inode, u32 *fh_in, int *max_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			   struct inode *parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	int len = *max_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	int type = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	u64 blkno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	u32 generation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	__le32 *fh = (__force __le32 *) fh_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) #ifdef TRACE_HOOKS_ARE_NOT_BRAINDEAD_IN_YOUR_OPINION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #error "You go ahead and fix that mess, then.  Somehow"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	trace_ocfs2_encode_fh_begin(dentry, dentry->d_name.len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				    dentry->d_name.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 				    fh, len, connectable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (parent && (len < 6)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		*max_len = 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		type = FILEID_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	} else if (len < 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		*max_len = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		type = FILEID_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	blkno = OCFS2_I(inode)->ip_blkno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	generation = inode->i_generation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	trace_ocfs2_encode_fh_self((unsigned long long)blkno, generation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	len = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	fh[0] = cpu_to_le32((u32)(blkno >> 32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	fh[1] = cpu_to_le32((u32)(blkno & 0xffffffff));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	fh[2] = cpu_to_le32(generation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	if (parent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		blkno = OCFS2_I(parent)->ip_blkno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		generation = parent->i_generation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		fh[3] = cpu_to_le32((u32)(blkno >> 32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		fh[4] = cpu_to_le32((u32)(blkno & 0xffffffff));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		fh[5] = cpu_to_le32(generation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		len = 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		type = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		trace_ocfs2_encode_fh_parent((unsigned long long)blkno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 					     generation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	*max_len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) bail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	trace_ocfs2_encode_fh_type(type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	return type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) static struct dentry *ocfs2_fh_to_dentry(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		struct fid *fid, int fh_len, int fh_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	struct ocfs2_inode_handle handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	if (fh_len < 3 || fh_type > 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	handle.ih_blkno = (u64)le32_to_cpu(fid->raw[0]) << 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	handle.ih_blkno |= (u64)le32_to_cpu(fid->raw[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	handle.ih_generation = le32_to_cpu(fid->raw[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	return ocfs2_get_dentry(sb, &handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) static struct dentry *ocfs2_fh_to_parent(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		struct fid *fid, int fh_len, int fh_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	struct ocfs2_inode_handle parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	if (fh_type != 2 || fh_len < 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	parent.ih_blkno = (u64)le32_to_cpu(fid->raw[3]) << 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	parent.ih_blkno |= (u64)le32_to_cpu(fid->raw[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	parent.ih_generation = le32_to_cpu(fid->raw[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	return ocfs2_get_dentry(sb, &parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) const struct export_operations ocfs2_export_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	.encode_fh	= ocfs2_encode_fh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	.fh_to_dentry	= ocfs2_fh_to_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	.fh_to_parent	= ocfs2_fh_to_parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	.get_parent	= ocfs2_get_parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) };