aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2/inode.c')
-rw-r--r--fs/gfs2/inode.c83
1 files changed, 82 insertions, 1 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 58f5a67e1c35..a31a4b80ba3c 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -38,6 +38,11 @@
38#include "trans.h" 38#include "trans.h"
39#include "util.h" 39#include "util.h"
40 40
41struct gfs2_inum_range_host {
42 u64 ir_start;
43 u64 ir_length;
44};
45
41static int iget_test(struct inode *inode, void *opaque) 46static int iget_test(struct inode *inode, void *opaque)
42{ 47{
43 struct gfs2_inode *ip = GFS2_I(inode); 48 struct gfs2_inode *ip = GFS2_I(inode);
@@ -402,6 +407,22 @@ out:
402 return inode ? inode : ERR_PTR(error); 407 return inode ? inode : ERR_PTR(error);
403} 408}
404 409
410static void gfs2_inum_range_in(struct gfs2_inum_range_host *ir, const void *buf)
411{
412 const struct gfs2_inum_range *str = buf;
413
414 ir->ir_start = be64_to_cpu(str->ir_start);
415 ir->ir_length = be64_to_cpu(str->ir_length);
416}
417
418static void gfs2_inum_range_out(const struct gfs2_inum_range_host *ir, void *buf)
419{
420 struct gfs2_inum_range *str = buf;
421
422 str->ir_start = cpu_to_be64(ir->ir_start);
423 str->ir_length = cpu_to_be64(ir->ir_length);
424}
425
405static int pick_formal_ino_1(struct gfs2_sbd *sdp, u64 *formal_ino) 426static int pick_formal_ino_1(struct gfs2_sbd *sdp, u64 *formal_ino)
406{ 427{
407 struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode); 428 struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode);
@@ -741,7 +762,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
741 goto fail_quota_locks; 762 goto fail_quota_locks;
742 763
743 error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + 764 error = gfs2_trans_begin(sdp, sdp->sd_max_dirres +
744 al->al_rgd->rd_ri.ri_length + 765 al->al_rgd->rd_length +
745 2 * RES_DINODE + 766 2 * RES_DINODE +
746 RES_STATFS + RES_QUOTA, 0); 767 RES_STATFS + RES_QUOTA, 0);
747 if (error) 768 if (error)
@@ -1234,3 +1255,63 @@ int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
1234 return error; 1255 return error;
1235} 1256}
1236 1257
1258void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
1259{
1260 const struct gfs2_dinode_host *di = &ip->i_di;
1261 struct gfs2_dinode *str = buf;
1262
1263 str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
1264 str->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI);
1265 str->di_header.__pad0 = 0;
1266 str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI);
1267 str->di_header.__pad1 = 0;
1268 str->di_num.no_addr = cpu_to_be64(ip->i_no_addr);
1269 str->di_num.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino);
1270 str->di_mode = cpu_to_be32(ip->i_inode.i_mode);
1271 str->di_uid = cpu_to_be32(ip->i_inode.i_uid);
1272 str->di_gid = cpu_to_be32(ip->i_inode.i_gid);
1273 str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink);
1274 str->di_size = cpu_to_be64(di->di_size);
1275 str->di_blocks = cpu_to_be64(di->di_blocks);
1276 str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec);
1277 str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec);
1278 str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec);
1279
1280 str->di_goal_meta = cpu_to_be64(di->di_goal_meta);
1281 str->di_goal_data = cpu_to_be64(di->di_goal_data);
1282 str->di_generation = cpu_to_be64(di->di_generation);
1283
1284 str->di_flags = cpu_to_be32(di->di_flags);
1285 str->di_height = cpu_to_be16(di->di_height);
1286 str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) &&
1287 !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ?
1288 GFS2_FORMAT_DE : 0);
1289 str->di_depth = cpu_to_be16(di->di_depth);
1290 str->di_entries = cpu_to_be32(di->di_entries);
1291
1292 str->di_eattr = cpu_to_be64(di->di_eattr);
1293}
1294
1295void gfs2_dinode_print(const struct gfs2_inode *ip)
1296{
1297 const struct gfs2_dinode_host *di = &ip->i_di;
1298
1299 printk(KERN_INFO " no_formal_ino = %llu\n",
1300 (unsigned long long)ip->i_no_formal_ino);
1301 printk(KERN_INFO " no_addr = %llu\n",
1302 (unsigned long long)ip->i_no_addr);
1303 printk(KERN_INFO " di_size = %llu\n", (unsigned long long)di->di_size);
1304 printk(KERN_INFO " di_blocks = %llu\n",
1305 (unsigned long long)di->di_blocks);
1306 printk(KERN_INFO " di_goal_meta = %llu\n",
1307 (unsigned long long)di->di_goal_meta);
1308 printk(KERN_INFO " di_goal_data = %llu\n",
1309 (unsigned long long)di->di_goal_data);
1310 printk(KERN_INFO " di_flags = 0x%.8X\n", di->di_flags);
1311 printk(KERN_INFO " di_height = %u\n", di->di_height);
1312 printk(KERN_INFO " di_depth = %u\n", di->di_depth);
1313 printk(KERN_INFO " di_entries = %u\n", di->di_entries);
1314 printk(KERN_INFO " di_eattr = %llu\n",
1315 (unsigned long long)di->di_eattr);
1316}
1317