]> bbs.cooldavid.org Git - net-next-2.6.git/blame - fs/gfs2/inode.c
ceph: update issue_seq on cap grant
[net-next-2.6.git] / fs / gfs2 / inode.c
CommitLineData
b3b94faa
DT
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
ca390601 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
b3b94faa
DT
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
e9fc2aa0 7 * of the GNU General Public License version 2.
b3b94faa
DT
8 */
9
10#include <linux/sched.h>
11#include <linux/slab.h>
12#include <linux/spinlock.h>
13#include <linux/completion.h>
14#include <linux/buffer_head.h>
15#include <linux/posix_acl.h>
16#include <linux/sort.h>
5c676f6d 17#include <linux/gfs2_ondisk.h>
71b86f56 18#include <linux/crc32.h>
fcb47e0b 19#include <linux/security.h>
719ee344 20#include <linux/time.h>
b3b94faa
DT
21
22#include "gfs2.h"
5c676f6d 23#include "incore.h"
b3b94faa
DT
24#include "acl.h"
25#include "bmap.h"
26#include "dir.h"
307cf6e6 27#include "xattr.h"
b3b94faa
DT
28#include "glock.h"
29#include "glops.h"
30#include "inode.h"
31#include "log.h"
32#include "meta_io.h"
b3b94faa
DT
33#include "quota.h"
34#include "rgrp.h"
35#include "trans.h"
5c676f6d 36#include "util.h"
b3b94faa 37
bb8d8a6f
SW
38struct gfs2_inum_range_host {
39 u64 ir_start;
40 u64 ir_length;
41};
42
feaa7bba
SW
43static int iget_test(struct inode *inode, void *opaque)
44{
45 struct gfs2_inode *ip = GFS2_I(inode);
dbb7cae2 46 u64 *no_addr = opaque;
feaa7bba 47
009d8518 48 if (ip->i_no_addr == *no_addr)
feaa7bba 49 return 1;
b3b94faa 50
feaa7bba
SW
51 return 0;
52}
53
54static int iget_set(struct inode *inode, void *opaque)
b3b94faa 55{
feaa7bba 56 struct gfs2_inode *ip = GFS2_I(inode);
dbb7cae2 57 u64 *no_addr = opaque;
b3b94faa 58
dbb7cae2
SW
59 inode->i_ino = (unsigned long)*no_addr;
60 ip->i_no_addr = *no_addr;
feaa7bba
SW
61 return 0;
62}
b3b94faa 63
dbb7cae2 64struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr)
feaa7bba 65{
dbb7cae2
SW
66 unsigned long hash = (unsigned long)no_addr;
67 return ilookup5(sb, hash, iget_test, &no_addr);
feaa7bba 68}
b3b94faa 69
dbb7cae2 70static struct inode *gfs2_iget(struct super_block *sb, u64 no_addr)
feaa7bba 71{
dbb7cae2
SW
72 unsigned long hash = (unsigned long)no_addr;
73 return iget5_locked(sb, hash, iget_test, iget_set, &no_addr);
b3b94faa
DT
74}
75
7a9f53b3
BM
76struct gfs2_skip_data {
77 u64 no_addr;
78 int skipped;
79};
80
81static int iget_skip_test(struct inode *inode, void *opaque)
82{
83 struct gfs2_inode *ip = GFS2_I(inode);
84 struct gfs2_skip_data *data = opaque;
85
009d8518 86 if (ip->i_no_addr == data->no_addr) {
a4ffdde6 87 if (inode->i_state & (I_FREEING|I_WILL_FREE)){
7a9f53b3
BM
88 data->skipped = 1;
89 return 0;
90 }
91 return 1;
92 }
93 return 0;
94}
95
96static int iget_skip_set(struct inode *inode, void *opaque)
97{
98 struct gfs2_inode *ip = GFS2_I(inode);
99 struct gfs2_skip_data *data = opaque;
100
101 if (data->skipped)
102 return 1;
103 inode->i_ino = (unsigned long)(data->no_addr);
104 ip->i_no_addr = data->no_addr;
105 return 0;
106}
107
108static struct inode *gfs2_iget_skip(struct super_block *sb,
109 u64 no_addr)
110{
111 struct gfs2_skip_data data;
112 unsigned long hash = (unsigned long)no_addr;
113
114 data.no_addr = no_addr;
115 data.skipped = 0;
116 return iget5_locked(sb, hash, iget_skip_test, iget_skip_set, &data);
117}
118
35dcc52e
WC
119/**
120 * GFS2 lookup code fills in vfs inode contents based on info obtained
121 * from directory entry inside gfs2_inode_lookup(). This has caused issues
122 * with NFS code path since its get_dentry routine doesn't have the relevant
123 * directory entry when gfs2_inode_lookup() is invoked. Part of the code
124 * segment inside gfs2_inode_lookup code needs to get moved around.
125 *
eaff8079 126 * Clears I_NEW as well.
35dcc52e
WC
127 **/
128
129void gfs2_set_iop(struct inode *inode)
130{
c97bfe43 131 struct gfs2_sbd *sdp = GFS2_SB(inode);
35dcc52e
WC
132 umode_t mode = inode->i_mode;
133
134 if (S_ISREG(mode)) {
135 inode->i_op = &gfs2_file_iops;
f057f6cd 136 if (gfs2_localflocks(sdp))
10d21988 137 inode->i_fop = &gfs2_file_fops_nolock;
c97bfe43 138 else
10d21988 139 inode->i_fop = &gfs2_file_fops;
35dcc52e
WC
140 } else if (S_ISDIR(mode)) {
141 inode->i_op = &gfs2_dir_iops;
f057f6cd 142 if (gfs2_localflocks(sdp))
10d21988 143 inode->i_fop = &gfs2_dir_fops_nolock;
c97bfe43 144 else
10d21988 145 inode->i_fop = &gfs2_dir_fops;
35dcc52e
WC
146 } else if (S_ISLNK(mode)) {
147 inode->i_op = &gfs2_symlink_iops;
148 } else {
d83225d4 149 inode->i_op = &gfs2_file_iops;
43a33c53 150 init_special_inode(inode, inode->i_mode, inode->i_rdev);
35dcc52e
WC
151 }
152
153 unlock_new_inode(inode);
154}
155
b3b94faa 156/**
feaa7bba
SW
157 * gfs2_inode_lookup - Lookup an inode
158 * @sb: The super block
dbb7cae2 159 * @no_addr: The inode number
feaa7bba 160 * @type: The type of the inode
b3b94faa 161 *
feaa7bba 162 * Returns: A VFS inode, or an error
b3b94faa
DT
163 */
164
091806ed 165struct inode *gfs2_inode_lookup(struct super_block *sb,
bb9bcf06
WC
166 unsigned int type,
167 u64 no_addr,
1a0eae88 168 u64 no_formal_ino)
b3b94faa 169{
7a9f53b3
BM
170 struct inode *inode;
171 struct gfs2_inode *ip;
b1becbde 172 struct gfs2_glock *io_gl = NULL;
feaa7bba 173 int error;
b3b94faa 174
1a0eae88 175 inode = gfs2_iget(sb, no_addr);
7a9f53b3
BM
176 ip = GFS2_I(inode);
177
26d83ded
SW
178 if (!inode)
179 return ERR_PTR(-ENOBUFS);
180
feaa7bba
SW
181 if (inode->i_state & I_NEW) {
182 struct gfs2_sbd *sdp = GFS2_SB(inode);
bb9bcf06 183 ip->i_no_formal_ino = no_formal_ino;
b3b94faa 184
dbb7cae2 185 error = gfs2_glock_get(sdp, no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl);
feaa7bba
SW
186 if (unlikely(error))
187 goto fail;
188 ip->i_gl->gl_object = ip;
b3b94faa 189
dbb7cae2 190 error = gfs2_glock_get(sdp, no_addr, &gfs2_iopen_glops, CREATE, &io_gl);
feaa7bba
SW
191 if (unlikely(error))
192 goto fail_put;
b3b94faa 193
bfded27b 194 set_bit(GIF_INVALID, &ip->i_flags);
feaa7bba
SW
195 error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh);
196 if (unlikely(error))
197 goto fail_iopen;
d93cfa98 198 ip->i_iopen_gh.gh_gl->gl_object = ip;
b3b94faa 199
feaa7bba 200 gfs2_glock_put(io_gl);
b1becbde 201 io_gl = NULL;
c8cdf479 202
35dcc52e
WC
203 if ((type == DT_UNKNOWN) && (no_formal_ino == 0))
204 goto gfs2_nfsbypass;
205
206 inode->i_mode = DT2IF(type);
207
c8cdf479
SW
208 /*
209 * We must read the inode in order to work out its type in
210 * this case. Note that this doesn't happen often as we normally
211 * know the type beforehand. This code path only occurs during
212 * unlinked inode recovery (where it is safe to do this glock,
213 * which is not true in the general case).
214 */
c8cdf479
SW
215 if (type == DT_UNKNOWN) {
216 struct gfs2_holder gh;
217 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
218 if (unlikely(error))
219 goto fail_glock;
220 /* Inode is now uptodate */
c8cdf479
SW
221 gfs2_glock_dq_uninit(&gh);
222 }
223
35dcc52e 224 gfs2_set_iop(inode);
feaa7bba 225 }
b3b94faa 226
35dcc52e 227gfs2_nfsbypass:
b3b94faa 228 return inode;
c8cdf479
SW
229fail_glock:
230 gfs2_glock_dq(&ip->i_iopen_gh);
feaa7bba 231fail_iopen:
b1becbde
BP
232 if (io_gl)
233 gfs2_glock_put(io_gl);
feaa7bba 234fail_put:
1a0eae88
BP
235 if (inode->i_state & I_NEW)
236 ip->i_gl->gl_object = NULL;
feaa7bba
SW
237 gfs2_glock_put(ip->i_gl);
238fail:
1a0eae88
BP
239 if (inode->i_state & I_NEW)
240 iget_failed(inode);
241 else
242 iput(inode);
feaa7bba 243 return ERR_PTR(error);
b3b94faa
DT
244}
245
1a0eae88 246/**
ed4878e8
BP
247 * gfs2_process_unlinked_inode - Lookup an unlinked inode for reclamation
248 * and try to reclaim it by doing iput.
249 *
250 * This function assumes no rgrp locks are currently held.
251 *
1a0eae88
BP
252 * @sb: The super block
253 * no_addr: The inode number
1a0eae88 254 *
1a0eae88
BP
255 */
256
ed4878e8 257void gfs2_process_unlinked_inode(struct super_block *sb, u64 no_addr)
1a0eae88
BP
258{
259 struct gfs2_sbd *sdp;
260 struct gfs2_inode *ip;
b1becbde 261 struct gfs2_glock *io_gl = NULL;
1a0eae88
BP
262 int error;
263 struct gfs2_holder gh;
ed4878e8 264 struct inode *inode;
1a0eae88 265
ed4878e8 266 inode = gfs2_iget_skip(sb, no_addr);
1a0eae88 267
ed4878e8
BP
268 if (!inode)
269 return;
1a0eae88 270
ed4878e8
BP
271 /* If it's not a new inode, someone's using it, so leave it alone. */
272 if (!(inode->i_state & I_NEW)) {
273 iput(inode);
274 return;
275 }
1a0eae88 276
ed4878e8
BP
277 ip = GFS2_I(inode);
278 sdp = GFS2_SB(inode);
1a0eae88
BP
279 ip->i_no_formal_ino = -1;
280
281 error = gfs2_glock_get(sdp, no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl);
282 if (unlikely(error))
283 goto fail;
284 ip->i_gl->gl_object = ip;
285
286 error = gfs2_glock_get(sdp, no_addr, &gfs2_iopen_glops, CREATE, &io_gl);
287 if (unlikely(error))
288 goto fail_put;
289
290 set_bit(GIF_INVALID, &ip->i_flags);
291 error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, LM_FLAG_TRY | GL_EXACT,
292 &ip->i_iopen_gh);
ed4878e8 293 if (unlikely(error))
1a0eae88 294 goto fail_iopen;
ed4878e8 295
1a0eae88
BP
296 ip->i_iopen_gh.gh_gl->gl_object = ip;
297 gfs2_glock_put(io_gl);
b1becbde 298 io_gl = NULL;
1a0eae88 299
ed4878e8 300 inode->i_mode = DT2IF(DT_UNKNOWN);
1a0eae88
BP
301
302 /*
303 * We must read the inode in order to work out its type in
304 * this case. Note that this doesn't happen often as we normally
305 * know the type beforehand. This code path only occurs during
306 * unlinked inode recovery (where it is safe to do this glock,
307 * which is not true in the general case).
308 */
309 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, LM_FLAG_TRY,
310 &gh);
ed4878e8 311 if (unlikely(error))
1a0eae88 312 goto fail_glock;
ed4878e8 313
1a0eae88
BP
314 /* Inode is now uptodate */
315 gfs2_glock_dq_uninit(&gh);
ed4878e8
BP
316 gfs2_set_iop(inode);
317
318 /* The iput will cause it to be deleted. */
319 iput(inode);
320 return;
1a0eae88 321
1a0eae88
BP
322fail_glock:
323 gfs2_glock_dq(&ip->i_iopen_gh);
324fail_iopen:
b1becbde
BP
325 if (io_gl)
326 gfs2_glock_put(io_gl);
1a0eae88
BP
327fail_put:
328 ip->i_gl->gl_object = NULL;
329 gfs2_glock_put(ip->i_gl);
330fail:
ed4878e8
BP
331 iget_failed(inode);
332 return;
1a0eae88
BP
333}
334
af339c02 335static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
ea744d01 336{
ea744d01 337 const struct gfs2_dinode *str = buf;
719ee344 338 struct timespec atime;
9a004508 339 u16 height, depth;
ea744d01 340
ecc30c79
SW
341 if (unlikely(ip->i_no_addr != be64_to_cpu(str->di_num.no_addr)))
342 goto corrupt;
dbb7cae2 343 ip->i_no_formal_ino = be64_to_cpu(str->di_num.no_formal_ino);
b60623c2 344 ip->i_inode.i_mode = be32_to_cpu(str->di_mode);
e7f14f4d 345 ip->i_inode.i_rdev = 0;
b60623c2 346 switch (ip->i_inode.i_mode & S_IFMT) {
e7f14f4d
SW
347 case S_IFBLK:
348 case S_IFCHR:
349 ip->i_inode.i_rdev = MKDEV(be32_to_cpu(str->di_major),
350 be32_to_cpu(str->di_minor));
351 break;
352 };
353
2933f925
SW
354 ip->i_inode.i_uid = be32_to_cpu(str->di_uid);
355 ip->i_inode.i_gid = be32_to_cpu(str->di_gid);
4f56110a
SW
356 /*
357 * We will need to review setting the nlink count here in the
358 * light of the forthcoming ro bind mount work. This is a reminder
359 * to do that.
360 */
361 ip->i_inode.i_nlink = be32_to_cpu(str->di_nlink);
c9e98886
SW
362 ip->i_disksize = be64_to_cpu(str->di_size);
363 i_size_write(&ip->i_inode, ip->i_disksize);
77658aad 364 gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks));
719ee344
SW
365 atime.tv_sec = be64_to_cpu(str->di_atime);
366 atime.tv_nsec = be32_to_cpu(str->di_atime_nsec);
367 if (timespec_compare(&ip->i_inode.i_atime, &atime) < 0)
368 ip->i_inode.i_atime = atime;
1a7b1eed 369 ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime);
4bd91ba1 370 ip->i_inode.i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec);
1a7b1eed 371 ip->i_inode.i_ctime.tv_sec = be64_to_cpu(str->di_ctime);
4bd91ba1 372 ip->i_inode.i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec);
ea744d01 373
ce276b06 374 ip->i_goal = be64_to_cpu(str->di_goal_meta);
bcf0b5b3 375 ip->i_generation = be64_to_cpu(str->di_generation);
ea744d01 376
383f01fb 377 ip->i_diskflags = be32_to_cpu(str->di_flags);
6b124d8d 378 gfs2_set_inode_flags(&ip->i_inode);
ecc30c79
SW
379 height = be16_to_cpu(str->di_height);
380 if (unlikely(height > GFS2_MAX_META_HEIGHT))
381 goto corrupt;
382 ip->i_height = (u8)height;
ea744d01 383
9a004508
SW
384 depth = be16_to_cpu(str->di_depth);
385 if (unlikely(depth > GFS2_DIR_MAX_DEPTH))
386 goto corrupt;
387 ip->i_depth = (u8)depth;
ad6203f2 388 ip->i_entries = be32_to_cpu(str->di_entries);
ea744d01 389
3767ac21 390 ip->i_eattr = be64_to_cpu(str->di_eattr);
5561093e
SW
391 if (S_ISREG(ip->i_inode.i_mode))
392 gfs2_set_aops(&ip->i_inode);
393
af339c02 394 return 0;
ecc30c79
SW
395corrupt:
396 if (gfs2_consist_inode(ip))
397 gfs2_dinode_print(ip);
398 return -EIO;
ea744d01
SW
399}
400
b3b94faa
DT
401/**
402 * gfs2_inode_refresh - Refresh the incore copy of the dinode
403 * @ip: The GFS2 inode
404 *
405 * Returns: errno
406 */
407
408int gfs2_inode_refresh(struct gfs2_inode *ip)
409{
410 struct buffer_head *dibh;
411 int error;
412
413 error = gfs2_meta_inode_buffer(ip, &dibh);
414 if (error)
415 return error;
416
feaa7bba 417 if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), dibh, GFS2_METATYPE_DI)) {
b3b94faa
DT
418 brelse(dibh);
419 return -EIO;
420 }
421
af339c02 422 error = gfs2_dinode_in(ip, dibh->b_data);
b3b94faa 423 brelse(dibh);
bfded27b 424 clear_bit(GIF_INVALID, &ip->i_flags);
b3b94faa 425
af339c02 426 return error;
b3b94faa
DT
427}
428
feaa7bba 429int gfs2_dinode_dealloc(struct gfs2_inode *ip)
b3b94faa 430{
feaa7bba 431 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
b3b94faa
DT
432 struct gfs2_alloc *al;
433 struct gfs2_rgrpd *rgd;
434 int error;
435
77658aad 436 if (gfs2_get_inode_blocks(&ip->i_inode) != 1) {
b3b94faa 437 if (gfs2_consist_inode(ip))
4cc14f0b 438 gfs2_dinode_print(ip);
b3b94faa
DT
439 return -EIO;
440 }
441
442 al = gfs2_alloc_get(ip);
182fe5ab
CG
443 if (!al)
444 return -ENOMEM;
b3b94faa
DT
445
446 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
447 if (error)
448 goto out;
449
450 error = gfs2_rindex_hold(sdp, &al->al_ri_gh);
451 if (error)
452 goto out_qs;
453
dbb7cae2 454 rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr);
b3b94faa
DT
455 if (!rgd) {
456 gfs2_consist_inode(ip);
457 error = -EIO;
458 goto out_rindex_relse;
459 }
460
461 error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0,
462 &al->al_rgd_gh);
463 if (error)
464 goto out_rindex_relse;
465
420b9e5e 466 error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA, 1);
b3b94faa
DT
467 if (error)
468 goto out_rg_gunlock;
469
2bcd610d
SW
470 set_bit(GLF_DIRTY, &ip->i_gl->gl_flags);
471 set_bit(GLF_LFLUSH, &ip->i_gl->gl_flags);
b3b94faa
DT
472
473 gfs2_free_di(rgd, ip);
474
b3b94faa 475 gfs2_trans_end(sdp);
b3b94faa 476
feaa7bba 477out_rg_gunlock:
b3b94faa 478 gfs2_glock_dq_uninit(&al->al_rgd_gh);
feaa7bba 479out_rindex_relse:
b3b94faa 480 gfs2_glock_dq_uninit(&al->al_ri_gh);
feaa7bba 481out_qs:
b3b94faa 482 gfs2_quota_unhold(ip);
36327521 483out:
feaa7bba 484 gfs2_alloc_put(ip);
b3b94faa
DT
485 return error;
486}
487
b3b94faa 488/**
87d21e07 489 * gfs2_change_nlink - Change nlink count on inode
b3b94faa
DT
490 * @ip: The GFS2 inode
491 * @diff: The change in the nlink count required
492 *
493 * Returns: errno
494 */
87d21e07 495int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
b3b94faa
DT
496{
497 struct buffer_head *dibh;
cd915493 498 u32 nlink;
b3b94faa
DT
499 int error;
500
4f56110a
SW
501 BUG_ON(diff != 1 && diff != -1);
502 nlink = ip->i_inode.i_nlink + diff;
b3b94faa
DT
503
504 /* If we are reducing the nlink count, but the new value ends up being
505 bigger than the old one, we must have underflowed. */
4f56110a 506 if (diff < 0 && nlink > ip->i_inode.i_nlink) {
b3b94faa 507 if (gfs2_consist_inode(ip))
4cc14f0b 508 gfs2_dinode_print(ip);
b3b94faa
DT
509 return -EIO;
510 }
511
512 error = gfs2_meta_inode_buffer(ip, &dibh);
513 if (error)
514 return error;
515
4f56110a
SW
516 if (diff > 0)
517 inc_nlink(&ip->i_inode);
518 else
519 drop_nlink(&ip->i_inode);
520
4bd91ba1 521 ip->i_inode.i_ctime = CURRENT_TIME;
b3b94faa 522
d4e9c4c3 523 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
539e5d6b 524 gfs2_dinode_out(ip, dibh->b_data);
b3b94faa 525 brelse(dibh);
feaa7bba 526 mark_inode_dirty(&ip->i_inode);
b3b94faa 527
87d21e07 528 if (ip->i_inode.i_nlink == 0)
ddee7608 529 gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */
87d21e07 530
5509826f
WC
531 return error;
532}
533
c752666c
SW
534struct inode *gfs2_lookup_simple(struct inode *dip, const char *name)
535{
536 struct qstr qstr;
6c93fd1e 537 struct inode *inode;
71b86f56 538 gfs2_str2qstr(&qstr, name);
a569c711 539 inode = gfs2_lookupi(dip, &qstr, 1);
6c93fd1e
RC
540 /* gfs2_lookupi has inconsistent callers: vfs
541 * related routines expect NULL for no entry found,
542 * gfs2_lookup_simple callers expect ENOENT
543 * and do not check for NULL.
544 */
545 if (inode == NULL)
546 return ERR_PTR(-ENOENT);
547 else
548 return inode;
c752666c
SW
549}
550
551
b3b94faa
DT
552/**
553 * gfs2_lookupi - Look up a filename in a directory and return its inode
554 * @d_gh: An initialized holder for the directory glock
555 * @name: The name of the inode to look for
556 * @is_root: If 1, ignore the caller's permissions
557 * @i_gh: An uninitialized holder for the new inode glock
558 *
d7c103d0
SW
559 * This can be called via the VFS filldir function when NFS is doing
560 * a readdirplus and the inode which its intending to stat isn't
561 * already in cache. In this case we must not take the directory glock
562 * again, since the readdir call will have already taken that lock.
b3b94faa
DT
563 *
564 * Returns: errno
565 */
566
feaa7bba 567struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
a569c711 568 int is_root)
b3b94faa 569{
c9fd4307 570 struct super_block *sb = dir->i_sb;
feaa7bba 571 struct gfs2_inode *dip = GFS2_I(dir);
b3b94faa 572 struct gfs2_holder d_gh;
037bcbb7 573 int error = 0;
c752666c 574 struct inode *inode = NULL;
d7c103d0 575 int unlock = 0;
b3b94faa
DT
576
577 if (!name->len || name->len > GFS2_FNAMESIZE)
c752666c 578 return ERR_PTR(-ENAMETOOLONG);
b3b94faa 579
c752666c
SW
580 if ((name->len == 1 && memcmp(name->name, ".", 1) == 0) ||
581 (name->len == 2 && memcmp(name->name, "..", 2) == 0 &&
582 dir == sb->s_root->d_inode)) {
320dd101
SW
583 igrab(dir);
584 return dir;
b3b94faa
DT
585 }
586
7afd88d9 587 if (gfs2_glock_is_locked_by_me(dip->i_gl) == NULL) {
d7c103d0
SW
588 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
589 if (error)
590 return ERR_PTR(error);
591 unlock = 1;
592 }
b3b94faa
DT
593
594 if (!is_root) {
f58ba889 595 error = gfs2_permission(dir, MAY_EXEC);
b3b94faa
DT
596 if (error)
597 goto out;
598 }
599
dbb7cae2
SW
600 inode = gfs2_dir_search(dir, name);
601 if (IS_ERR(inode))
602 error = PTR_ERR(inode);
7359a19c 603out:
d7c103d0
SW
604 if (unlock)
605 gfs2_glock_dq_uninit(&d_gh);
c752666c
SW
606 if (error == -ENOENT)
607 return NULL;
d7c103d0 608 return inode ? inode : ERR_PTR(error);
b3b94faa
DT
609}
610
b3b94faa
DT
611/**
612 * create_ok - OK to create a new on-disk inode here?
613 * @dip: Directory in which dinode is to be created
614 * @name: Name of new dinode
615 * @mode:
616 *
617 * Returns: errno
618 */
619
feaa7bba 620static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
b3b94faa
DT
621 unsigned int mode)
622{
623 int error;
624
f58ba889 625 error = gfs2_permission(&dip->i_inode, MAY_WRITE | MAY_EXEC);
b3b94faa
DT
626 if (error)
627 return error;
628
629 /* Don't create entries in an unlinked directory */
4f56110a 630 if (!dip->i_inode.i_nlink)
b3b94faa
DT
631 return -EPERM;
632
dbb7cae2 633 error = gfs2_dir_check(&dip->i_inode, name, NULL);
b3b94faa
DT
634 switch (error) {
635 case -ENOENT:
636 error = 0;
637 break;
638 case 0:
639 return -EEXIST;
640 default:
641 return error;
642 }
643
ad6203f2 644 if (dip->i_entries == (u32)-1)
b3b94faa 645 return -EFBIG;
4f56110a 646 if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1)
b3b94faa
DT
647 return -EMLINK;
648
649 return 0;
650}
651
652static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode,
653 unsigned int *uid, unsigned int *gid)
654{
feaa7bba 655 if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir &&
2933f925 656 (dip->i_inode.i_mode & S_ISUID) && dip->i_inode.i_uid) {
b3b94faa
DT
657 if (S_ISDIR(*mode))
658 *mode |= S_ISUID;
3de7be33 659 else if (dip->i_inode.i_uid != current_fsuid())
b3b94faa 660 *mode &= ~07111;
2933f925 661 *uid = dip->i_inode.i_uid;
b3b94faa 662 } else
3de7be33 663 *uid = current_fsuid();
b3b94faa 664
b60623c2 665 if (dip->i_inode.i_mode & S_ISGID) {
b3b94faa
DT
666 if (S_ISDIR(*mode))
667 *mode |= S_ISGID;
2933f925 668 *gid = dip->i_inode.i_gid;
b3b94faa 669 } else
3de7be33 670 *gid = current_fsgid();
b3b94faa
DT
671}
672
dbb7cae2 673static int alloc_dinode(struct gfs2_inode *dip, u64 *no_addr, u64 *generation)
b3b94faa 674{
feaa7bba 675 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
b3b94faa
DT
676 int error;
677
6dbd8224
SW
678 if (gfs2_alloc_get(dip) == NULL)
679 return -ENOMEM;
b3b94faa 680
6dbd8224 681 dip->i_alloc->al_requested = RES_DINODE;
b3b94faa
DT
682 error = gfs2_inplace_reserve(dip);
683 if (error)
684 goto out;
685
feaa7bba 686 error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS, 0);
b3b94faa
DT
687 if (error)
688 goto out_ipreserv;
689
6050b9c7 690 error = gfs2_alloc_di(dip, no_addr, generation);
b3b94faa
DT
691
692 gfs2_trans_end(sdp);
693
4340fe62 694out_ipreserv:
b3b94faa 695 gfs2_inplace_release(dip);
4340fe62 696out:
b3b94faa 697 gfs2_alloc_put(dip);
b3b94faa
DT
698 return error;
699}
700
701/**
702 * init_dinode - Fill in a new dinode structure
703 * @dip: the directory this inode is being created in
704 * @gl: The glock covering the new inode
705 * @inum: the inode number
706 * @mode: the file permissions
707 * @uid:
708 * @gid:
709 *
710 */
711
712static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
629a21e7 713 const struct gfs2_inum_host *inum, unsigned int mode,
4340fe62 714 unsigned int uid, unsigned int gid,
e9bd2b3b 715 const u64 *generation, dev_t dev, struct buffer_head **bhp)
b3b94faa 716{
feaa7bba 717 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
b96ca4fa 718 struct gfs2_dinode *di;
b3b94faa 719 struct buffer_head *dibh;
4bd91ba1 720 struct timespec tv = CURRENT_TIME;
b3b94faa
DT
721
722 dibh = gfs2_meta_new(gl, inum->no_addr);
d4e9c4c3 723 gfs2_trans_add_bh(gl, dibh, 1);
b3b94faa
DT
724 gfs2_metatype_set(dibh, GFS2_METATYPE_DI, GFS2_FORMAT_DI);
725 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
b96ca4fa
SW
726 di = (struct gfs2_dinode *)dibh->b_data;
727
2442a098
SW
728 di->di_num.no_formal_ino = cpu_to_be64(inum->no_formal_ino);
729 di->di_num.no_addr = cpu_to_be64(inum->no_addr);
b96ca4fa
SW
730 di->di_mode = cpu_to_be32(mode);
731 di->di_uid = cpu_to_be32(uid);
732 di->di_gid = cpu_to_be32(gid);
294caaa3
SW
733 di->di_nlink = 0;
734 di->di_size = 0;
b96ca4fa 735 di->di_blocks = cpu_to_be64(1);
4bd91ba1 736 di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(tv.tv_sec);
e7f14f4d
SW
737 di->di_major = cpu_to_be32(MAJOR(dev));
738 di->di_minor = cpu_to_be32(MINOR(dev));
b96ca4fa 739 di->di_goal_meta = di->di_goal_data = cpu_to_be64(inum->no_addr);
4340fe62 740 di->di_generation = cpu_to_be64(*generation);
294caaa3 741 di->di_flags = 0;
b3b94faa
DT
742
743 if (S_ISREG(mode)) {
383f01fb 744 if ((dip->i_diskflags & GFS2_DIF_INHERIT_JDATA) ||
b3b94faa 745 gfs2_tune_get(sdp, gt_new_files_jdata))
b96ca4fa 746 di->di_flags |= cpu_to_be32(GFS2_DIF_JDATA);
b3b94faa 747 } else if (S_ISDIR(mode)) {
383f01fb 748 di->di_flags |= cpu_to_be32(dip->i_diskflags &
568f4c96 749 GFS2_DIF_INHERIT_JDATA);
b3b94faa
DT
750 }
751
b96ca4fa 752 di->__pad1 = 0;
a9583c79 753 di->di_payload_format = cpu_to_be32(S_ISDIR(mode) ? GFS2_FORMAT_DE : 0);
294caaa3 754 di->di_height = 0;
b96ca4fa
SW
755 di->__pad2 = 0;
756 di->__pad3 = 0;
294caaa3
SW
757 di->di_depth = 0;
758 di->di_entries = 0;
b96ca4fa 759 memset(&di->__pad4, 0, sizeof(di->__pad4));
294caaa3 760 di->di_eattr = 0;
4bd91ba1
SW
761 di->di_atime_nsec = cpu_to_be32(tv.tv_nsec);
762 di->di_mtime_nsec = cpu_to_be32(tv.tv_nsec);
763 di->di_ctime_nsec = cpu_to_be32(tv.tv_nsec);
b96ca4fa 764 memset(&di->di_reserved, 0, sizeof(di->di_reserved));
e9bd2b3b
WC
765
766 set_buffer_uptodate(dibh);
b96ca4fa 767
e9bd2b3b 768 *bhp = dibh;
b3b94faa
DT
769}
770
771static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
629a21e7 772 unsigned int mode, const struct gfs2_inum_host *inum,
e9bd2b3b 773 const u64 *generation, dev_t dev, struct buffer_head **bhp)
b3b94faa 774{
feaa7bba 775 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
b3b94faa
DT
776 unsigned int uid, gid;
777 int error;
778
779 munge_mode_uid_gid(dip, &mode, &uid, &gid);
182fe5ab
CG
780 if (!gfs2_alloc_get(dip))
781 return -ENOMEM;
b3b94faa
DT
782
783 error = gfs2_quota_lock(dip, uid, gid);
784 if (error)
785 goto out;
786
787 error = gfs2_quota_check(dip, uid, gid);
788 if (error)
789 goto out_quota;
790
feaa7bba 791 error = gfs2_trans_begin(sdp, RES_DINODE + RES_QUOTA, 0);
b3b94faa
DT
792 if (error)
793 goto out_quota;
794
e9bd2b3b 795 init_dinode(dip, gl, inum, mode, uid, gid, generation, dev, bhp);
b3b94faa 796 gfs2_quota_change(dip, +1, uid, gid);
b3b94faa
DT
797 gfs2_trans_end(sdp);
798
feaa7bba 799out_quota:
b3b94faa 800 gfs2_quota_unlock(dip);
feaa7bba 801out:
b3b94faa 802 gfs2_alloc_put(dip);
b3b94faa
DT
803 return error;
804}
805
feaa7bba
SW
806static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
807 struct gfs2_inode *ip)
b3b94faa 808{
feaa7bba 809 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
b3b94faa
DT
810 struct gfs2_alloc *al;
811 int alloc_required;
812 struct buffer_head *dibh;
813 int error;
814
815 al = gfs2_alloc_get(dip);
182fe5ab
CG
816 if (!al)
817 return -ENOMEM;
b3b94faa
DT
818
819 error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
820 if (error)
821 goto fail;
822
feaa7bba 823 error = alloc_required = gfs2_diradd_alloc_required(&dip->i_inode, name);
c752666c 824 if (alloc_required < 0)
1b8177ec 825 goto fail_quota_locks;
b3b94faa 826 if (alloc_required) {
2933f925 827 error = gfs2_quota_check(dip, dip->i_inode.i_uid, dip->i_inode.i_gid);
b3b94faa
DT
828 if (error)
829 goto fail_quota_locks;
830
831 al->al_requested = sdp->sd_max_dirres;
832
833 error = gfs2_inplace_reserve(dip);
834 if (error)
835 goto fail_quota_locks;
836
320dd101 837 error = gfs2_trans_begin(sdp, sdp->sd_max_dirres +
bb8d8a6f 838 al->al_rgd->rd_length +
907b9bce 839 2 * RES_DINODE +
b3b94faa
DT
840 RES_STATFS + RES_QUOTA, 0);
841 if (error)
842 goto fail_ipreserv;
843 } else {
feaa7bba 844 error = gfs2_trans_begin(sdp, RES_LEAF + 2 * RES_DINODE, 0);
b3b94faa
DT
845 if (error)
846 goto fail_quota_locks;
847 }
848
dbb7cae2 849 error = gfs2_dir_add(&dip->i_inode, name, ip, IF2DT(ip->i_inode.i_mode));
b3b94faa
DT
850 if (error)
851 goto fail_end_trans;
852
853 error = gfs2_meta_inode_buffer(ip, &dibh);
854 if (error)
855 goto fail_end_trans;
4f56110a 856 ip->i_inode.i_nlink = 1;
d4e9c4c3 857 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
539e5d6b 858 gfs2_dinode_out(ip, dibh->b_data);
b3b94faa 859 brelse(dibh);
b3b94faa
DT
860 return 0;
861
320dd101 862fail_end_trans:
b3b94faa
DT
863 gfs2_trans_end(sdp);
864
320dd101 865fail_ipreserv:
6dbd8224 866 if (dip->i_alloc->al_rgd)
b3b94faa
DT
867 gfs2_inplace_release(dip);
868
320dd101 869fail_quota_locks:
b3b94faa
DT
870 gfs2_quota_unlock(dip);
871
320dd101 872fail:
b3b94faa 873 gfs2_alloc_put(dip);
b3b94faa
DT
874 return error;
875}
876
fcb47e0b
RH
877static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip)
878{
879 int err;
880 size_t len;
881 void *value;
882 char *name;
fcb47e0b
RH
883
884 err = security_inode_init_security(&ip->i_inode, &dip->i_inode,
885 &name, &value, &len);
886
887 if (err) {
888 if (err == -EOPNOTSUPP)
889 return 0;
890 return err;
891 }
892
431547b3
CH
893 err = __gfs2_xattr_set(&ip->i_inode, name, value, len, 0,
894 GFS2_EATYPE_SECURITY);
fcb47e0b
RH
895 kfree(value);
896 kfree(name);
897
898 return err;
899}
900
b3b94faa
DT
901/**
902 * gfs2_createi - Create a new inode
903 * @ghs: An array of two holders
904 * @name: The name of the new file
905 * @mode: the permissions on the new inode
906 *
907 * @ghs[0] is an initialized holder for the directory
908 * @ghs[1] is the holder for the inode lock
909 *
7359a19c 910 * If the return value is not NULL, the glocks on both the directory and the new
b3b94faa
DT
911 * file are held. A transaction has been started and an inplace reservation
912 * is held, as well.
913 *
7359a19c 914 * Returns: An inode
b3b94faa
DT
915 */
916
feaa7bba 917struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
e7f14f4d 918 unsigned int mode, dev_t dev)
b3b94faa 919{
e1cc8603 920 struct inode *inode = NULL;
5c676f6d 921 struct gfs2_inode *dip = ghs->gh_gl->gl_object;
feaa7bba
SW
922 struct inode *dir = &dip->i_inode;
923 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
dbb7cae2 924 struct gfs2_inum_host inum = { .no_addr = 0, .no_formal_ino = 0 };
b3b94faa 925 int error;
4340fe62 926 u64 generation;
f91a0d3e 927 struct buffer_head *bh = NULL;
b3b94faa
DT
928
929 if (!name->len || name->len > GFS2_FNAMESIZE)
7359a19c 930 return ERR_PTR(-ENAMETOOLONG);
b3b94faa 931
b3b94faa
DT
932 gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, ghs);
933 error = gfs2_glock_nq(ghs);
934 if (error)
935 goto fail;
936
937 error = create_ok(dip, name, mode);
938 if (error)
939 goto fail_gunlock;
940
dbb7cae2 941 error = alloc_dinode(dip, &inum.no_addr, &generation);
b3b94faa
DT
942 if (error)
943 goto fail_gunlock;
8d8291ae 944 inum.no_formal_ino = generation;
b3b94faa 945
28626e20
SW
946 error = gfs2_glock_nq_num(sdp, inum.no_addr, &gfs2_inode_glops,
947 LM_ST_EXCLUSIVE, GL_SKIP, ghs + 1);
948 if (error)
949 goto fail_gunlock;
b3b94faa 950
e9bd2b3b 951 error = make_dinode(dip, ghs[1].gh_gl, mode, &inum, &generation, dev, &bh);
b3b94faa
DT
952 if (error)
953 goto fail_gunlock2;
954
8d8291ae 955 inode = gfs2_inode_lookup(dir->i_sb, IF2DT(mode), inum.no_addr,
1a0eae88 956 inum.no_formal_ino);
feaa7bba 957 if (IS_ERR(inode))
b3b94faa
DT
958 goto fail_gunlock2;
959
feaa7bba 960 error = gfs2_inode_refresh(GFS2_I(inode));
b3b94faa 961 if (error)
e1cc8603 962 goto fail_gunlock2;
b3b94faa 963
479c427d 964 error = gfs2_acl_create(dip, inode);
b3b94faa 965 if (error)
e1cc8603 966 goto fail_gunlock2;
b3b94faa 967
fcb47e0b
RH
968 error = gfs2_security_init(dip, GFS2_I(inode));
969 if (error)
e1cc8603 970 goto fail_gunlock2;
fcb47e0b 971
feaa7bba 972 error = link_dinode(dip, name, GFS2_I(inode));
b3b94faa 973 if (error)
e1cc8603 974 goto fail_gunlock2;
b3b94faa 975
f91a0d3e
SW
976 if (bh)
977 brelse(bh);
7359a19c 978 return inode;
b3b94faa 979
320dd101 980fail_gunlock2:
b3b94faa 981 gfs2_glock_dq_uninit(ghs + 1);
bd1eb881 982 if (inode && !IS_ERR(inode))
e1cc8603 983 iput(inode);
320dd101 984fail_gunlock:
b3b94faa 985 gfs2_glock_dq(ghs);
320dd101 986fail:
f91a0d3e
SW
987 if (bh)
988 brelse(bh);
7359a19c 989 return ERR_PTR(error);
b3b94faa
DT
990}
991
536baf02 992static int __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
b3b94faa 993{
1025774c 994 struct inode *inode = &ip->i_inode;
b3b94faa
DT
995 struct buffer_head *dibh;
996 int error;
997
998 error = gfs2_meta_inode_buffer(ip, &dibh);
1025774c
CH
999 if (error)
1000 return error;
1001
1002 if ((attr->ia_valid & ATTR_SIZE) &&
1003 attr->ia_size != i_size_read(inode)) {
1004 error = vmtruncate(inode, attr->ia_size);
1005 if (error)
1006 return error;
b3b94faa 1007 }
1025774c
CH
1008
1009 setattr_copy(inode, attr);
1010 mark_inode_dirty(inode);
1011
1012 gfs2_assert_warn(GFS2_SB(inode), !error);
1013 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1014 gfs2_dinode_out(ip, dibh->b_data);
1015 brelse(dibh);
1016 return 0;
b3b94faa
DT
1017}
1018
1019/**
1020 * gfs2_setattr_simple -
1021 * @ip:
1022 * @attr:
1023 *
1024 * Called with a reference on the vnode.
1025 *
1026 * Returns: errno
1027 */
1028
1029int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
1030{
1031 int error;
1032
5c676f6d 1033 if (current->journal_info)
b3b94faa
DT
1034 return __gfs2_setattr_simple(ip, attr);
1035
feaa7bba 1036 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE, 0);
b3b94faa
DT
1037 if (error)
1038 return error;
1039
1040 error = __gfs2_setattr_simple(ip, attr);
feaa7bba 1041 gfs2_trans_end(GFS2_SB(&ip->i_inode));
b3b94faa
DT
1042 return error;
1043}
1044
bb8d8a6f
SW
1045void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
1046{
bb8d8a6f
SW
1047 struct gfs2_dinode *str = buf;
1048
1049 str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
1050 str->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI);
bb8d8a6f 1051 str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI);
bb8d8a6f
SW
1052 str->di_num.no_addr = cpu_to_be64(ip->i_no_addr);
1053 str->di_num.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino);
1054 str->di_mode = cpu_to_be32(ip->i_inode.i_mode);
1055 str->di_uid = cpu_to_be32(ip->i_inode.i_uid);
1056 str->di_gid = cpu_to_be32(ip->i_inode.i_gid);
1057 str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink);
c9e98886 1058 str->di_size = cpu_to_be64(ip->i_disksize);
77658aad 1059 str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode));
bb8d8a6f
SW
1060 str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec);
1061 str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec);
1062 str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec);
1063
ce276b06
SW
1064 str->di_goal_meta = cpu_to_be64(ip->i_goal);
1065 str->di_goal_data = cpu_to_be64(ip->i_goal);
bcf0b5b3 1066 str->di_generation = cpu_to_be64(ip->i_generation);
bb8d8a6f 1067
383f01fb 1068 str->di_flags = cpu_to_be32(ip->i_diskflags);
ecc30c79 1069 str->di_height = cpu_to_be16(ip->i_height);
bb8d8a6f 1070 str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) &&
383f01fb 1071 !(ip->i_diskflags & GFS2_DIF_EXHASH) ?
bb8d8a6f 1072 GFS2_FORMAT_DE : 0);
9a004508 1073 str->di_depth = cpu_to_be16(ip->i_depth);
ad6203f2 1074 str->di_entries = cpu_to_be32(ip->i_entries);
bb8d8a6f 1075
3767ac21 1076 str->di_eattr = cpu_to_be64(ip->i_eattr);
4bd91ba1
SW
1077 str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec);
1078 str->di_mtime_nsec = cpu_to_be32(ip->i_inode.i_mtime.tv_nsec);
1079 str->di_ctime_nsec = cpu_to_be32(ip->i_inode.i_ctime.tv_nsec);
bb8d8a6f
SW
1080}
1081
1082void gfs2_dinode_print(const struct gfs2_inode *ip)
1083{
bb8d8a6f
SW
1084 printk(KERN_INFO " no_formal_ino = %llu\n",
1085 (unsigned long long)ip->i_no_formal_ino);
1086 printk(KERN_INFO " no_addr = %llu\n",
1087 (unsigned long long)ip->i_no_addr);
c9e98886
SW
1088 printk(KERN_INFO " i_disksize = %llu\n",
1089 (unsigned long long)ip->i_disksize);
77658aad
SW
1090 printk(KERN_INFO " blocks = %llu\n",
1091 (unsigned long long)gfs2_get_inode_blocks(&ip->i_inode));
ce276b06
SW
1092 printk(KERN_INFO " i_goal = %llu\n",
1093 (unsigned long long)ip->i_goal);
383f01fb 1094 printk(KERN_INFO " i_diskflags = 0x%.8X\n", ip->i_diskflags);
ca390601 1095 printk(KERN_INFO " i_height = %u\n", ip->i_height);
9a004508 1096 printk(KERN_INFO " i_depth = %u\n", ip->i_depth);
ad6203f2 1097 printk(KERN_INFO " i_entries = %u\n", ip->i_entries);
3767ac21
SW
1098 printk(KERN_INFO " i_eattr = %llu\n",
1099 (unsigned long long)ip->i_eattr);
bb8d8a6f
SW
1100}
1101