blob: f03afd9c44bc748b51811bff46ccdab3d66fa619 [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Bob Petersonca390602008-01-28 11:15:57 -06003 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00004 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
Steven Whitehousee9fc2aa2006-09-01 11:05:15 -04007 * of the GNU General Public License version 2.
David Teiglandb3b94fa2006-01-16 16:50:04 +00008 */
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>
Steven Whitehouse5c676f62006-02-27 17:23:27 -050017#include <linux/gfs2_ondisk.h>
Steven Whitehouse71b86f52006-03-28 14:14:04 -050018#include <linux/crc32.h>
Ryan O'Harafcb47e0b2006-10-03 11:57:35 -040019#include <linux/security.h>
Steven Whitehouse719ee342008-09-18 13:53:59 +010020#include <linux/time.h>
David Teiglandb3b94fa2006-01-16 16:50:04 +000021
22#include "gfs2.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050023#include "incore.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000024#include "acl.h"
25#include "bmap.h"
26#include "dir.h"
Steven Whitehouse307cf6e2009-08-26 18:51:04 +010027#include "xattr.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000028#include "glock.h"
29#include "glops.h"
30#include "inode.h"
31#include "log.h"
32#include "meta_io.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000033#include "quota.h"
34#include "rgrp.h"
35#include "trans.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050036#include "util.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000037
Steven Whitehousebb8d8a62007-06-01 14:11:58 +010038struct gfs2_inum_range_host {
39 u64 ir_start;
40 u64 ir_length;
41};
42
David Teiglandb3b94fa2006-01-16 16:50:04 +000043static int iget_test(struct inode *inode, void *opaque)
44{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040045 struct gfs2_inode *ip = GFS2_I(inode);
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010046 u64 *no_addr = opaque;
David Teiglandb3b94fa2006-01-16 16:50:04 +000047
Steven Whitehouse009d8512009-12-08 12:12:13 +000048 if (ip->i_no_addr == *no_addr)
David Teiglandb3b94fa2006-01-16 16:50:04 +000049 return 1;
50
51 return 0;
52}
53
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040054static int iget_set(struct inode *inode, void *opaque)
55{
56 struct gfs2_inode *ip = GFS2_I(inode);
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010057 u64 *no_addr = opaque;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040058
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010059 inode->i_ino = (unsigned long)*no_addr;
60 ip->i_no_addr = *no_addr;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040061 return 0;
62}
63
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010064struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr)
David Teiglandb3b94fa2006-01-16 16:50:04 +000065{
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010066 unsigned long hash = (unsigned long)no_addr;
67 return ilookup5(sb, hash, iget_test, &no_addr);
David Teiglandb3b94fa2006-01-16 16:50:04 +000068}
69
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010070static struct inode *gfs2_iget(struct super_block *sb, u64 no_addr)
David Teiglandb3b94fa2006-01-16 16:50:04 +000071{
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010072 unsigned long hash = (unsigned long)no_addr;
73 return iget5_locked(sb, hash, iget_test, iget_set, &no_addr);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040074}
75
Benjamin Marzinski7a9f53b2007-09-18 13:33:18 -050076struct 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
Steven Whitehouse009d8512009-12-08 12:12:13 +000086 if (ip->i_no_addr == data->no_addr) {
Benjamin Marzinski7a9f53b2007-09-18 13:33:18 -050087 if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)){
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
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400119/**
Wendy Cheng35dcc522007-06-27 17:07:53 -0400120 * 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 *
Christoph Hellwigeaff8072009-12-17 14:25:01 +0100126 * Clears I_NEW as well.
Wendy Cheng35dcc522007-06-27 17:07:53 -0400127 **/
128
129void gfs2_set_iop(struct inode *inode)
130{
Wendy Chengc97bfe42007-11-29 17:56:51 -0500131 struct gfs2_sbd *sdp = GFS2_SB(inode);
Wendy Cheng35dcc522007-06-27 17:07:53 -0400132 umode_t mode = inode->i_mode;
133
134 if (S_ISREG(mode)) {
135 inode->i_op = &gfs2_file_iops;
Steven Whitehousef057f6c2009-01-12 10:43:39 +0000136 if (gfs2_localflocks(sdp))
Christoph Hellwig10d21982009-04-07 19:42:17 +0200137 inode->i_fop = &gfs2_file_fops_nolock;
Wendy Chengc97bfe42007-11-29 17:56:51 -0500138 else
Christoph Hellwig10d21982009-04-07 19:42:17 +0200139 inode->i_fop = &gfs2_file_fops;
Wendy Cheng35dcc522007-06-27 17:07:53 -0400140 } else if (S_ISDIR(mode)) {
141 inode->i_op = &gfs2_dir_iops;
Steven Whitehousef057f6c2009-01-12 10:43:39 +0000142 if (gfs2_localflocks(sdp))
Christoph Hellwig10d21982009-04-07 19:42:17 +0200143 inode->i_fop = &gfs2_dir_fops_nolock;
Wendy Chengc97bfe42007-11-29 17:56:51 -0500144 else
Christoph Hellwig10d21982009-04-07 19:42:17 +0200145 inode->i_fop = &gfs2_dir_fops;
Wendy Cheng35dcc522007-06-27 17:07:53 -0400146 } else if (S_ISLNK(mode)) {
147 inode->i_op = &gfs2_symlink_iops;
148 } else {
Denis Chengd83225d2008-02-26 15:25:03 +0800149 inode->i_op = &gfs2_file_iops;
Denis Cheng43a33c52008-02-26 15:25:04 +0800150 init_special_inode(inode, inode->i_mode, inode->i_rdev);
Wendy Cheng35dcc522007-06-27 17:07:53 -0400151 }
152
153 unlock_new_inode(inode);
154}
155
156/**
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400157 * gfs2_inode_lookup - Lookup an inode
158 * @sb: The super block
Steven Whitehousedbb7cae2007-05-15 15:37:50 +0100159 * @no_addr: The inode number
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400160 * @type: The type of the inode
161 *
162 * Returns: A VFS inode, or an error
163 */
164
Bob Peterson091806ed2008-04-29 12:35:48 -0500165struct inode *gfs2_inode_lookup(struct super_block *sb,
Wendy Chengbb9bcf02007-06-27 17:07:08 -0400166 unsigned int type,
167 u64 no_addr,
Bob Peterson1a0eae82010-04-14 11:58:16 -0400168 u64 no_formal_ino)
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400169{
Benjamin Marzinski7a9f53b2007-09-18 13:33:18 -0500170 struct inode *inode;
171 struct gfs2_inode *ip;
Bob Petersonb1becbd2010-06-17 16:45:37 -0400172 struct gfs2_glock *io_gl = NULL;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400173 int error;
174
Bob Peterson1a0eae82010-04-14 11:58:16 -0400175 inode = gfs2_iget(sb, no_addr);
Benjamin Marzinski7a9f53b2007-09-18 13:33:18 -0500176 ip = GFS2_I(inode);
177
Steven Whitehouse26d83de2006-10-30 16:59:08 -0500178 if (!inode)
179 return ERR_PTR(-ENOBUFS);
180
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400181 if (inode->i_state & I_NEW) {
182 struct gfs2_sbd *sdp = GFS2_SB(inode);
Wendy Chengbb9bcf02007-06-27 17:07:08 -0400183 ip->i_no_formal_ino = no_formal_ino;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400184
Steven Whitehousedbb7cae2007-05-15 15:37:50 +0100185 error = gfs2_glock_get(sdp, no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400186 if (unlikely(error))
187 goto fail;
188 ip->i_gl->gl_object = ip;
189
Steven Whitehousedbb7cae2007-05-15 15:37:50 +0100190 error = gfs2_glock_get(sdp, no_addr, &gfs2_iopen_glops, CREATE, &io_gl);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400191 if (unlikely(error))
192 goto fail_put;
193
Steven Whitehousebfded272006-11-01 16:05:38 -0500194 set_bit(GIF_INVALID, &ip->i_flags);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400195 error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh);
196 if (unlikely(error))
197 goto fail_iopen;
Abhijith Dasd93cfa92007-06-11 08:22:32 +0100198 ip->i_iopen_gh.gh_gl->gl_object = ip;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400199
200 gfs2_glock_put(io_gl);
Bob Petersonb1becbd2010-06-17 16:45:37 -0400201 io_gl = NULL;
Steven Whitehousec8cdf472007-06-08 10:05:33 +0100202
Wendy Cheng35dcc522007-06-27 17:07:53 -0400203 if ((type == DT_UNKNOWN) && (no_formal_ino == 0))
204 goto gfs2_nfsbypass;
205
206 inode->i_mode = DT2IF(type);
207
Steven Whitehousec8cdf472007-06-08 10:05:33 +0100208 /*
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 */
Steven Whitehousec8cdf472007-06-08 10:05:33 +0100215 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 */
Steven Whitehousec8cdf472007-06-08 10:05:33 +0100221 gfs2_glock_dq_uninit(&gh);
222 }
223
Wendy Cheng35dcc522007-06-27 17:07:53 -0400224 gfs2_set_iop(inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000225 }
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400226
Wendy Cheng35dcc522007-06-27 17:07:53 -0400227gfs2_nfsbypass:
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400228 return inode;
Steven Whitehousec8cdf472007-06-08 10:05:33 +0100229fail_glock:
230 gfs2_glock_dq(&ip->i_iopen_gh);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400231fail_iopen:
Bob Petersonb1becbd2010-06-17 16:45:37 -0400232 if (io_gl)
233 gfs2_glock_put(io_gl);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400234fail_put:
Bob Peterson1a0eae82010-04-14 11:58:16 -0400235 if (inode->i_state & I_NEW)
236 ip->i_gl->gl_object = NULL;
237 gfs2_glock_put(ip->i_gl);
238fail:
239 if (inode->i_state & I_NEW)
240 iget_failed(inode);
241 else
242 iput(inode);
243 return ERR_PTR(error);
244}
245
246/**
Bob Petersoned4878e2010-05-20 23:30:11 -0400247 * 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 *
Bob Peterson1a0eae82010-04-14 11:58:16 -0400252 * @sb: The super block
253 * no_addr: The inode number
Bob Peterson1a0eae82010-04-14 11:58:16 -0400254 *
Bob Peterson1a0eae82010-04-14 11:58:16 -0400255 */
256
Bob Petersoned4878e2010-05-20 23:30:11 -0400257void gfs2_process_unlinked_inode(struct super_block *sb, u64 no_addr)
Bob Peterson1a0eae82010-04-14 11:58:16 -0400258{
259 struct gfs2_sbd *sdp;
260 struct gfs2_inode *ip;
Bob Petersonb1becbd2010-06-17 16:45:37 -0400261 struct gfs2_glock *io_gl = NULL;
Bob Peterson1a0eae82010-04-14 11:58:16 -0400262 int error;
263 struct gfs2_holder gh;
Bob Petersoned4878e2010-05-20 23:30:11 -0400264 struct inode *inode;
Bob Peterson1a0eae82010-04-14 11:58:16 -0400265
Bob Petersoned4878e2010-05-20 23:30:11 -0400266 inode = gfs2_iget_skip(sb, no_addr);
Bob Peterson1a0eae82010-04-14 11:58:16 -0400267
Bob Petersoned4878e2010-05-20 23:30:11 -0400268 if (!inode)
269 return;
Bob Peterson1a0eae82010-04-14 11:58:16 -0400270
Bob Petersoned4878e2010-05-20 23:30:11 -0400271 /* 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 }
Bob Peterson1a0eae82010-04-14 11:58:16 -0400276
Bob Petersoned4878e2010-05-20 23:30:11 -0400277 ip = GFS2_I(inode);
278 sdp = GFS2_SB(inode);
Bob Peterson1a0eae82010-04-14 11:58:16 -0400279 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);
Bob Petersoned4878e2010-05-20 23:30:11 -0400293 if (unlikely(error))
Bob Peterson1a0eae82010-04-14 11:58:16 -0400294 goto fail_iopen;
Bob Petersoned4878e2010-05-20 23:30:11 -0400295
Bob Peterson1a0eae82010-04-14 11:58:16 -0400296 ip->i_iopen_gh.gh_gl->gl_object = ip;
297 gfs2_glock_put(io_gl);
Bob Petersonb1becbd2010-06-17 16:45:37 -0400298 io_gl = NULL;
Bob Peterson1a0eae82010-04-14 11:58:16 -0400299
Bob Petersoned4878e2010-05-20 23:30:11 -0400300 inode->i_mode = DT2IF(DT_UNKNOWN);
Bob Peterson1a0eae82010-04-14 11:58:16 -0400301
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);
Bob Petersoned4878e2010-05-20 23:30:11 -0400311 if (unlikely(error))
Bob Peterson1a0eae82010-04-14 11:58:16 -0400312 goto fail_glock;
Bob Petersoned4878e2010-05-20 23:30:11 -0400313
Bob Peterson1a0eae82010-04-14 11:58:16 -0400314 /* Inode is now uptodate */
315 gfs2_glock_dq_uninit(&gh);
Bob Petersoned4878e2010-05-20 23:30:11 -0400316 gfs2_set_iop(inode);
Bob Peterson1a0eae82010-04-14 11:58:16 -0400317
Bob Petersoned4878e2010-05-20 23:30:11 -0400318 /* The iput will cause it to be deleted. */
319 iput(inode);
320 return;
321
Bob Peterson1a0eae82010-04-14 11:58:16 -0400322fail_glock:
323 gfs2_glock_dq(&ip->i_iopen_gh);
324fail_iopen:
Bob Petersonb1becbd2010-06-17 16:45:37 -0400325 if (io_gl)
326 gfs2_glock_put(io_gl);
Bob Peterson1a0eae82010-04-14 11:58:16 -0400327fail_put:
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400328 ip->i_gl->gl_object = NULL;
329 gfs2_glock_put(ip->i_gl);
330fail:
Bob Petersoned4878e2010-05-20 23:30:11 -0400331 iget_failed(inode);
332 return;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000333}
334
Steven Whitehouseaf339c02006-11-01 10:34:15 -0500335static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
Steven Whitehouseea744d02006-10-31 15:28:00 -0500336{
Steven Whitehouseea744d02006-10-31 15:28:00 -0500337 const struct gfs2_dinode *str = buf;
Steven Whitehouse719ee342008-09-18 13:53:59 +0100338 struct timespec atime;
Steven Whitehouse9a004502008-02-01 09:23:44 +0000339 u16 height, depth;
Steven Whitehouseea744d02006-10-31 15:28:00 -0500340
Steven Whitehouseecc30c72008-01-28 10:37:35 +0000341 if (unlikely(ip->i_no_addr != be64_to_cpu(str->di_num.no_addr)))
342 goto corrupt;
Steven Whitehousedbb7cae2007-05-15 15:37:50 +0100343 ip->i_no_formal_ino = be64_to_cpu(str->di_num.no_formal_ino);
Steven Whitehouseb60623c2006-11-01 12:22:46 -0500344 ip->i_inode.i_mode = be32_to_cpu(str->di_mode);
Steven Whitehousee7f14f42006-10-31 21:45:08 -0500345 ip->i_inode.i_rdev = 0;
Steven Whitehouseb60623c2006-11-01 12:22:46 -0500346 switch (ip->i_inode.i_mode & S_IFMT) {
Steven Whitehousee7f14f42006-10-31 21:45:08 -0500347 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
Steven Whitehouse2933f922006-11-01 13:23:29 -0500354 ip->i_inode.i_uid = be32_to_cpu(str->di_uid);
355 ip->i_inode.i_gid = be32_to_cpu(str->di_gid);
Steven Whitehouse4f561102006-11-01 14:04:17 -0500356 /*
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);
Steven Whitehousec9e98882008-11-04 09:47:33 +0000362 ip->i_disksize = be64_to_cpu(str->di_size);
363 i_size_write(&ip->i_inode, ip->i_disksize);
Steven Whitehouse77658aa2008-02-12 14:17:27 +0000364 gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks));
Steven Whitehouse719ee342008-09-18 13:53:59 +0100365 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;
Steven Whitehouse1a7b1ee2006-11-01 14:35:17 -0500369 ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime);
Steven Whitehouse4bd91ba2007-06-05 09:39:18 +0100370 ip->i_inode.i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec);
Steven Whitehouse1a7b1ee2006-11-01 14:35:17 -0500371 ip->i_inode.i_ctime.tv_sec = be64_to_cpu(str->di_ctime);
Steven Whitehouse4bd91ba2007-06-05 09:39:18 +0100372 ip->i_inode.i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec);
Steven Whitehouseea744d02006-10-31 15:28:00 -0500373
Steven Whitehousece276b02008-02-06 09:25:45 +0000374 ip->i_goal = be64_to_cpu(str->di_goal_meta);
Steven Whitehousebcf0b5b2008-11-03 13:39:46 +0000375 ip->i_generation = be64_to_cpu(str->di_generation);
Steven Whitehouseea744d02006-10-31 15:28:00 -0500376
Steven Whitehouse383f01f2008-11-04 10:05:22 +0000377 ip->i_diskflags = be32_to_cpu(str->di_flags);
Steven Whitehouse6b124d82006-11-08 12:51:06 -0500378 gfs2_set_inode_flags(&ip->i_inode);
Steven Whitehouseecc30c72008-01-28 10:37:35 +0000379 height = be16_to_cpu(str->di_height);
380 if (unlikely(height > GFS2_MAX_META_HEIGHT))
381 goto corrupt;
382 ip->i_height = (u8)height;
Steven Whitehouseea744d02006-10-31 15:28:00 -0500383
Steven Whitehouse9a004502008-02-01 09:23:44 +0000384 depth = be16_to_cpu(str->di_depth);
385 if (unlikely(depth > GFS2_DIR_MAX_DEPTH))
386 goto corrupt;
387 ip->i_depth = (u8)depth;
Steven Whitehousead6203f2008-11-03 13:59:19 +0000388 ip->i_entries = be32_to_cpu(str->di_entries);
Steven Whitehouseea744d02006-10-31 15:28:00 -0500389
Steven Whitehouse3767ac22008-11-03 14:28:42 +0000390 ip->i_eattr = be64_to_cpu(str->di_eattr);
Steven Whitehouse55610932007-10-17 08:47:38 +0100391 if (S_ISREG(ip->i_inode.i_mode))
392 gfs2_set_aops(&ip->i_inode);
393
Steven Whitehouseaf339c02006-11-01 10:34:15 -0500394 return 0;
Steven Whitehouseecc30c72008-01-28 10:37:35 +0000395corrupt:
396 if (gfs2_consist_inode(ip))
397 gfs2_dinode_print(ip);
398 return -EIO;
Steven Whitehouseea744d02006-10-31 15:28:00 -0500399}
400
David Teiglandb3b94fa2006-01-16 16:50:04 +0000401/**
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
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400417 if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), dibh, GFS2_METATYPE_DI)) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000418 brelse(dibh);
419 return -EIO;
420 }
421
Steven Whitehouseaf339c02006-11-01 10:34:15 -0500422 error = gfs2_dinode_in(ip, dibh->b_data);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000423 brelse(dibh);
Steven Whitehousebfded272006-11-01 16:05:38 -0500424 clear_bit(GIF_INVALID, &ip->i_flags);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000425
Steven Whitehouseaf339c02006-11-01 10:34:15 -0500426 return error;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000427}
428
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400429int gfs2_dinode_dealloc(struct gfs2_inode *ip)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000430{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400431 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000432 struct gfs2_alloc *al;
433 struct gfs2_rgrpd *rgd;
434 int error;
435
Steven Whitehouse77658aa2008-02-12 14:17:27 +0000436 if (gfs2_get_inode_blocks(&ip->i_inode) != 1) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000437 if (gfs2_consist_inode(ip))
Steven Whitehouse4cc14f02006-10-31 19:00:24 -0500438 gfs2_dinode_print(ip);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000439 return -EIO;
440 }
441
442 al = gfs2_alloc_get(ip);
Cyrill Gorcunov182fe5a2008-03-03 21:54:21 +0300443 if (!al)
444 return -ENOMEM;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000445
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
Steven Whitehousedbb7cae2007-05-15 15:37:50 +0100454 rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000455 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
Steven Whitehouse420b9e52006-07-31 15:42:17 -0400466 error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA, 1);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000467 if (error)
468 goto out_rg_gunlock;
469
Steven Whitehouse2bcd6102007-11-08 14:25:12 +0000470 set_bit(GLF_DIRTY, &ip->i_gl->gl_flags);
471 set_bit(GLF_LFLUSH, &ip->i_gl->gl_flags);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000472
473 gfs2_free_di(rgd, ip);
474
David Teiglandb3b94fa2006-01-16 16:50:04 +0000475 gfs2_trans_end(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000476
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400477out_rg_gunlock:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000478 gfs2_glock_dq_uninit(&al->al_rgd_gh);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400479out_rindex_relse:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000480 gfs2_glock_dq_uninit(&al->al_ri_gh);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400481out_qs:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000482 gfs2_quota_unhold(ip);
Steven Whitehouse36327522006-04-28 10:46:21 -0400483out:
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400484 gfs2_alloc_put(ip);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000485 return error;
486}
487
488/**
S. Wendy Cheng87d21e02007-01-18 16:07:03 -0500489 * gfs2_change_nlink - Change nlink count on inode
David Teiglandb3b94fa2006-01-16 16:50:04 +0000490 * @ip: The GFS2 inode
491 * @diff: The change in the nlink count required
492 *
493 * Returns: errno
494 */
S. Wendy Cheng87d21e02007-01-18 16:07:03 -0500495int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000496{
497 struct buffer_head *dibh;
Steven Whitehousecd915492006-09-04 12:49:07 -0400498 u32 nlink;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000499 int error;
500
Steven Whitehouse4f561102006-11-01 14:04:17 -0500501 BUG_ON(diff != 1 && diff != -1);
502 nlink = ip->i_inode.i_nlink + diff;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000503
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. */
Steven Whitehouse4f561102006-11-01 14:04:17 -0500506 if (diff < 0 && nlink > ip->i_inode.i_nlink) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000507 if (gfs2_consist_inode(ip))
Steven Whitehouse4cc14f02006-10-31 19:00:24 -0500508 gfs2_dinode_print(ip);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000509 return -EIO;
510 }
511
512 error = gfs2_meta_inode_buffer(ip, &dibh);
513 if (error)
514 return error;
515
Steven Whitehouse4f561102006-11-01 14:04:17 -0500516 if (diff > 0)
517 inc_nlink(&ip->i_inode);
518 else
519 drop_nlink(&ip->i_inode);
520
Steven Whitehouse4bd91ba2007-06-05 09:39:18 +0100521 ip->i_inode.i_ctime = CURRENT_TIME;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000522
Steven Whitehoused4e9c4c2006-01-18 11:19:28 +0000523 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
Steven Whitehouse539e5d62006-10-31 15:07:05 -0500524 gfs2_dinode_out(ip, dibh->b_data);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000525 brelse(dibh);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400526 mark_inode_dirty(&ip->i_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000527
S. Wendy Cheng87d21e02007-01-18 16:07:03 -0500528 if (ip->i_inode.i_nlink == 0)
Russell Cattelanddee7602007-01-29 17:13:44 -0600529 gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */
S. Wendy Cheng87d21e02007-01-18 16:07:03 -0500530
S. Wendy Cheng55098262007-01-18 15:56:34 -0500531 return error;
532}
533
Steven Whitehousec7526662006-03-20 12:30:04 -0500534struct inode *gfs2_lookup_simple(struct inode *dip, const char *name)
535{
536 struct qstr qstr;
Russell Cattelan6c93fd12007-01-08 17:47:51 -0600537 struct inode *inode;
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500538 gfs2_str2qstr(&qstr, name);
Al Viroa569c712008-07-23 14:42:05 -0400539 inode = gfs2_lookupi(dip, &qstr, 1);
Russell Cattelan6c93fd12007-01-08 17:47:51 -0600540 /* 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;
Steven Whitehousec7526662006-03-20 12:30:04 -0500549}
550
551
David Teiglandb3b94fa2006-01-16 16:50:04 +0000552/**
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 *
Steven Whitehoused7c103d2007-01-25 17:14:59 +0000559 * 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.
David Teiglandb3b94fa2006-01-16 16:50:04 +0000563 *
564 * Returns: errno
565 */
566
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400567struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
Al Viroa569c712008-07-23 14:42:05 -0400568 int is_root)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000569{
Steven Whitehousec9fd4302006-03-01 15:31:02 -0500570 struct super_block *sb = dir->i_sb;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400571 struct gfs2_inode *dip = GFS2_I(dir);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000572 struct gfs2_holder d_gh;
akpm@linux-foundation.org037bcbb2007-06-08 16:42:14 -0700573 int error = 0;
Steven Whitehousec7526662006-03-20 12:30:04 -0500574 struct inode *inode = NULL;
Steven Whitehoused7c103d2007-01-25 17:14:59 +0000575 int unlock = 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000576
577 if (!name->len || name->len > GFS2_FNAMESIZE)
Steven Whitehousec7526662006-03-20 12:30:04 -0500578 return ERR_PTR(-ENAMETOOLONG);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000579
Steven Whitehousec7526662006-03-20 12:30:04 -0500580 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)) {
Steven Whitehouse320dd102006-05-18 16:25:27 -0400583 igrab(dir);
584 return dir;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000585 }
586
Steven Whitehouse7afd88d2008-02-22 16:07:18 +0000587 if (gfs2_glock_is_locked_by_me(dip->i_gl) == NULL) {
Steven Whitehoused7c103d2007-01-25 17:14:59 +0000588 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 }
David Teiglandb3b94fa2006-01-16 16:50:04 +0000593
594 if (!is_root) {
Miklos Szeredif58ba882008-07-02 21:12:01 +0200595 error = gfs2_permission(dir, MAY_EXEC);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000596 if (error)
597 goto out;
598 }
599
Steven Whitehousedbb7cae2007-05-15 15:37:50 +0100600 inode = gfs2_dir_search(dir, name);
601 if (IS_ERR(inode))
602 error = PTR_ERR(inode);
Steven Whitehouse7359a192006-02-13 12:27:43 +0000603out:
Steven Whitehoused7c103d2007-01-25 17:14:59 +0000604 if (unlock)
605 gfs2_glock_dq_uninit(&d_gh);
Steven Whitehousec7526662006-03-20 12:30:04 -0500606 if (error == -ENOENT)
607 return NULL;
Steven Whitehoused7c103d2007-01-25 17:14:59 +0000608 return inode ? inode : ERR_PTR(error);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000609}
610
David Teiglandb3b94fa2006-01-16 16:50:04 +0000611/**
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
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400620static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000621 unsigned int mode)
622{
623 int error;
624
Miklos Szeredif58ba882008-07-02 21:12:01 +0200625 error = gfs2_permission(&dip->i_inode, MAY_WRITE | MAY_EXEC);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000626 if (error)
627 return error;
628
629 /* Don't create entries in an unlinked directory */
Steven Whitehouse4f561102006-11-01 14:04:17 -0500630 if (!dip->i_inode.i_nlink)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000631 return -EPERM;
632
Steven Whitehousedbb7cae2007-05-15 15:37:50 +0100633 error = gfs2_dir_check(&dip->i_inode, name, NULL);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000634 switch (error) {
635 case -ENOENT:
636 error = 0;
637 break;
638 case 0:
639 return -EEXIST;
640 default:
641 return error;
642 }
643
Steven Whitehousead6203f2008-11-03 13:59:19 +0000644 if (dip->i_entries == (u32)-1)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000645 return -EFBIG;
Steven Whitehouse4f561102006-11-01 14:04:17 -0500646 if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000647 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{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400655 if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir &&
Steven Whitehouse2933f922006-11-01 13:23:29 -0500656 (dip->i_inode.i_mode & S_ISUID) && dip->i_inode.i_uid) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000657 if (S_ISDIR(*mode))
658 *mode |= S_ISUID;
David Howells3de7be32008-11-14 10:38:53 +1100659 else if (dip->i_inode.i_uid != current_fsuid())
David Teiglandb3b94fa2006-01-16 16:50:04 +0000660 *mode &= ~07111;
Steven Whitehouse2933f922006-11-01 13:23:29 -0500661 *uid = dip->i_inode.i_uid;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000662 } else
David Howells3de7be32008-11-14 10:38:53 +1100663 *uid = current_fsuid();
David Teiglandb3b94fa2006-01-16 16:50:04 +0000664
Steven Whitehouseb60623c2006-11-01 12:22:46 -0500665 if (dip->i_inode.i_mode & S_ISGID) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000666 if (S_ISDIR(*mode))
667 *mode |= S_ISGID;
Steven Whitehouse2933f922006-11-01 13:23:29 -0500668 *gid = dip->i_inode.i_gid;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000669 } else
David Howells3de7be32008-11-14 10:38:53 +1100670 *gid = current_fsgid();
David Teiglandb3b94fa2006-01-16 16:50:04 +0000671}
672
Steven Whitehousedbb7cae2007-05-15 15:37:50 +0100673static int alloc_dinode(struct gfs2_inode *dip, u64 *no_addr, u64 *generation)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000674{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400675 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000676 int error;
677
Steven Whitehouse6dbd8222008-01-10 15:18:55 +0000678 if (gfs2_alloc_get(dip) == NULL)
679 return -ENOMEM;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000680
Steven Whitehouse6dbd8222008-01-10 15:18:55 +0000681 dip->i_alloc->al_requested = RES_DINODE;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000682 error = gfs2_inplace_reserve(dip);
683 if (error)
684 goto out;
685
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400686 error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS, 0);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000687 if (error)
688 goto out_ipreserv;
689
Steven Whitehouse6050b9c2009-07-31 16:19:40 +0100690 error = gfs2_alloc_di(dip, no_addr, generation);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000691
692 gfs2_trans_end(sdp);
693
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400694out_ipreserv:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000695 gfs2_inplace_release(dip);
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400696out:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000697 gfs2_alloc_put(dip);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000698 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,
Al Viro629a21e2006-10-13 22:51:24 -0400713 const struct gfs2_inum_host *inum, unsigned int mode,
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400714 unsigned int uid, unsigned int gid,
Wendy Chenge9bd2b32007-08-24 09:15:01 -0400715 const u64 *generation, dev_t dev, struct buffer_head **bhp)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000716{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400717 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
Steven Whitehouseb96ca4f2006-01-18 10:57:10 +0000718 struct gfs2_dinode *di;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000719 struct buffer_head *dibh;
Steven Whitehouse4bd91ba2007-06-05 09:39:18 +0100720 struct timespec tv = CURRENT_TIME;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000721
722 dibh = gfs2_meta_new(gl, inum->no_addr);
Steven Whitehoused4e9c4c2006-01-18 11:19:28 +0000723 gfs2_trans_add_bh(gl, dibh, 1);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000724 gfs2_metatype_set(dibh, GFS2_METATYPE_DI, GFS2_FORMAT_DI);
725 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
Steven Whitehouseb96ca4f2006-01-18 10:57:10 +0000726 di = (struct gfs2_dinode *)dibh->b_data;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000727
Steven Whitehouse2442a092006-01-30 11:49:32 +0000728 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);
Steven Whitehouseb96ca4f2006-01-18 10:57:10 +0000730 di->di_mode = cpu_to_be32(mode);
731 di->di_uid = cpu_to_be32(uid);
732 di->di_gid = cpu_to_be32(gid);
Steven Whitehouse294caaa2006-11-02 11:59:28 -0500733 di->di_nlink = 0;
734 di->di_size = 0;
Steven Whitehouseb96ca4f2006-01-18 10:57:10 +0000735 di->di_blocks = cpu_to_be64(1);
Steven Whitehouse4bd91ba2007-06-05 09:39:18 +0100736 di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(tv.tv_sec);
Steven Whitehousee7f14f42006-10-31 21:45:08 -0500737 di->di_major = cpu_to_be32(MAJOR(dev));
738 di->di_minor = cpu_to_be32(MINOR(dev));
Steven Whitehouseb96ca4f2006-01-18 10:57:10 +0000739 di->di_goal_meta = di->di_goal_data = cpu_to_be64(inum->no_addr);
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400740 di->di_generation = cpu_to_be64(*generation);
Steven Whitehouse294caaa2006-11-02 11:59:28 -0500741 di->di_flags = 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000742
743 if (S_ISREG(mode)) {
Steven Whitehouse383f01f2008-11-04 10:05:22 +0000744 if ((dip->i_diskflags & GFS2_DIF_INHERIT_JDATA) ||
David Teiglandb3b94fa2006-01-16 16:50:04 +0000745 gfs2_tune_get(sdp, gt_new_files_jdata))
Steven Whitehouseb96ca4f2006-01-18 10:57:10 +0000746 di->di_flags |= cpu_to_be32(GFS2_DIF_JDATA);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000747 } else if (S_ISDIR(mode)) {
Steven Whitehouse383f01f2008-11-04 10:05:22 +0000748 di->di_flags |= cpu_to_be32(dip->i_diskflags &
Steven Whitehouse568f4c92006-02-27 12:00:42 -0500749 GFS2_DIF_INHERIT_JDATA);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000750 }
751
Steven Whitehouseb96ca4f2006-01-18 10:57:10 +0000752 di->__pad1 = 0;
Steven Whitehousea9583c792006-11-01 20:09:14 -0500753 di->di_payload_format = cpu_to_be32(S_ISDIR(mode) ? GFS2_FORMAT_DE : 0);
Steven Whitehouse294caaa2006-11-02 11:59:28 -0500754 di->di_height = 0;
Steven Whitehouseb96ca4f2006-01-18 10:57:10 +0000755 di->__pad2 = 0;
756 di->__pad3 = 0;
Steven Whitehouse294caaa2006-11-02 11:59:28 -0500757 di->di_depth = 0;
758 di->di_entries = 0;
Steven Whitehouseb96ca4f2006-01-18 10:57:10 +0000759 memset(&di->__pad4, 0, sizeof(di->__pad4));
Steven Whitehouse294caaa2006-11-02 11:59:28 -0500760 di->di_eattr = 0;
Steven Whitehouse4bd91ba2007-06-05 09:39:18 +0100761 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);
Steven Whitehouseb96ca4f2006-01-18 10:57:10 +0000764 memset(&di->di_reserved, 0, sizeof(di->di_reserved));
Wendy Chenge9bd2b32007-08-24 09:15:01 -0400765
766 set_buffer_uptodate(dibh);
Steven Whitehouseb96ca4f2006-01-18 10:57:10 +0000767
Wendy Chenge9bd2b32007-08-24 09:15:01 -0400768 *bhp = dibh;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000769}
770
771static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
Al Viro629a21e2006-10-13 22:51:24 -0400772 unsigned int mode, const struct gfs2_inum_host *inum,
Wendy Chenge9bd2b32007-08-24 09:15:01 -0400773 const u64 *generation, dev_t dev, struct buffer_head **bhp)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000774{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400775 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000776 unsigned int uid, gid;
777 int error;
778
779 munge_mode_uid_gid(dip, &mode, &uid, &gid);
Cyrill Gorcunov182fe5a2008-03-03 21:54:21 +0300780 if (!gfs2_alloc_get(dip))
781 return -ENOMEM;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000782
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
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400791 error = gfs2_trans_begin(sdp, RES_DINODE + RES_QUOTA, 0);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000792 if (error)
793 goto out_quota;
794
Wendy Chenge9bd2b32007-08-24 09:15:01 -0400795 init_dinode(dip, gl, inum, mode, uid, gid, generation, dev, bhp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000796 gfs2_quota_change(dip, +1, uid, gid);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000797 gfs2_trans_end(sdp);
798
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400799out_quota:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000800 gfs2_quota_unlock(dip);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400801out:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000802 gfs2_alloc_put(dip);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000803 return error;
804}
805
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400806static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
807 struct gfs2_inode *ip)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000808{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400809 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000810 struct gfs2_alloc *al;
811 int alloc_required;
812 struct buffer_head *dibh;
813 int error;
814
815 al = gfs2_alloc_get(dip);
Cyrill Gorcunov182fe5a2008-03-03 21:54:21 +0300816 if (!al)
817 return -ENOMEM;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000818
819 error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
820 if (error)
821 goto fail;
822
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400823 error = alloc_required = gfs2_diradd_alloc_required(&dip->i_inode, name);
Steven Whitehousec7526662006-03-20 12:30:04 -0500824 if (alloc_required < 0)
Bob Peterson1b8177e2008-01-19 21:50:24 -0600825 goto fail_quota_locks;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000826 if (alloc_required) {
Steven Whitehouse2933f922006-11-01 13:23:29 -0500827 error = gfs2_quota_check(dip, dip->i_inode.i_uid, dip->i_inode.i_gid);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000828 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
Steven Whitehouse320dd102006-05-18 16:25:27 -0400837 error = gfs2_trans_begin(sdp, sdp->sd_max_dirres +
Steven Whitehousebb8d8a62007-06-01 14:11:58 +0100838 al->al_rgd->rd_length +
Steven Whitehouse907b9bc2006-09-25 09:26:04 -0400839 2 * RES_DINODE +
David Teiglandb3b94fa2006-01-16 16:50:04 +0000840 RES_STATFS + RES_QUOTA, 0);
841 if (error)
842 goto fail_ipreserv;
843 } else {
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400844 error = gfs2_trans_begin(sdp, RES_LEAF + 2 * RES_DINODE, 0);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000845 if (error)
846 goto fail_quota_locks;
847 }
848
Steven Whitehousedbb7cae2007-05-15 15:37:50 +0100849 error = gfs2_dir_add(&dip->i_inode, name, ip, IF2DT(ip->i_inode.i_mode));
David Teiglandb3b94fa2006-01-16 16:50:04 +0000850 if (error)
851 goto fail_end_trans;
852
853 error = gfs2_meta_inode_buffer(ip, &dibh);
854 if (error)
855 goto fail_end_trans;
Steven Whitehouse4f561102006-11-01 14:04:17 -0500856 ip->i_inode.i_nlink = 1;
Steven Whitehoused4e9c4c2006-01-18 11:19:28 +0000857 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
Steven Whitehouse539e5d62006-10-31 15:07:05 -0500858 gfs2_dinode_out(ip, dibh->b_data);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000859 brelse(dibh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000860 return 0;
861
Steven Whitehouse320dd102006-05-18 16:25:27 -0400862fail_end_trans:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000863 gfs2_trans_end(sdp);
864
Steven Whitehouse320dd102006-05-18 16:25:27 -0400865fail_ipreserv:
Steven Whitehouse6dbd8222008-01-10 15:18:55 +0000866 if (dip->i_alloc->al_rgd)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000867 gfs2_inplace_release(dip);
868
Steven Whitehouse320dd102006-05-18 16:25:27 -0400869fail_quota_locks:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000870 gfs2_quota_unlock(dip);
871
Steven Whitehouse320dd102006-05-18 16:25:27 -0400872fail:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000873 gfs2_alloc_put(dip);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000874 return error;
875}
876
Ryan O'Harafcb47e0b2006-10-03 11:57:35 -0400877static 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;
Ryan O'Harafcb47e0b2006-10-03 11:57:35 -0400883
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
Christoph Hellwig431547b2009-11-13 09:52:56 +0000893 err = __gfs2_xattr_set(&ip->i_inode, name, value, len, 0,
894 GFS2_EATYPE_SECURITY);
Ryan O'Harafcb47e0b2006-10-03 11:57:35 -0400895 kfree(value);
896 kfree(name);
897
898 return err;
899}
900
David Teiglandb3b94fa2006-01-16 16:50:04 +0000901/**
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 *
Steven Whitehouse7359a192006-02-13 12:27:43 +0000910 * If the return value is not NULL, the glocks on both the directory and the new
David Teiglandb3b94fa2006-01-16 16:50:04 +0000911 * file are held. A transaction has been started and an inplace reservation
912 * is held, as well.
913 *
Steven Whitehouse7359a192006-02-13 12:27:43 +0000914 * Returns: An inode
David Teiglandb3b94fa2006-01-16 16:50:04 +0000915 */
916
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400917struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
Steven Whitehousee7f14f42006-10-31 21:45:08 -0500918 unsigned int mode, dev_t dev)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000919{
Steven Whitehousee1cc8602007-06-07 11:47:52 +0100920 struct inode *inode = NULL;
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500921 struct gfs2_inode *dip = ghs->gh_gl->gl_object;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400922 struct inode *dir = &dip->i_inode;
923 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
Steven Whitehousedbb7cae2007-05-15 15:37:50 +0100924 struct gfs2_inum_host inum = { .no_addr = 0, .no_formal_ino = 0 };
David Teiglandb3b94fa2006-01-16 16:50:04 +0000925 int error;
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400926 u64 generation;
Steven Whitehousef91a0d32007-10-15 16:29:05 +0100927 struct buffer_head *bh = NULL;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000928
929 if (!name->len || name->len > GFS2_FNAMESIZE)
Steven Whitehouse7359a192006-02-13 12:27:43 +0000930 return ERR_PTR(-ENAMETOOLONG);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000931
David Teiglandb3b94fa2006-01-16 16:50:04 +0000932 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
Steven Whitehousedbb7cae2007-05-15 15:37:50 +0100941 error = alloc_dinode(dip, &inum.no_addr, &generation);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000942 if (error)
943 goto fail_gunlock;
Steven Whitehouse8d8291a2009-08-27 15:51:07 +0100944 inum.no_formal_ino = generation;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000945
Steven Whitehouse28626e22006-11-22 11:13:21 -0500946 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;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000950
Wendy Chenge9bd2b32007-08-24 09:15:01 -0400951 error = make_dinode(dip, ghs[1].gh_gl, mode, &inum, &generation, dev, &bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000952 if (error)
953 goto fail_gunlock2;
954
Steven Whitehouse8d8291a2009-08-27 15:51:07 +0100955 inode = gfs2_inode_lookup(dir->i_sb, IF2DT(mode), inum.no_addr,
Bob Peterson1a0eae82010-04-14 11:58:16 -0400956 inum.no_formal_ino);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400957 if (IS_ERR(inode))
David Teiglandb3b94fa2006-01-16 16:50:04 +0000958 goto fail_gunlock2;
959
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400960 error = gfs2_inode_refresh(GFS2_I(inode));
David Teiglandb3b94fa2006-01-16 16:50:04 +0000961 if (error)
Steven Whitehousee1cc8602007-06-07 11:47:52 +0100962 goto fail_gunlock2;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000963
Steven Whitehouse479c4272009-10-02 12:00:00 +0100964 error = gfs2_acl_create(dip, inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000965 if (error)
Steven Whitehousee1cc8602007-06-07 11:47:52 +0100966 goto fail_gunlock2;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000967
Ryan O'Harafcb47e0b2006-10-03 11:57:35 -0400968 error = gfs2_security_init(dip, GFS2_I(inode));
969 if (error)
Steven Whitehousee1cc8602007-06-07 11:47:52 +0100970 goto fail_gunlock2;
Ryan O'Harafcb47e0b2006-10-03 11:57:35 -0400971
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400972 error = link_dinode(dip, name, GFS2_I(inode));
David Teiglandb3b94fa2006-01-16 16:50:04 +0000973 if (error)
Steven Whitehousee1cc8602007-06-07 11:47:52 +0100974 goto fail_gunlock2;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000975
Steven Whitehousef91a0d32007-10-15 16:29:05 +0100976 if (bh)
977 brelse(bh);
Steven Whitehouse7359a192006-02-13 12:27:43 +0000978 return inode;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000979
Steven Whitehouse320dd102006-05-18 16:25:27 -0400980fail_gunlock2:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000981 gfs2_glock_dq_uninit(ghs + 1);
Julien Brunelbd1eb882008-09-01 10:51:22 +0200982 if (inode && !IS_ERR(inode))
Steven Whitehousee1cc8602007-06-07 11:47:52 +0100983 iput(inode);
Steven Whitehouse320dd102006-05-18 16:25:27 -0400984fail_gunlock:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000985 gfs2_glock_dq(ghs);
Steven Whitehouse320dd102006-05-18 16:25:27 -0400986fail:
Steven Whitehousef91a0d32007-10-15 16:29:05 +0100987 if (bh)
988 brelse(bh);
Steven Whitehouse7359a192006-02-13 12:27:43 +0000989 return ERR_PTR(error);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000990}
991
Steven Whitehouse536baf02009-05-22 10:48:59 +0100992static int __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000993{
994 struct buffer_head *dibh;
995 int error;
996
997 error = gfs2_meta_inode_buffer(ip, &dibh);
998 if (!error) {
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400999 error = inode_setattr(&ip->i_inode, attr);
1000 gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error);
Steven Whitehoused4e9c4c2006-01-18 11:19:28 +00001001 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
Steven Whitehouse539e5d62006-10-31 15:07:05 -05001002 gfs2_dinode_out(ip, dibh->b_data);
David Teiglandb3b94fa2006-01-16 16:50:04 +00001003 brelse(dibh);
1004 }
1005 return error;
1006}
1007
1008/**
1009 * gfs2_setattr_simple -
1010 * @ip:
1011 * @attr:
1012 *
1013 * Called with a reference on the vnode.
1014 *
1015 * Returns: errno
1016 */
1017
1018int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
1019{
1020 int error;
1021
Steven Whitehouse5c676f62006-02-27 17:23:27 -05001022 if (current->journal_info)
David Teiglandb3b94fa2006-01-16 16:50:04 +00001023 return __gfs2_setattr_simple(ip, attr);
1024
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -04001025 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE, 0);
David Teiglandb3b94fa2006-01-16 16:50:04 +00001026 if (error)
1027 return error;
1028
1029 error = __gfs2_setattr_simple(ip, attr);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -04001030 gfs2_trans_end(GFS2_SB(&ip->i_inode));
David Teiglandb3b94fa2006-01-16 16:50:04 +00001031 return error;
1032}
1033
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001034void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
1035{
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001036 struct gfs2_dinode *str = buf;
1037
1038 str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
1039 str->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI);
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001040 str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI);
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001041 str->di_num.no_addr = cpu_to_be64(ip->i_no_addr);
1042 str->di_num.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino);
1043 str->di_mode = cpu_to_be32(ip->i_inode.i_mode);
1044 str->di_uid = cpu_to_be32(ip->i_inode.i_uid);
1045 str->di_gid = cpu_to_be32(ip->i_inode.i_gid);
1046 str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink);
Steven Whitehousec9e98882008-11-04 09:47:33 +00001047 str->di_size = cpu_to_be64(ip->i_disksize);
Steven Whitehouse77658aa2008-02-12 14:17:27 +00001048 str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode));
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001049 str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec);
1050 str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec);
1051 str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec);
1052
Steven Whitehousece276b02008-02-06 09:25:45 +00001053 str->di_goal_meta = cpu_to_be64(ip->i_goal);
1054 str->di_goal_data = cpu_to_be64(ip->i_goal);
Steven Whitehousebcf0b5b2008-11-03 13:39:46 +00001055 str->di_generation = cpu_to_be64(ip->i_generation);
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001056
Steven Whitehouse383f01f2008-11-04 10:05:22 +00001057 str->di_flags = cpu_to_be32(ip->i_diskflags);
Steven Whitehouseecc30c72008-01-28 10:37:35 +00001058 str->di_height = cpu_to_be16(ip->i_height);
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001059 str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) &&
Steven Whitehouse383f01f2008-11-04 10:05:22 +00001060 !(ip->i_diskflags & GFS2_DIF_EXHASH) ?
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001061 GFS2_FORMAT_DE : 0);
Steven Whitehouse9a004502008-02-01 09:23:44 +00001062 str->di_depth = cpu_to_be16(ip->i_depth);
Steven Whitehousead6203f2008-11-03 13:59:19 +00001063 str->di_entries = cpu_to_be32(ip->i_entries);
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001064
Steven Whitehouse3767ac22008-11-03 14:28:42 +00001065 str->di_eattr = cpu_to_be64(ip->i_eattr);
Steven Whitehouse4bd91ba2007-06-05 09:39:18 +01001066 str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec);
1067 str->di_mtime_nsec = cpu_to_be32(ip->i_inode.i_mtime.tv_nsec);
1068 str->di_ctime_nsec = cpu_to_be32(ip->i_inode.i_ctime.tv_nsec);
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001069}
1070
1071void gfs2_dinode_print(const struct gfs2_inode *ip)
1072{
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001073 printk(KERN_INFO " no_formal_ino = %llu\n",
1074 (unsigned long long)ip->i_no_formal_ino);
1075 printk(KERN_INFO " no_addr = %llu\n",
1076 (unsigned long long)ip->i_no_addr);
Steven Whitehousec9e98882008-11-04 09:47:33 +00001077 printk(KERN_INFO " i_disksize = %llu\n",
1078 (unsigned long long)ip->i_disksize);
Steven Whitehouse77658aa2008-02-12 14:17:27 +00001079 printk(KERN_INFO " blocks = %llu\n",
1080 (unsigned long long)gfs2_get_inode_blocks(&ip->i_inode));
Steven Whitehousece276b02008-02-06 09:25:45 +00001081 printk(KERN_INFO " i_goal = %llu\n",
1082 (unsigned long long)ip->i_goal);
Steven Whitehouse383f01f2008-11-04 10:05:22 +00001083 printk(KERN_INFO " i_diskflags = 0x%.8X\n", ip->i_diskflags);
Bob Petersonca390602008-01-28 11:15:57 -06001084 printk(KERN_INFO " i_height = %u\n", ip->i_height);
Steven Whitehouse9a004502008-02-01 09:23:44 +00001085 printk(KERN_INFO " i_depth = %u\n", ip->i_depth);
Steven Whitehousead6203f2008-11-03 13:59:19 +00001086 printk(KERN_INFO " i_entries = %u\n", ip->i_entries);
Steven Whitehouse3767ac22008-11-03 14:28:42 +00001087 printk(KERN_INFO " i_eattr = %llu\n",
1088 (unsigned long long)ip->i_eattr);
Steven Whitehousebb8d8a62007-06-01 14:11:58 +01001089}
1090