David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
Bob Peterson | ca39060 | 2008-01-28 11:15:57 -0600 | [diff] [blame] | 3 | * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 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 |
Steven Whitehouse | e9fc2aa | 2006-09-01 11:05:15 -0400 | [diff] [blame] | 7 | * of the GNU General Public License version 2. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 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> |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 17 | #include <linux/gfs2_ondisk.h> |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 18 | #include <linux/crc32.h> |
Ryan O'Hara | fcb47e0b | 2006-10-03 11:57:35 -0400 | [diff] [blame] | 19 | #include <linux/security.h> |
Steven Whitehouse | 719ee34 | 2008-09-18 13:53:59 +0100 | [diff] [blame] | 20 | #include <linux/time.h> |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 21 | |
| 22 | #include "gfs2.h" |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 23 | #include "incore.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 24 | #include "acl.h" |
| 25 | #include "bmap.h" |
| 26 | #include "dir.h" |
Steven Whitehouse | 307cf6e | 2009-08-26 18:51:04 +0100 | [diff] [blame] | 27 | #include "xattr.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 28 | #include "glock.h" |
| 29 | #include "glops.h" |
| 30 | #include "inode.h" |
| 31 | #include "log.h" |
| 32 | #include "meta_io.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 33 | #include "quota.h" |
| 34 | #include "rgrp.h" |
| 35 | #include "trans.h" |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 36 | #include "util.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 37 | |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 38 | struct gfs2_inum_range_host { |
| 39 | u64 ir_start; |
| 40 | u64 ir_length; |
| 41 | }; |
| 42 | |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 43 | struct gfs2_skip_data { |
| 44 | u64 no_addr; |
| 45 | int skipped; |
| 46 | int non_block; |
| 47 | }; |
| 48 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 49 | static int iget_test(struct inode *inode, void *opaque) |
| 50 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 51 | struct gfs2_inode *ip = GFS2_I(inode); |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 52 | struct gfs2_skip_data *data = opaque; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 53 | |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 54 | if (ip->i_no_addr == data->no_addr) { |
| 55 | if (data->non_block && |
| 56 | inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) { |
| 57 | data->skipped = 1; |
| 58 | return 0; |
| 59 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 60 | return 1; |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 61 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 62 | return 0; |
| 63 | } |
| 64 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 65 | static int iget_set(struct inode *inode, void *opaque) |
| 66 | { |
| 67 | struct gfs2_inode *ip = GFS2_I(inode); |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 68 | struct gfs2_skip_data *data = opaque; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 69 | |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 70 | if (data->skipped) |
| 71 | return -ENOENT; |
| 72 | inode->i_ino = (unsigned long)(data->no_addr); |
| 73 | ip->i_no_addr = data->no_addr; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 77 | struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 78 | { |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 79 | unsigned long hash = (unsigned long)no_addr; |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 80 | struct gfs2_skip_data data; |
| 81 | |
| 82 | data.no_addr = no_addr; |
| 83 | data.skipped = 0; |
| 84 | data.non_block = 0; |
| 85 | return ilookup5(sb, hash, iget_test, &data); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 88 | static struct inode *gfs2_iget(struct super_block *sb, u64 no_addr, |
| 89 | int non_block) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 90 | { |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 91 | struct gfs2_skip_data data; |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 92 | unsigned long hash = (unsigned long)no_addr; |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 93 | |
| 94 | data.no_addr = no_addr; |
| 95 | data.skipped = 0; |
| 96 | data.non_block = non_block; |
| 97 | return iget5_locked(sb, hash, iget_test, iget_set, &data); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | /** |
Steven Whitehouse | 24d9765 | 2011-01-18 14:49:08 +0000 | [diff] [blame] | 101 | * gfs2_set_iop - Sets inode operations |
| 102 | * @inode: The inode with correct i_mode filled in |
Wendy Cheng | 35dcc52 | 2007-06-27 17:07:53 -0400 | [diff] [blame] | 103 | * |
Steven Whitehouse | 24d9765 | 2011-01-18 14:49:08 +0000 | [diff] [blame] | 104 | * GFS2 lookup code fills in vfs inode contents based on info obtained |
| 105 | * from directory entry inside gfs2_inode_lookup(). |
| 106 | */ |
Wendy Cheng | 35dcc52 | 2007-06-27 17:07:53 -0400 | [diff] [blame] | 107 | |
Steven Whitehouse | 24d9765 | 2011-01-18 14:49:08 +0000 | [diff] [blame] | 108 | static void gfs2_set_iop(struct inode *inode) |
Wendy Cheng | 35dcc52 | 2007-06-27 17:07:53 -0400 | [diff] [blame] | 109 | { |
Wendy Cheng | c97bfe4 | 2007-11-29 17:56:51 -0500 | [diff] [blame] | 110 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
Wendy Cheng | 35dcc52 | 2007-06-27 17:07:53 -0400 | [diff] [blame] | 111 | umode_t mode = inode->i_mode; |
| 112 | |
| 113 | if (S_ISREG(mode)) { |
| 114 | inode->i_op = &gfs2_file_iops; |
Steven Whitehouse | f057f6c | 2009-01-12 10:43:39 +0000 | [diff] [blame] | 115 | if (gfs2_localflocks(sdp)) |
Christoph Hellwig | 10d2198 | 2009-04-07 19:42:17 +0200 | [diff] [blame] | 116 | inode->i_fop = &gfs2_file_fops_nolock; |
Wendy Cheng | c97bfe4 | 2007-11-29 17:56:51 -0500 | [diff] [blame] | 117 | else |
Christoph Hellwig | 10d2198 | 2009-04-07 19:42:17 +0200 | [diff] [blame] | 118 | inode->i_fop = &gfs2_file_fops; |
Wendy Cheng | 35dcc52 | 2007-06-27 17:07:53 -0400 | [diff] [blame] | 119 | } else if (S_ISDIR(mode)) { |
| 120 | inode->i_op = &gfs2_dir_iops; |
Steven Whitehouse | f057f6c | 2009-01-12 10:43:39 +0000 | [diff] [blame] | 121 | if (gfs2_localflocks(sdp)) |
Christoph Hellwig | 10d2198 | 2009-04-07 19:42:17 +0200 | [diff] [blame] | 122 | inode->i_fop = &gfs2_dir_fops_nolock; |
Wendy Cheng | c97bfe4 | 2007-11-29 17:56:51 -0500 | [diff] [blame] | 123 | else |
Christoph Hellwig | 10d2198 | 2009-04-07 19:42:17 +0200 | [diff] [blame] | 124 | inode->i_fop = &gfs2_dir_fops; |
Wendy Cheng | 35dcc52 | 2007-06-27 17:07:53 -0400 | [diff] [blame] | 125 | } else if (S_ISLNK(mode)) { |
| 126 | inode->i_op = &gfs2_symlink_iops; |
| 127 | } else { |
Denis Cheng | d83225d | 2008-02-26 15:25:03 +0800 | [diff] [blame] | 128 | inode->i_op = &gfs2_file_iops; |
Denis Cheng | 43a33c5 | 2008-02-26 15:25:04 +0800 | [diff] [blame] | 129 | init_special_inode(inode, inode->i_mode, inode->i_rdev); |
Wendy Cheng | 35dcc52 | 2007-06-27 17:07:53 -0400 | [diff] [blame] | 130 | } |
Wendy Cheng | 35dcc52 | 2007-06-27 17:07:53 -0400 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | /** |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 134 | * gfs2_inode_lookup - Lookup an inode |
| 135 | * @sb: The super block |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 136 | * @no_addr: The inode number |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 137 | * @type: The type of the inode |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 138 | * non_block: Can we block on inodes that are being freed? |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 139 | * |
| 140 | * Returns: A VFS inode, or an error |
| 141 | */ |
| 142 | |
Steven Whitehouse | 24d9765 | 2011-01-18 14:49:08 +0000 | [diff] [blame] | 143 | struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type, |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 144 | u64 no_addr, u64 no_formal_ino, int non_block) |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 145 | { |
Benjamin Marzinski | 7a9f53b | 2007-09-18 13:33:18 -0500 | [diff] [blame] | 146 | struct inode *inode; |
| 147 | struct gfs2_inode *ip; |
Bob Peterson | b1becbd | 2010-06-17 16:45:37 -0400 | [diff] [blame] | 148 | struct gfs2_glock *io_gl = NULL; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 149 | int error; |
| 150 | |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 151 | inode = gfs2_iget(sb, no_addr, non_block); |
Benjamin Marzinski | 7a9f53b | 2007-09-18 13:33:18 -0500 | [diff] [blame] | 152 | ip = GFS2_I(inode); |
| 153 | |
Steven Whitehouse | 26d83de | 2006-10-30 16:59:08 -0500 | [diff] [blame] | 154 | if (!inode) |
| 155 | return ERR_PTR(-ENOBUFS); |
| 156 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 157 | if (inode->i_state & I_NEW) { |
| 158 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
Wendy Cheng | bb9bcf0 | 2007-06-27 17:07:08 -0400 | [diff] [blame] | 159 | ip->i_no_formal_ino = no_formal_ino; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 160 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 161 | error = gfs2_glock_get(sdp, no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 162 | if (unlikely(error)) |
| 163 | goto fail; |
| 164 | ip->i_gl->gl_object = ip; |
| 165 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 166 | error = gfs2_glock_get(sdp, no_addr, &gfs2_iopen_glops, CREATE, &io_gl); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 167 | if (unlikely(error)) |
| 168 | goto fail_put; |
| 169 | |
Steven Whitehouse | bfded27 | 2006-11-01 16:05:38 -0500 | [diff] [blame] | 170 | set_bit(GIF_INVALID, &ip->i_flags); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 171 | error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh); |
| 172 | if (unlikely(error)) |
| 173 | goto fail_iopen; |
| 174 | |
Steven Whitehouse | 24d9765 | 2011-01-18 14:49:08 +0000 | [diff] [blame] | 175 | ip->i_iopen_gh.gh_gl->gl_object = ip; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 176 | gfs2_glock_put(io_gl); |
Bob Peterson | b1becbd | 2010-06-17 16:45:37 -0400 | [diff] [blame] | 177 | io_gl = NULL; |
Steven Whitehouse | c8cdf47 | 2007-06-08 10:05:33 +0100 | [diff] [blame] | 178 | |
Steven Whitehouse | c8cdf47 | 2007-06-08 10:05:33 +0100 | [diff] [blame] | 179 | if (type == DT_UNKNOWN) { |
Steven Whitehouse | 24d9765 | 2011-01-18 14:49:08 +0000 | [diff] [blame] | 180 | /* Inode glock must be locked already */ |
| 181 | error = gfs2_inode_refresh(GFS2_I(inode)); |
| 182 | if (error) |
| 183 | goto fail_refresh; |
| 184 | } else { |
| 185 | inode->i_mode = DT2IF(type); |
Steven Whitehouse | c8cdf47 | 2007-06-08 10:05:33 +0100 | [diff] [blame] | 186 | } |
| 187 | |
Wendy Cheng | 35dcc52 | 2007-06-27 17:07:53 -0400 | [diff] [blame] | 188 | gfs2_set_iop(inode); |
Steven Whitehouse | 24d9765 | 2011-01-18 14:49:08 +0000 | [diff] [blame] | 189 | unlock_new_inode(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 190 | } |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 191 | |
| 192 | return inode; |
Steven Whitehouse | 24d9765 | 2011-01-18 14:49:08 +0000 | [diff] [blame] | 193 | |
| 194 | fail_refresh: |
| 195 | ip->i_iopen_gh.gh_gl->gl_object = NULL; |
| 196 | gfs2_glock_dq_uninit(&ip->i_iopen_gh); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 197 | fail_iopen: |
Bob Peterson | b1becbd | 2010-06-17 16:45:37 -0400 | [diff] [blame] | 198 | if (io_gl) |
| 199 | gfs2_glock_put(io_gl); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 200 | fail_put: |
Steven Whitehouse | 24d9765 | 2011-01-18 14:49:08 +0000 | [diff] [blame] | 201 | ip->i_gl->gl_object = NULL; |
Bob Peterson | 1a0eae8 | 2010-04-14 11:58:16 -0400 | [diff] [blame] | 202 | gfs2_glock_put(ip->i_gl); |
| 203 | fail: |
Steven Whitehouse | 24d9765 | 2011-01-18 14:49:08 +0000 | [diff] [blame] | 204 | iget_failed(inode); |
Bob Peterson | 1a0eae8 | 2010-04-14 11:58:16 -0400 | [diff] [blame] | 205 | return ERR_PTR(error); |
| 206 | } |
| 207 | |
Steven Whitehouse | 044b941 | 2010-11-03 20:01:07 +0000 | [diff] [blame] | 208 | struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr, |
| 209 | u64 *no_formal_ino, unsigned int blktype) |
Bob Peterson | 1a0eae8 | 2010-04-14 11:58:16 -0400 | [diff] [blame] | 210 | { |
Steven Whitehouse | 044b941 | 2010-11-03 20:01:07 +0000 | [diff] [blame] | 211 | struct super_block *sb = sdp->sd_vfs; |
| 212 | struct gfs2_holder i_gh; |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 213 | struct inode *inode = NULL; |
Steven Whitehouse | 044b941 | 2010-11-03 20:01:07 +0000 | [diff] [blame] | 214 | int error; |
Bob Peterson | 1a0eae8 | 2010-04-14 11:58:16 -0400 | [diff] [blame] | 215 | |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 216 | /* Must not read in block until block type is verified */ |
Steven Whitehouse | 044b941 | 2010-11-03 20:01:07 +0000 | [diff] [blame] | 217 | error = gfs2_glock_nq_num(sdp, no_addr, &gfs2_inode_glops, |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 218 | LM_ST_EXCLUSIVE, GL_SKIP, &i_gh); |
Steven Whitehouse | 044b941 | 2010-11-03 20:01:07 +0000 | [diff] [blame] | 219 | if (error) |
| 220 | return ERR_PTR(error); |
Bob Peterson | 1a0eae8 | 2010-04-14 11:58:16 -0400 | [diff] [blame] | 221 | |
Steven Whitehouse | 044b941 | 2010-11-03 20:01:07 +0000 | [diff] [blame] | 222 | error = gfs2_check_blk_type(sdp, no_addr, blktype); |
| 223 | if (error) |
| 224 | goto fail; |
Bob Peterson | 1a0eae8 | 2010-04-14 11:58:16 -0400 | [diff] [blame] | 225 | |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 226 | inode = gfs2_inode_lookup(sb, DT_UNKNOWN, no_addr, 0, 1); |
Steven Whitehouse | 044b941 | 2010-11-03 20:01:07 +0000 | [diff] [blame] | 227 | if (IS_ERR(inode)) |
| 228 | goto fail; |
| 229 | |
Steven Whitehouse | 044b941 | 2010-11-03 20:01:07 +0000 | [diff] [blame] | 230 | /* Two extra checks for NFS only */ |
| 231 | if (no_formal_ino) { |
| 232 | error = -ESTALE; |
| 233 | if (GFS2_I(inode)->i_no_formal_ino != *no_formal_ino) |
| 234 | goto fail_iput; |
| 235 | |
| 236 | error = -EIO; |
| 237 | if (GFS2_I(inode)->i_diskflags & GFS2_DIF_SYSTEM) |
| 238 | goto fail_iput; |
| 239 | |
| 240 | error = 0; |
Bob Peterson | ed4878e | 2010-05-20 23:30:11 -0400 | [diff] [blame] | 241 | } |
Bob Peterson | 1a0eae8 | 2010-04-14 11:58:16 -0400 | [diff] [blame] | 242 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 243 | fail: |
Steven Whitehouse | 044b941 | 2010-11-03 20:01:07 +0000 | [diff] [blame] | 244 | gfs2_glock_dq_uninit(&i_gh); |
| 245 | return error ? ERR_PTR(error) : inode; |
| 246 | fail_iput: |
| 247 | iput(inode); |
| 248 | goto fail; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 249 | } |
| 250 | |
Steven Whitehouse | af339c0 | 2006-11-01 10:34:15 -0500 | [diff] [blame] | 251 | static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) |
Steven Whitehouse | ea744d0 | 2006-10-31 15:28:00 -0500 | [diff] [blame] | 252 | { |
Steven Whitehouse | ea744d0 | 2006-10-31 15:28:00 -0500 | [diff] [blame] | 253 | const struct gfs2_dinode *str = buf; |
Steven Whitehouse | 719ee34 | 2008-09-18 13:53:59 +0100 | [diff] [blame] | 254 | struct timespec atime; |
Steven Whitehouse | 9a00450 | 2008-02-01 09:23:44 +0000 | [diff] [blame] | 255 | u16 height, depth; |
Steven Whitehouse | ea744d0 | 2006-10-31 15:28:00 -0500 | [diff] [blame] | 256 | |
Steven Whitehouse | ecc30c7 | 2008-01-28 10:37:35 +0000 | [diff] [blame] | 257 | if (unlikely(ip->i_no_addr != be64_to_cpu(str->di_num.no_addr))) |
| 258 | goto corrupt; |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 259 | ip->i_no_formal_ino = be64_to_cpu(str->di_num.no_formal_ino); |
Steven Whitehouse | b60623c | 2006-11-01 12:22:46 -0500 | [diff] [blame] | 260 | ip->i_inode.i_mode = be32_to_cpu(str->di_mode); |
Steven Whitehouse | e7f14f4 | 2006-10-31 21:45:08 -0500 | [diff] [blame] | 261 | ip->i_inode.i_rdev = 0; |
Steven Whitehouse | b60623c | 2006-11-01 12:22:46 -0500 | [diff] [blame] | 262 | switch (ip->i_inode.i_mode & S_IFMT) { |
Steven Whitehouse | e7f14f4 | 2006-10-31 21:45:08 -0500 | [diff] [blame] | 263 | case S_IFBLK: |
| 264 | case S_IFCHR: |
| 265 | ip->i_inode.i_rdev = MKDEV(be32_to_cpu(str->di_major), |
| 266 | be32_to_cpu(str->di_minor)); |
| 267 | break; |
| 268 | }; |
| 269 | |
Steven Whitehouse | 2933f92 | 2006-11-01 13:23:29 -0500 | [diff] [blame] | 270 | ip->i_inode.i_uid = be32_to_cpu(str->di_uid); |
| 271 | ip->i_inode.i_gid = be32_to_cpu(str->di_gid); |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 272 | /* |
| 273 | * We will need to review setting the nlink count here in the |
| 274 | * light of the forthcoming ro bind mount work. This is a reminder |
| 275 | * to do that. |
| 276 | */ |
| 277 | ip->i_inode.i_nlink = be32_to_cpu(str->di_nlink); |
Steven Whitehouse | a2e0f79 | 2010-08-11 09:53:11 +0100 | [diff] [blame] | 278 | i_size_write(&ip->i_inode, be64_to_cpu(str->di_size)); |
Steven Whitehouse | 77658aa | 2008-02-12 14:17:27 +0000 | [diff] [blame] | 279 | gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks)); |
Steven Whitehouse | 719ee34 | 2008-09-18 13:53:59 +0100 | [diff] [blame] | 280 | atime.tv_sec = be64_to_cpu(str->di_atime); |
| 281 | atime.tv_nsec = be32_to_cpu(str->di_atime_nsec); |
| 282 | if (timespec_compare(&ip->i_inode.i_atime, &atime) < 0) |
| 283 | ip->i_inode.i_atime = atime; |
Steven Whitehouse | 1a7b1ee | 2006-11-01 14:35:17 -0500 | [diff] [blame] | 284 | ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime); |
Steven Whitehouse | 4bd91ba | 2007-06-05 09:39:18 +0100 | [diff] [blame] | 285 | ip->i_inode.i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec); |
Steven Whitehouse | 1a7b1ee | 2006-11-01 14:35:17 -0500 | [diff] [blame] | 286 | ip->i_inode.i_ctime.tv_sec = be64_to_cpu(str->di_ctime); |
Steven Whitehouse | 4bd91ba | 2007-06-05 09:39:18 +0100 | [diff] [blame] | 287 | ip->i_inode.i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec); |
Steven Whitehouse | ea744d0 | 2006-10-31 15:28:00 -0500 | [diff] [blame] | 288 | |
Steven Whitehouse | ce276b0 | 2008-02-06 09:25:45 +0000 | [diff] [blame] | 289 | ip->i_goal = be64_to_cpu(str->di_goal_meta); |
Steven Whitehouse | bcf0b5b | 2008-11-03 13:39:46 +0000 | [diff] [blame] | 290 | ip->i_generation = be64_to_cpu(str->di_generation); |
Steven Whitehouse | ea744d0 | 2006-10-31 15:28:00 -0500 | [diff] [blame] | 291 | |
Steven Whitehouse | 383f01f | 2008-11-04 10:05:22 +0000 | [diff] [blame] | 292 | ip->i_diskflags = be32_to_cpu(str->di_flags); |
Steven Whitehouse | 6b124d8 | 2006-11-08 12:51:06 -0500 | [diff] [blame] | 293 | gfs2_set_inode_flags(&ip->i_inode); |
Steven Whitehouse | ecc30c7 | 2008-01-28 10:37:35 +0000 | [diff] [blame] | 294 | height = be16_to_cpu(str->di_height); |
| 295 | if (unlikely(height > GFS2_MAX_META_HEIGHT)) |
| 296 | goto corrupt; |
| 297 | ip->i_height = (u8)height; |
Steven Whitehouse | ea744d0 | 2006-10-31 15:28:00 -0500 | [diff] [blame] | 298 | |
Steven Whitehouse | 9a00450 | 2008-02-01 09:23:44 +0000 | [diff] [blame] | 299 | depth = be16_to_cpu(str->di_depth); |
| 300 | if (unlikely(depth > GFS2_DIR_MAX_DEPTH)) |
| 301 | goto corrupt; |
| 302 | ip->i_depth = (u8)depth; |
Steven Whitehouse | ad6203f | 2008-11-03 13:59:19 +0000 | [diff] [blame] | 303 | ip->i_entries = be32_to_cpu(str->di_entries); |
Steven Whitehouse | ea744d0 | 2006-10-31 15:28:00 -0500 | [diff] [blame] | 304 | |
Steven Whitehouse | 3767ac2 | 2008-11-03 14:28:42 +0000 | [diff] [blame] | 305 | ip->i_eattr = be64_to_cpu(str->di_eattr); |
Steven Whitehouse | 5561093 | 2007-10-17 08:47:38 +0100 | [diff] [blame] | 306 | if (S_ISREG(ip->i_inode.i_mode)) |
| 307 | gfs2_set_aops(&ip->i_inode); |
| 308 | |
Steven Whitehouse | af339c0 | 2006-11-01 10:34:15 -0500 | [diff] [blame] | 309 | return 0; |
Steven Whitehouse | ecc30c7 | 2008-01-28 10:37:35 +0000 | [diff] [blame] | 310 | corrupt: |
| 311 | if (gfs2_consist_inode(ip)) |
| 312 | gfs2_dinode_print(ip); |
| 313 | return -EIO; |
Steven Whitehouse | ea744d0 | 2006-10-31 15:28:00 -0500 | [diff] [blame] | 314 | } |
| 315 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 316 | /** |
| 317 | * gfs2_inode_refresh - Refresh the incore copy of the dinode |
| 318 | * @ip: The GFS2 inode |
| 319 | * |
| 320 | * Returns: errno |
| 321 | */ |
| 322 | |
| 323 | int gfs2_inode_refresh(struct gfs2_inode *ip) |
| 324 | { |
| 325 | struct buffer_head *dibh; |
| 326 | int error; |
| 327 | |
| 328 | error = gfs2_meta_inode_buffer(ip, &dibh); |
| 329 | if (error) |
| 330 | return error; |
| 331 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 332 | if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), dibh, GFS2_METATYPE_DI)) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 333 | brelse(dibh); |
| 334 | return -EIO; |
| 335 | } |
| 336 | |
Steven Whitehouse | af339c0 | 2006-11-01 10:34:15 -0500 | [diff] [blame] | 337 | error = gfs2_dinode_in(ip, dibh->b_data); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 338 | brelse(dibh); |
Steven Whitehouse | bfded27 | 2006-11-01 16:05:38 -0500 | [diff] [blame] | 339 | clear_bit(GIF_INVALID, &ip->i_flags); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 340 | |
Steven Whitehouse | af339c0 | 2006-11-01 10:34:15 -0500 | [diff] [blame] | 341 | return error; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 342 | } |
| 343 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 344 | int gfs2_dinode_dealloc(struct gfs2_inode *ip) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 345 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 346 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 347 | struct gfs2_alloc *al; |
| 348 | struct gfs2_rgrpd *rgd; |
| 349 | int error; |
| 350 | |
Steven Whitehouse | 77658aa | 2008-02-12 14:17:27 +0000 | [diff] [blame] | 351 | if (gfs2_get_inode_blocks(&ip->i_inode) != 1) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 352 | if (gfs2_consist_inode(ip)) |
Steven Whitehouse | 4cc14f0 | 2006-10-31 19:00:24 -0500 | [diff] [blame] | 353 | gfs2_dinode_print(ip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 354 | return -EIO; |
| 355 | } |
| 356 | |
| 357 | al = gfs2_alloc_get(ip); |
Cyrill Gorcunov | 182fe5a | 2008-03-03 21:54:21 +0300 | [diff] [blame] | 358 | if (!al) |
| 359 | return -ENOMEM; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 360 | |
| 361 | error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); |
| 362 | if (error) |
| 363 | goto out; |
| 364 | |
| 365 | error = gfs2_rindex_hold(sdp, &al->al_ri_gh); |
| 366 | if (error) |
| 367 | goto out_qs; |
| 368 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 369 | rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 370 | if (!rgd) { |
| 371 | gfs2_consist_inode(ip); |
| 372 | error = -EIO; |
| 373 | goto out_rindex_relse; |
| 374 | } |
| 375 | |
| 376 | error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, |
| 377 | &al->al_rgd_gh); |
| 378 | if (error) |
| 379 | goto out_rindex_relse; |
| 380 | |
Steven Whitehouse | 420b9e5 | 2006-07-31 15:42:17 -0400 | [diff] [blame] | 381 | error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA, 1); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 382 | if (error) |
| 383 | goto out_rg_gunlock; |
| 384 | |
Steven Whitehouse | 2bcd610 | 2007-11-08 14:25:12 +0000 | [diff] [blame] | 385 | set_bit(GLF_DIRTY, &ip->i_gl->gl_flags); |
| 386 | set_bit(GLF_LFLUSH, &ip->i_gl->gl_flags); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 387 | |
| 388 | gfs2_free_di(rgd, ip); |
| 389 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 390 | gfs2_trans_end(sdp); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 391 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 392 | out_rg_gunlock: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 393 | gfs2_glock_dq_uninit(&al->al_rgd_gh); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 394 | out_rindex_relse: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 395 | gfs2_glock_dq_uninit(&al->al_ri_gh); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 396 | out_qs: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 397 | gfs2_quota_unhold(ip); |
Steven Whitehouse | 3632752 | 2006-04-28 10:46:21 -0400 | [diff] [blame] | 398 | out: |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 399 | gfs2_alloc_put(ip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 400 | return error; |
| 401 | } |
| 402 | |
| 403 | /** |
S. Wendy Cheng | 87d21e0 | 2007-01-18 16:07:03 -0500 | [diff] [blame] | 404 | * gfs2_change_nlink - Change nlink count on inode |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 405 | * @ip: The GFS2 inode |
| 406 | * @diff: The change in the nlink count required |
| 407 | * |
| 408 | * Returns: errno |
| 409 | */ |
S. Wendy Cheng | 87d21e0 | 2007-01-18 16:07:03 -0500 | [diff] [blame] | 410 | int gfs2_change_nlink(struct gfs2_inode *ip, int diff) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 411 | { |
| 412 | struct buffer_head *dibh; |
Steven Whitehouse | cd91549 | 2006-09-04 12:49:07 -0400 | [diff] [blame] | 413 | u32 nlink; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 414 | int error; |
| 415 | |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 416 | BUG_ON(diff != 1 && diff != -1); |
| 417 | nlink = ip->i_inode.i_nlink + diff; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 418 | |
| 419 | /* If we are reducing the nlink count, but the new value ends up being |
| 420 | bigger than the old one, we must have underflowed. */ |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 421 | if (diff < 0 && nlink > ip->i_inode.i_nlink) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 422 | if (gfs2_consist_inode(ip)) |
Steven Whitehouse | 4cc14f0 | 2006-10-31 19:00:24 -0500 | [diff] [blame] | 423 | gfs2_dinode_print(ip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 424 | return -EIO; |
| 425 | } |
| 426 | |
| 427 | error = gfs2_meta_inode_buffer(ip, &dibh); |
| 428 | if (error) |
| 429 | return error; |
| 430 | |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 431 | if (diff > 0) |
| 432 | inc_nlink(&ip->i_inode); |
| 433 | else |
| 434 | drop_nlink(&ip->i_inode); |
| 435 | |
Steven Whitehouse | 4bd91ba | 2007-06-05 09:39:18 +0100 | [diff] [blame] | 436 | ip->i_inode.i_ctime = CURRENT_TIME; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 437 | |
Steven Whitehouse | d4e9c4c | 2006-01-18 11:19:28 +0000 | [diff] [blame] | 438 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
Steven Whitehouse | 539e5d6 | 2006-10-31 15:07:05 -0500 | [diff] [blame] | 439 | gfs2_dinode_out(ip, dibh->b_data); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 440 | brelse(dibh); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 441 | mark_inode_dirty(&ip->i_inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 442 | |
S. Wendy Cheng | 87d21e0 | 2007-01-18 16:07:03 -0500 | [diff] [blame] | 443 | if (ip->i_inode.i_nlink == 0) |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 444 | gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */ |
S. Wendy Cheng | 87d21e0 | 2007-01-18 16:07:03 -0500 | [diff] [blame] | 445 | |
S. Wendy Cheng | 5509826 | 2007-01-18 15:56:34 -0500 | [diff] [blame] | 446 | return error; |
| 447 | } |
| 448 | |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 449 | struct inode *gfs2_lookup_simple(struct inode *dip, const char *name) |
| 450 | { |
| 451 | struct qstr qstr; |
Russell Cattelan | 6c93fd1 | 2007-01-08 17:47:51 -0600 | [diff] [blame] | 452 | struct inode *inode; |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 453 | gfs2_str2qstr(&qstr, name); |
Al Viro | a569c71 | 2008-07-23 14:42:05 -0400 | [diff] [blame] | 454 | inode = gfs2_lookupi(dip, &qstr, 1); |
Russell Cattelan | 6c93fd1 | 2007-01-08 17:47:51 -0600 | [diff] [blame] | 455 | /* gfs2_lookupi has inconsistent callers: vfs |
| 456 | * related routines expect NULL for no entry found, |
| 457 | * gfs2_lookup_simple callers expect ENOENT |
| 458 | * and do not check for NULL. |
| 459 | */ |
| 460 | if (inode == NULL) |
| 461 | return ERR_PTR(-ENOENT); |
| 462 | else |
| 463 | return inode; |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 467 | /** |
| 468 | * gfs2_lookupi - Look up a filename in a directory and return its inode |
| 469 | * @d_gh: An initialized holder for the directory glock |
| 470 | * @name: The name of the inode to look for |
| 471 | * @is_root: If 1, ignore the caller's permissions |
| 472 | * @i_gh: An uninitialized holder for the new inode glock |
| 473 | * |
Steven Whitehouse | d7c103d | 2007-01-25 17:14:59 +0000 | [diff] [blame] | 474 | * This can be called via the VFS filldir function when NFS is doing |
| 475 | * a readdirplus and the inode which its intending to stat isn't |
| 476 | * already in cache. In this case we must not take the directory glock |
| 477 | * again, since the readdir call will have already taken that lock. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 478 | * |
| 479 | * Returns: errno |
| 480 | */ |
| 481 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 482 | struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, |
Al Viro | a569c71 | 2008-07-23 14:42:05 -0400 | [diff] [blame] | 483 | int is_root) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 484 | { |
Steven Whitehouse | c9fd430 | 2006-03-01 15:31:02 -0500 | [diff] [blame] | 485 | struct super_block *sb = dir->i_sb; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 486 | struct gfs2_inode *dip = GFS2_I(dir); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 487 | struct gfs2_holder d_gh; |
akpm@linux-foundation.org | 037bcbb | 2007-06-08 16:42:14 -0700 | [diff] [blame] | 488 | int error = 0; |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 489 | struct inode *inode = NULL; |
Steven Whitehouse | d7c103d | 2007-01-25 17:14:59 +0000 | [diff] [blame] | 490 | int unlock = 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 491 | |
| 492 | if (!name->len || name->len > GFS2_FNAMESIZE) |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 493 | return ERR_PTR(-ENAMETOOLONG); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 494 | |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 495 | if ((name->len == 1 && memcmp(name->name, ".", 1) == 0) || |
| 496 | (name->len == 2 && memcmp(name->name, "..", 2) == 0 && |
| 497 | dir == sb->s_root->d_inode)) { |
Steven Whitehouse | 320dd10 | 2006-05-18 16:25:27 -0400 | [diff] [blame] | 498 | igrab(dir); |
| 499 | return dir; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 500 | } |
| 501 | |
Steven Whitehouse | 7afd88d | 2008-02-22 16:07:18 +0000 | [diff] [blame] | 502 | if (gfs2_glock_is_locked_by_me(dip->i_gl) == NULL) { |
Steven Whitehouse | d7c103d | 2007-01-25 17:14:59 +0000 | [diff] [blame] | 503 | error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh); |
| 504 | if (error) |
| 505 | return ERR_PTR(error); |
| 506 | unlock = 1; |
| 507 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 508 | |
| 509 | if (!is_root) { |
Nick Piggin | b74c79e | 2011-01-07 17:49:58 +1100 | [diff] [blame] | 510 | error = gfs2_permission(dir, MAY_EXEC, 0); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 511 | if (error) |
| 512 | goto out; |
| 513 | } |
| 514 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 515 | inode = gfs2_dir_search(dir, name); |
| 516 | if (IS_ERR(inode)) |
| 517 | error = PTR_ERR(inode); |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 518 | out: |
Steven Whitehouse | d7c103d | 2007-01-25 17:14:59 +0000 | [diff] [blame] | 519 | if (unlock) |
| 520 | gfs2_glock_dq_uninit(&d_gh); |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 521 | if (error == -ENOENT) |
| 522 | return NULL; |
Steven Whitehouse | d7c103d | 2007-01-25 17:14:59 +0000 | [diff] [blame] | 523 | return inode ? inode : ERR_PTR(error); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 524 | } |
| 525 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 526 | /** |
| 527 | * create_ok - OK to create a new on-disk inode here? |
| 528 | * @dip: Directory in which dinode is to be created |
| 529 | * @name: Name of new dinode |
| 530 | * @mode: |
| 531 | * |
| 532 | * Returns: errno |
| 533 | */ |
| 534 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 535 | static int create_ok(struct gfs2_inode *dip, const struct qstr *name, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 536 | unsigned int mode) |
| 537 | { |
| 538 | int error; |
| 539 | |
Nick Piggin | b74c79e | 2011-01-07 17:49:58 +1100 | [diff] [blame] | 540 | error = gfs2_permission(&dip->i_inode, MAY_WRITE | MAY_EXEC, 0); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 541 | if (error) |
| 542 | return error; |
| 543 | |
| 544 | /* Don't create entries in an unlinked directory */ |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 545 | if (!dip->i_inode.i_nlink) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 546 | return -EPERM; |
| 547 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 548 | error = gfs2_dir_check(&dip->i_inode, name, NULL); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 549 | switch (error) { |
| 550 | case -ENOENT: |
| 551 | error = 0; |
| 552 | break; |
| 553 | case 0: |
| 554 | return -EEXIST; |
| 555 | default: |
| 556 | return error; |
| 557 | } |
| 558 | |
Steven Whitehouse | ad6203f | 2008-11-03 13:59:19 +0000 | [diff] [blame] | 559 | if (dip->i_entries == (u32)-1) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 560 | return -EFBIG; |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 561 | if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 562 | return -EMLINK; |
| 563 | |
| 564 | return 0; |
| 565 | } |
| 566 | |
| 567 | static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode, |
| 568 | unsigned int *uid, unsigned int *gid) |
| 569 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 570 | if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir && |
Steven Whitehouse | 2933f92 | 2006-11-01 13:23:29 -0500 | [diff] [blame] | 571 | (dip->i_inode.i_mode & S_ISUID) && dip->i_inode.i_uid) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 572 | if (S_ISDIR(*mode)) |
| 573 | *mode |= S_ISUID; |
David Howells | 3de7be3 | 2008-11-14 10:38:53 +1100 | [diff] [blame] | 574 | else if (dip->i_inode.i_uid != current_fsuid()) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 575 | *mode &= ~07111; |
Steven Whitehouse | 2933f92 | 2006-11-01 13:23:29 -0500 | [diff] [blame] | 576 | *uid = dip->i_inode.i_uid; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 577 | } else |
David Howells | 3de7be3 | 2008-11-14 10:38:53 +1100 | [diff] [blame] | 578 | *uid = current_fsuid(); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 579 | |
Steven Whitehouse | b60623c | 2006-11-01 12:22:46 -0500 | [diff] [blame] | 580 | if (dip->i_inode.i_mode & S_ISGID) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 581 | if (S_ISDIR(*mode)) |
| 582 | *mode |= S_ISGID; |
Steven Whitehouse | 2933f92 | 2006-11-01 13:23:29 -0500 | [diff] [blame] | 583 | *gid = dip->i_inode.i_gid; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 584 | } else |
David Howells | 3de7be3 | 2008-11-14 10:38:53 +1100 | [diff] [blame] | 585 | *gid = current_fsgid(); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 586 | } |
| 587 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 588 | static int alloc_dinode(struct gfs2_inode *dip, u64 *no_addr, u64 *generation) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 589 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 590 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 591 | int error; |
| 592 | |
Steven Whitehouse | 6dbd822 | 2008-01-10 15:18:55 +0000 | [diff] [blame] | 593 | if (gfs2_alloc_get(dip) == NULL) |
| 594 | return -ENOMEM; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 595 | |
Steven Whitehouse | 6dbd822 | 2008-01-10 15:18:55 +0000 | [diff] [blame] | 596 | dip->i_alloc->al_requested = RES_DINODE; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 597 | error = gfs2_inplace_reserve(dip); |
| 598 | if (error) |
| 599 | goto out; |
| 600 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 601 | error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS, 0); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 602 | if (error) |
| 603 | goto out_ipreserv; |
| 604 | |
Steven Whitehouse | 6050b9c | 2009-07-31 16:19:40 +0100 | [diff] [blame] | 605 | error = gfs2_alloc_di(dip, no_addr, generation); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 606 | |
| 607 | gfs2_trans_end(sdp); |
| 608 | |
Steven Whitehouse | 4340fe6 | 2006-07-11 09:46:33 -0400 | [diff] [blame] | 609 | out_ipreserv: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 610 | gfs2_inplace_release(dip); |
Steven Whitehouse | 4340fe6 | 2006-07-11 09:46:33 -0400 | [diff] [blame] | 611 | out: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 612 | gfs2_alloc_put(dip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 613 | return error; |
| 614 | } |
| 615 | |
| 616 | /** |
| 617 | * init_dinode - Fill in a new dinode structure |
| 618 | * @dip: the directory this inode is being created in |
| 619 | * @gl: The glock covering the new inode |
| 620 | * @inum: the inode number |
| 621 | * @mode: the file permissions |
| 622 | * @uid: |
| 623 | * @gid: |
| 624 | * |
| 625 | */ |
| 626 | |
| 627 | static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, |
Al Viro | 629a21e | 2006-10-13 22:51:24 -0400 | [diff] [blame] | 628 | const struct gfs2_inum_host *inum, unsigned int mode, |
Steven Whitehouse | 4340fe6 | 2006-07-11 09:46:33 -0400 | [diff] [blame] | 629 | unsigned int uid, unsigned int gid, |
Wendy Cheng | e9bd2b3 | 2007-08-24 09:15:01 -0400 | [diff] [blame] | 630 | const u64 *generation, dev_t dev, struct buffer_head **bhp) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 631 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 632 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); |
Steven Whitehouse | b96ca4f | 2006-01-18 10:57:10 +0000 | [diff] [blame] | 633 | struct gfs2_dinode *di; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 634 | struct buffer_head *dibh; |
Steven Whitehouse | 4bd91ba | 2007-06-05 09:39:18 +0100 | [diff] [blame] | 635 | struct timespec tv = CURRENT_TIME; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 636 | |
| 637 | dibh = gfs2_meta_new(gl, inum->no_addr); |
Steven Whitehouse | d4e9c4c | 2006-01-18 11:19:28 +0000 | [diff] [blame] | 638 | gfs2_trans_add_bh(gl, dibh, 1); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 639 | gfs2_metatype_set(dibh, GFS2_METATYPE_DI, GFS2_FORMAT_DI); |
| 640 | gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); |
Steven Whitehouse | b96ca4f | 2006-01-18 10:57:10 +0000 | [diff] [blame] | 641 | di = (struct gfs2_dinode *)dibh->b_data; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 642 | |
Steven Whitehouse | 2442a09 | 2006-01-30 11:49:32 +0000 | [diff] [blame] | 643 | di->di_num.no_formal_ino = cpu_to_be64(inum->no_formal_ino); |
| 644 | di->di_num.no_addr = cpu_to_be64(inum->no_addr); |
Steven Whitehouse | b96ca4f | 2006-01-18 10:57:10 +0000 | [diff] [blame] | 645 | di->di_mode = cpu_to_be32(mode); |
| 646 | di->di_uid = cpu_to_be32(uid); |
| 647 | di->di_gid = cpu_to_be32(gid); |
Steven Whitehouse | 294caaa | 2006-11-02 11:59:28 -0500 | [diff] [blame] | 648 | di->di_nlink = 0; |
| 649 | di->di_size = 0; |
Steven Whitehouse | b96ca4f | 2006-01-18 10:57:10 +0000 | [diff] [blame] | 650 | di->di_blocks = cpu_to_be64(1); |
Steven Whitehouse | 4bd91ba | 2007-06-05 09:39:18 +0100 | [diff] [blame] | 651 | di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(tv.tv_sec); |
Steven Whitehouse | e7f14f4 | 2006-10-31 21:45:08 -0500 | [diff] [blame] | 652 | di->di_major = cpu_to_be32(MAJOR(dev)); |
| 653 | di->di_minor = cpu_to_be32(MINOR(dev)); |
Steven Whitehouse | b96ca4f | 2006-01-18 10:57:10 +0000 | [diff] [blame] | 654 | di->di_goal_meta = di->di_goal_data = cpu_to_be64(inum->no_addr); |
Steven Whitehouse | 4340fe6 | 2006-07-11 09:46:33 -0400 | [diff] [blame] | 655 | di->di_generation = cpu_to_be64(*generation); |
Steven Whitehouse | 294caaa | 2006-11-02 11:59:28 -0500 | [diff] [blame] | 656 | di->di_flags = 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 657 | |
| 658 | if (S_ISREG(mode)) { |
Steven Whitehouse | 383f01f | 2008-11-04 10:05:22 +0000 | [diff] [blame] | 659 | if ((dip->i_diskflags & GFS2_DIF_INHERIT_JDATA) || |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 660 | gfs2_tune_get(sdp, gt_new_files_jdata)) |
Steven Whitehouse | b96ca4f | 2006-01-18 10:57:10 +0000 | [diff] [blame] | 661 | di->di_flags |= cpu_to_be32(GFS2_DIF_JDATA); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 662 | } else if (S_ISDIR(mode)) { |
Steven Whitehouse | 383f01f | 2008-11-04 10:05:22 +0000 | [diff] [blame] | 663 | di->di_flags |= cpu_to_be32(dip->i_diskflags & |
Steven Whitehouse | 568f4c9 | 2006-02-27 12:00:42 -0500 | [diff] [blame] | 664 | GFS2_DIF_INHERIT_JDATA); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 665 | } |
| 666 | |
Steven Whitehouse | b96ca4f | 2006-01-18 10:57:10 +0000 | [diff] [blame] | 667 | di->__pad1 = 0; |
Steven Whitehouse | a9583c7 | 2006-11-01 20:09:14 -0500 | [diff] [blame] | 668 | di->di_payload_format = cpu_to_be32(S_ISDIR(mode) ? GFS2_FORMAT_DE : 0); |
Steven Whitehouse | 294caaa | 2006-11-02 11:59:28 -0500 | [diff] [blame] | 669 | di->di_height = 0; |
Steven Whitehouse | b96ca4f | 2006-01-18 10:57:10 +0000 | [diff] [blame] | 670 | di->__pad2 = 0; |
| 671 | di->__pad3 = 0; |
Steven Whitehouse | 294caaa | 2006-11-02 11:59:28 -0500 | [diff] [blame] | 672 | di->di_depth = 0; |
| 673 | di->di_entries = 0; |
Steven Whitehouse | b96ca4f | 2006-01-18 10:57:10 +0000 | [diff] [blame] | 674 | memset(&di->__pad4, 0, sizeof(di->__pad4)); |
Steven Whitehouse | 294caaa | 2006-11-02 11:59:28 -0500 | [diff] [blame] | 675 | di->di_eattr = 0; |
Steven Whitehouse | 4bd91ba | 2007-06-05 09:39:18 +0100 | [diff] [blame] | 676 | di->di_atime_nsec = cpu_to_be32(tv.tv_nsec); |
| 677 | di->di_mtime_nsec = cpu_to_be32(tv.tv_nsec); |
| 678 | di->di_ctime_nsec = cpu_to_be32(tv.tv_nsec); |
Steven Whitehouse | b96ca4f | 2006-01-18 10:57:10 +0000 | [diff] [blame] | 679 | memset(&di->di_reserved, 0, sizeof(di->di_reserved)); |
Wendy Cheng | e9bd2b3 | 2007-08-24 09:15:01 -0400 | [diff] [blame] | 680 | |
| 681 | set_buffer_uptodate(dibh); |
Steven Whitehouse | b96ca4f | 2006-01-18 10:57:10 +0000 | [diff] [blame] | 682 | |
Wendy Cheng | e9bd2b3 | 2007-08-24 09:15:01 -0400 | [diff] [blame] | 683 | *bhp = dibh; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, |
Al Viro | 629a21e | 2006-10-13 22:51:24 -0400 | [diff] [blame] | 687 | unsigned int mode, const struct gfs2_inum_host *inum, |
Wendy Cheng | e9bd2b3 | 2007-08-24 09:15:01 -0400 | [diff] [blame] | 688 | const u64 *generation, dev_t dev, struct buffer_head **bhp) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 689 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 690 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 691 | unsigned int uid, gid; |
| 692 | int error; |
| 693 | |
| 694 | munge_mode_uid_gid(dip, &mode, &uid, &gid); |
Cyrill Gorcunov | 182fe5a | 2008-03-03 21:54:21 +0300 | [diff] [blame] | 695 | if (!gfs2_alloc_get(dip)) |
| 696 | return -ENOMEM; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 697 | |
| 698 | error = gfs2_quota_lock(dip, uid, gid); |
| 699 | if (error) |
| 700 | goto out; |
| 701 | |
| 702 | error = gfs2_quota_check(dip, uid, gid); |
| 703 | if (error) |
| 704 | goto out_quota; |
| 705 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 706 | error = gfs2_trans_begin(sdp, RES_DINODE + RES_QUOTA, 0); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 707 | if (error) |
| 708 | goto out_quota; |
| 709 | |
Wendy Cheng | e9bd2b3 | 2007-08-24 09:15:01 -0400 | [diff] [blame] | 710 | init_dinode(dip, gl, inum, mode, uid, gid, generation, dev, bhp); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 711 | gfs2_quota_change(dip, +1, uid, gid); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 712 | gfs2_trans_end(sdp); |
| 713 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 714 | out_quota: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 715 | gfs2_quota_unlock(dip); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 716 | out: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 717 | gfs2_alloc_put(dip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 718 | return error; |
| 719 | } |
| 720 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 721 | static int link_dinode(struct gfs2_inode *dip, const struct qstr *name, |
| 722 | struct gfs2_inode *ip) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 723 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 724 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 725 | struct gfs2_alloc *al; |
| 726 | int alloc_required; |
| 727 | struct buffer_head *dibh; |
| 728 | int error; |
| 729 | |
| 730 | al = gfs2_alloc_get(dip); |
Cyrill Gorcunov | 182fe5a | 2008-03-03 21:54:21 +0300 | [diff] [blame] | 731 | if (!al) |
| 732 | return -ENOMEM; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 733 | |
| 734 | error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); |
| 735 | if (error) |
| 736 | goto fail; |
| 737 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 738 | error = alloc_required = gfs2_diradd_alloc_required(&dip->i_inode, name); |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 739 | if (alloc_required < 0) |
Bob Peterson | 1b8177e | 2008-01-19 21:50:24 -0600 | [diff] [blame] | 740 | goto fail_quota_locks; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 741 | if (alloc_required) { |
Steven Whitehouse | 2933f92 | 2006-11-01 13:23:29 -0500 | [diff] [blame] | 742 | error = gfs2_quota_check(dip, dip->i_inode.i_uid, dip->i_inode.i_gid); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 743 | if (error) |
| 744 | goto fail_quota_locks; |
| 745 | |
| 746 | al->al_requested = sdp->sd_max_dirres; |
| 747 | |
| 748 | error = gfs2_inplace_reserve(dip); |
| 749 | if (error) |
| 750 | goto fail_quota_locks; |
| 751 | |
Steven Whitehouse | 320dd10 | 2006-05-18 16:25:27 -0400 | [diff] [blame] | 752 | error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 753 | al->al_rgd->rd_length + |
Steven Whitehouse | 907b9bc | 2006-09-25 09:26:04 -0400 | [diff] [blame] | 754 | 2 * RES_DINODE + |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 755 | RES_STATFS + RES_QUOTA, 0); |
| 756 | if (error) |
| 757 | goto fail_ipreserv; |
| 758 | } else { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 759 | error = gfs2_trans_begin(sdp, RES_LEAF + 2 * RES_DINODE, 0); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 760 | if (error) |
| 761 | goto fail_quota_locks; |
| 762 | } |
| 763 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 764 | error = gfs2_dir_add(&dip->i_inode, name, ip, IF2DT(ip->i_inode.i_mode)); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 765 | if (error) |
| 766 | goto fail_end_trans; |
| 767 | |
| 768 | error = gfs2_meta_inode_buffer(ip, &dibh); |
| 769 | if (error) |
| 770 | goto fail_end_trans; |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 771 | ip->i_inode.i_nlink = 1; |
Steven Whitehouse | d4e9c4c | 2006-01-18 11:19:28 +0000 | [diff] [blame] | 772 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
Steven Whitehouse | 539e5d6 | 2006-10-31 15:07:05 -0500 | [diff] [blame] | 773 | gfs2_dinode_out(ip, dibh->b_data); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 774 | brelse(dibh); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 775 | return 0; |
| 776 | |
Steven Whitehouse | 320dd10 | 2006-05-18 16:25:27 -0400 | [diff] [blame] | 777 | fail_end_trans: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 778 | gfs2_trans_end(sdp); |
| 779 | |
Steven Whitehouse | 320dd10 | 2006-05-18 16:25:27 -0400 | [diff] [blame] | 780 | fail_ipreserv: |
Steven Whitehouse | 6dbd822 | 2008-01-10 15:18:55 +0000 | [diff] [blame] | 781 | if (dip->i_alloc->al_rgd) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 782 | gfs2_inplace_release(dip); |
| 783 | |
Steven Whitehouse | 320dd10 | 2006-05-18 16:25:27 -0400 | [diff] [blame] | 784 | fail_quota_locks: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 785 | gfs2_quota_unlock(dip); |
| 786 | |
Steven Whitehouse | 320dd10 | 2006-05-18 16:25:27 -0400 | [diff] [blame] | 787 | fail: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 788 | gfs2_alloc_put(dip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 789 | return error; |
| 790 | } |
| 791 | |
Eric Paris | 2a7dba3 | 2011-02-01 11:05:39 -0500 | [diff] [blame] | 792 | static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip, |
| 793 | const struct qstr *qstr) |
Ryan O'Hara | fcb47e0b | 2006-10-03 11:57:35 -0400 | [diff] [blame] | 794 | { |
| 795 | int err; |
| 796 | size_t len; |
| 797 | void *value; |
| 798 | char *name; |
Ryan O'Hara | fcb47e0b | 2006-10-03 11:57:35 -0400 | [diff] [blame] | 799 | |
Eric Paris | 2a7dba3 | 2011-02-01 11:05:39 -0500 | [diff] [blame] | 800 | err = security_inode_init_security(&ip->i_inode, &dip->i_inode, qstr, |
Ryan O'Hara | fcb47e0b | 2006-10-03 11:57:35 -0400 | [diff] [blame] | 801 | &name, &value, &len); |
| 802 | |
| 803 | if (err) { |
| 804 | if (err == -EOPNOTSUPP) |
| 805 | return 0; |
| 806 | return err; |
| 807 | } |
| 808 | |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 809 | err = __gfs2_xattr_set(&ip->i_inode, name, value, len, 0, |
| 810 | GFS2_EATYPE_SECURITY); |
Ryan O'Hara | fcb47e0b | 2006-10-03 11:57:35 -0400 | [diff] [blame] | 811 | kfree(value); |
| 812 | kfree(name); |
| 813 | |
| 814 | return err; |
| 815 | } |
| 816 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 817 | /** |
| 818 | * gfs2_createi - Create a new inode |
| 819 | * @ghs: An array of two holders |
| 820 | * @name: The name of the new file |
| 821 | * @mode: the permissions on the new inode |
| 822 | * |
| 823 | * @ghs[0] is an initialized holder for the directory |
| 824 | * @ghs[1] is the holder for the inode lock |
| 825 | * |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 826 | * If the return value is not NULL, the glocks on both the directory and the new |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 827 | * file are held. A transaction has been started and an inplace reservation |
| 828 | * is held, as well. |
| 829 | * |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 830 | * Returns: An inode |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 831 | */ |
| 832 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 833 | struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, |
Steven Whitehouse | e7f14f4 | 2006-10-31 21:45:08 -0500 | [diff] [blame] | 834 | unsigned int mode, dev_t dev) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 835 | { |
Steven Whitehouse | e1cc860 | 2007-06-07 11:47:52 +0100 | [diff] [blame] | 836 | struct inode *inode = NULL; |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 837 | struct gfs2_inode *dip = ghs->gh_gl->gl_object; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 838 | struct inode *dir = &dip->i_inode; |
| 839 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 840 | struct gfs2_inum_host inum = { .no_addr = 0, .no_formal_ino = 0 }; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 841 | int error; |
Steven Whitehouse | 4340fe6 | 2006-07-11 09:46:33 -0400 | [diff] [blame] | 842 | u64 generation; |
Steven Whitehouse | f91a0d3 | 2007-10-15 16:29:05 +0100 | [diff] [blame] | 843 | struct buffer_head *bh = NULL; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 844 | |
| 845 | if (!name->len || name->len > GFS2_FNAMESIZE) |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 846 | return ERR_PTR(-ENAMETOOLONG); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 847 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 848 | gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, ghs); |
| 849 | error = gfs2_glock_nq(ghs); |
| 850 | if (error) |
| 851 | goto fail; |
| 852 | |
| 853 | error = create_ok(dip, name, mode); |
| 854 | if (error) |
| 855 | goto fail_gunlock; |
| 856 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 857 | error = alloc_dinode(dip, &inum.no_addr, &generation); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 858 | if (error) |
| 859 | goto fail_gunlock; |
Steven Whitehouse | 8d8291a | 2009-08-27 15:51:07 +0100 | [diff] [blame] | 860 | inum.no_formal_ino = generation; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 861 | |
Steven Whitehouse | 28626e2 | 2006-11-22 11:13:21 -0500 | [diff] [blame] | 862 | error = gfs2_glock_nq_num(sdp, inum.no_addr, &gfs2_inode_glops, |
| 863 | LM_ST_EXCLUSIVE, GL_SKIP, ghs + 1); |
| 864 | if (error) |
| 865 | goto fail_gunlock; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 866 | |
Wendy Cheng | e9bd2b3 | 2007-08-24 09:15:01 -0400 | [diff] [blame] | 867 | error = make_dinode(dip, ghs[1].gh_gl, mode, &inum, &generation, dev, &bh); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 868 | if (error) |
| 869 | goto fail_gunlock2; |
| 870 | |
Steven Whitehouse | 8d8291a | 2009-08-27 15:51:07 +0100 | [diff] [blame] | 871 | inode = gfs2_inode_lookup(dir->i_sb, IF2DT(mode), inum.no_addr, |
Bob Peterson | 44ad37d | 2011-03-17 16:19:58 -0400 | [diff] [blame] | 872 | inum.no_formal_ino, 0); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 873 | if (IS_ERR(inode)) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 874 | goto fail_gunlock2; |
| 875 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 876 | error = gfs2_inode_refresh(GFS2_I(inode)); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 877 | if (error) |
Steven Whitehouse | e1cc860 | 2007-06-07 11:47:52 +0100 | [diff] [blame] | 878 | goto fail_gunlock2; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 879 | |
Steven Whitehouse | 479c427 | 2009-10-02 12:00:00 +0100 | [diff] [blame] | 880 | error = gfs2_acl_create(dip, inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 881 | if (error) |
Steven Whitehouse | e1cc860 | 2007-06-07 11:47:52 +0100 | [diff] [blame] | 882 | goto fail_gunlock2; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 883 | |
Eric Paris | 2a7dba3 | 2011-02-01 11:05:39 -0500 | [diff] [blame] | 884 | error = gfs2_security_init(dip, GFS2_I(inode), name); |
Ryan O'Hara | fcb47e0b | 2006-10-03 11:57:35 -0400 | [diff] [blame] | 885 | if (error) |
Steven Whitehouse | e1cc860 | 2007-06-07 11:47:52 +0100 | [diff] [blame] | 886 | goto fail_gunlock2; |
Ryan O'Hara | fcb47e0b | 2006-10-03 11:57:35 -0400 | [diff] [blame] | 887 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 888 | error = link_dinode(dip, name, GFS2_I(inode)); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 889 | if (error) |
Steven Whitehouse | e1cc860 | 2007-06-07 11:47:52 +0100 | [diff] [blame] | 890 | goto fail_gunlock2; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 891 | |
Steven Whitehouse | f91a0d3 | 2007-10-15 16:29:05 +0100 | [diff] [blame] | 892 | if (bh) |
| 893 | brelse(bh); |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 894 | return inode; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 895 | |
Steven Whitehouse | 320dd10 | 2006-05-18 16:25:27 -0400 | [diff] [blame] | 896 | fail_gunlock2: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 897 | gfs2_glock_dq_uninit(ghs + 1); |
Julien Brunel | bd1eb88 | 2008-09-01 10:51:22 +0200 | [diff] [blame] | 898 | if (inode && !IS_ERR(inode)) |
Steven Whitehouse | e1cc860 | 2007-06-07 11:47:52 +0100 | [diff] [blame] | 899 | iput(inode); |
Steven Whitehouse | 320dd10 | 2006-05-18 16:25:27 -0400 | [diff] [blame] | 900 | fail_gunlock: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 901 | gfs2_glock_dq(ghs); |
Steven Whitehouse | 320dd10 | 2006-05-18 16:25:27 -0400 | [diff] [blame] | 902 | fail: |
Steven Whitehouse | f91a0d3 | 2007-10-15 16:29:05 +0100 | [diff] [blame] | 903 | if (bh) |
| 904 | brelse(bh); |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 905 | return ERR_PTR(error); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 906 | } |
| 907 | |
Steven Whitehouse | 536baf0 | 2009-05-22 10:48:59 +0100 | [diff] [blame] | 908 | static int __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 909 | { |
Christoph Hellwig | 1025774 | 2010-06-04 11:30:02 +0200 | [diff] [blame] | 910 | struct inode *inode = &ip->i_inode; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 911 | struct buffer_head *dibh; |
| 912 | int error; |
| 913 | |
| 914 | error = gfs2_meta_inode_buffer(ip, &dibh); |
Christoph Hellwig | 1025774 | 2010-06-04 11:30:02 +0200 | [diff] [blame] | 915 | if (error) |
| 916 | return error; |
| 917 | |
Christoph Hellwig | 1025774 | 2010-06-04 11:30:02 +0200 | [diff] [blame] | 918 | setattr_copy(inode, attr); |
| 919 | mark_inode_dirty(inode); |
Christoph Hellwig | 1025774 | 2010-06-04 11:30:02 +0200 | [diff] [blame] | 920 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
| 921 | gfs2_dinode_out(ip, dibh->b_data); |
| 922 | brelse(dibh); |
| 923 | return 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 924 | } |
| 925 | |
| 926 | /** |
| 927 | * gfs2_setattr_simple - |
| 928 | * @ip: |
| 929 | * @attr: |
| 930 | * |
| 931 | * Called with a reference on the vnode. |
| 932 | * |
| 933 | * Returns: errno |
| 934 | */ |
| 935 | |
| 936 | int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) |
| 937 | { |
| 938 | int error; |
| 939 | |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 940 | if (current->journal_info) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 941 | return __gfs2_setattr_simple(ip, attr); |
| 942 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 943 | error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE, 0); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 944 | if (error) |
| 945 | return error; |
| 946 | |
| 947 | error = __gfs2_setattr_simple(ip, attr); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 948 | gfs2_trans_end(GFS2_SB(&ip->i_inode)); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 949 | return error; |
| 950 | } |
| 951 | |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 952 | void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf) |
| 953 | { |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 954 | struct gfs2_dinode *str = buf; |
| 955 | |
| 956 | str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC); |
| 957 | str->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI); |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 958 | str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI); |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 959 | str->di_num.no_addr = cpu_to_be64(ip->i_no_addr); |
| 960 | str->di_num.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino); |
| 961 | str->di_mode = cpu_to_be32(ip->i_inode.i_mode); |
| 962 | str->di_uid = cpu_to_be32(ip->i_inode.i_uid); |
| 963 | str->di_gid = cpu_to_be32(ip->i_inode.i_gid); |
| 964 | str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink); |
Steven Whitehouse | a2e0f79 | 2010-08-11 09:53:11 +0100 | [diff] [blame] | 965 | str->di_size = cpu_to_be64(i_size_read(&ip->i_inode)); |
Steven Whitehouse | 77658aa | 2008-02-12 14:17:27 +0000 | [diff] [blame] | 966 | str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode)); |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 967 | str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec); |
| 968 | str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec); |
| 969 | str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec); |
| 970 | |
Steven Whitehouse | ce276b0 | 2008-02-06 09:25:45 +0000 | [diff] [blame] | 971 | str->di_goal_meta = cpu_to_be64(ip->i_goal); |
| 972 | str->di_goal_data = cpu_to_be64(ip->i_goal); |
Steven Whitehouse | bcf0b5b | 2008-11-03 13:39:46 +0000 | [diff] [blame] | 973 | str->di_generation = cpu_to_be64(ip->i_generation); |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 974 | |
Steven Whitehouse | 383f01f | 2008-11-04 10:05:22 +0000 | [diff] [blame] | 975 | str->di_flags = cpu_to_be32(ip->i_diskflags); |
Steven Whitehouse | ecc30c7 | 2008-01-28 10:37:35 +0000 | [diff] [blame] | 976 | str->di_height = cpu_to_be16(ip->i_height); |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 977 | str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) && |
Steven Whitehouse | 383f01f | 2008-11-04 10:05:22 +0000 | [diff] [blame] | 978 | !(ip->i_diskflags & GFS2_DIF_EXHASH) ? |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 979 | GFS2_FORMAT_DE : 0); |
Steven Whitehouse | 9a00450 | 2008-02-01 09:23:44 +0000 | [diff] [blame] | 980 | str->di_depth = cpu_to_be16(ip->i_depth); |
Steven Whitehouse | ad6203f | 2008-11-03 13:59:19 +0000 | [diff] [blame] | 981 | str->di_entries = cpu_to_be32(ip->i_entries); |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 982 | |
Steven Whitehouse | 3767ac2 | 2008-11-03 14:28:42 +0000 | [diff] [blame] | 983 | str->di_eattr = cpu_to_be64(ip->i_eattr); |
Steven Whitehouse | 4bd91ba | 2007-06-05 09:39:18 +0100 | [diff] [blame] | 984 | str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec); |
| 985 | str->di_mtime_nsec = cpu_to_be32(ip->i_inode.i_mtime.tv_nsec); |
| 986 | str->di_ctime_nsec = cpu_to_be32(ip->i_inode.i_ctime.tv_nsec); |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 987 | } |
| 988 | |
| 989 | void gfs2_dinode_print(const struct gfs2_inode *ip) |
| 990 | { |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 991 | printk(KERN_INFO " no_formal_ino = %llu\n", |
| 992 | (unsigned long long)ip->i_no_formal_ino); |
| 993 | printk(KERN_INFO " no_addr = %llu\n", |
| 994 | (unsigned long long)ip->i_no_addr); |
Steven Whitehouse | a2e0f79 | 2010-08-11 09:53:11 +0100 | [diff] [blame] | 995 | printk(KERN_INFO " i_size = %llu\n", |
| 996 | (unsigned long long)i_size_read(&ip->i_inode)); |
Steven Whitehouse | 77658aa | 2008-02-12 14:17:27 +0000 | [diff] [blame] | 997 | printk(KERN_INFO " blocks = %llu\n", |
| 998 | (unsigned long long)gfs2_get_inode_blocks(&ip->i_inode)); |
Steven Whitehouse | ce276b0 | 2008-02-06 09:25:45 +0000 | [diff] [blame] | 999 | printk(KERN_INFO " i_goal = %llu\n", |
| 1000 | (unsigned long long)ip->i_goal); |
Steven Whitehouse | 383f01f | 2008-11-04 10:05:22 +0000 | [diff] [blame] | 1001 | printk(KERN_INFO " i_diskflags = 0x%.8X\n", ip->i_diskflags); |
Bob Peterson | ca39060 | 2008-01-28 11:15:57 -0600 | [diff] [blame] | 1002 | printk(KERN_INFO " i_height = %u\n", ip->i_height); |
Steven Whitehouse | 9a00450 | 2008-02-01 09:23:44 +0000 | [diff] [blame] | 1003 | printk(KERN_INFO " i_depth = %u\n", ip->i_depth); |
Steven Whitehouse | ad6203f | 2008-11-03 13:59:19 +0000 | [diff] [blame] | 1004 | printk(KERN_INFO " i_entries = %u\n", ip->i_entries); |
Steven Whitehouse | 3767ac2 | 2008-11-03 14:28:42 +0000 | [diff] [blame] | 1005 | printk(KERN_INFO " i_eattr = %llu\n", |
| 1006 | (unsigned long long)ip->i_eattr); |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 1007 | } |
| 1008 | |