David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
Steven Whitehouse | 3a8a9a1 | 2006-05-18 15:09:15 -0400 | [diff] [blame] | 3 | * Copyright (C) 2004-2006 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 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 10 | #include <linux/slab.h> |
| 11 | #include <linux/spinlock.h> |
| 12 | #include <linux/completion.h> |
| 13 | #include <linux/buffer_head.h> |
| 14 | #include <linux/namei.h> |
| 15 | #include <linux/utsname.h> |
| 16 | #include <linux/mm.h> |
| 17 | #include <linux/xattr.h> |
| 18 | #include <linux/posix_acl.h> |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 19 | #include <linux/gfs2_ondisk.h> |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 20 | #include <linux/crc32.h> |
Fabio Massimo Di Nitto | 7d30859 | 2006-09-19 07:56:29 +0200 | [diff] [blame] | 21 | #include <linux/lm_interface.h> |
Steven Whitehouse | e9079cc | 2008-10-14 14:43:29 +0100 | [diff] [blame^] | 22 | #include <linux/fiemap.h> |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 23 | #include <asm/uaccess.h> |
| 24 | |
| 25 | #include "gfs2.h" |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 26 | #include "incore.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 27 | #include "acl.h" |
| 28 | #include "bmap.h" |
| 29 | #include "dir.h" |
| 30 | #include "eaops.h" |
| 31 | #include "eattr.h" |
| 32 | #include "glock.h" |
| 33 | #include "inode.h" |
| 34 | #include "meta_io.h" |
| 35 | #include "ops_dentry.h" |
| 36 | #include "ops_inode.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 37 | #include "quota.h" |
| 38 | #include "rgrp.h" |
| 39 | #include "trans.h" |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 40 | #include "util.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * gfs2_create - Create a file |
| 44 | * @dir: The directory in which to create the file |
| 45 | * @dentry: The dentry of the new file |
| 46 | * @mode: The mode of the new file |
| 47 | * |
| 48 | * Returns: errno |
| 49 | */ |
| 50 | |
| 51 | static int gfs2_create(struct inode *dir, struct dentry *dentry, |
| 52 | int mode, struct nameidata *nd) |
| 53 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 54 | struct gfs2_inode *dip = GFS2_I(dir); |
| 55 | struct gfs2_sbd *sdp = GFS2_SB(dir); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 56 | struct gfs2_holder ghs[2]; |
| 57 | struct inode *inode; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 58 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 59 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); |
| 60 | |
| 61 | for (;;) { |
Steven Whitehouse | e7f14f4 | 2006-10-31 21:45:08 -0500 | [diff] [blame] | 62 | inode = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode, 0); |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 63 | if (!IS_ERR(inode)) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 64 | gfs2_trans_end(sdp); |
Steven Whitehouse | 6dbd822 | 2008-01-10 15:18:55 +0000 | [diff] [blame] | 65 | if (dip->i_alloc->al_rgd) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 66 | gfs2_inplace_release(dip); |
| 67 | gfs2_quota_unlock(dip); |
| 68 | gfs2_alloc_put(dip); |
| 69 | gfs2_glock_dq_uninit_m(2, ghs); |
Steven Whitehouse | 3a8476d | 2006-06-19 09:10:39 -0400 | [diff] [blame] | 70 | mark_inode_dirty(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 71 | break; |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 72 | } else if (PTR_ERR(inode) != -EEXIST || |
Al Viro | 3516586 | 2008-08-05 03:00:49 -0400 | [diff] [blame] | 73 | (nd && nd->flags & LOOKUP_EXCL)) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 74 | gfs2_holder_uninit(ghs); |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 75 | return PTR_ERR(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Al Viro | a569c71 | 2008-07-23 14:42:05 -0400 | [diff] [blame] | 78 | inode = gfs2_lookupi(dir, &dentry->d_name, 0); |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 79 | if (inode) { |
| 80 | if (!IS_ERR(inode)) { |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 81 | gfs2_holder_uninit(ghs); |
| 82 | break; |
| 83 | } else { |
| 84 | gfs2_holder_uninit(ghs); |
| 85 | return PTR_ERR(inode); |
| 86 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 87 | } |
| 88 | } |
| 89 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 90 | d_instantiate(dentry, inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 91 | |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * gfs2_lookup - Look up a filename in a directory and return its inode |
| 97 | * @dir: The directory inode |
| 98 | * @dentry: The dentry of the new inode |
| 99 | * @nd: passed from Linux VFS, ignored by us |
| 100 | * |
| 101 | * Called by the VFS layer. Lock dir and call gfs2_lookupi() |
| 102 | * |
| 103 | * Returns: errno |
| 104 | */ |
| 105 | |
| 106 | static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry, |
| 107 | struct nameidata *nd) |
| 108 | { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 109 | struct inode *inode = NULL; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 110 | |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 111 | dentry->d_op = &gfs2_dops; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 112 | |
Al Viro | a569c71 | 2008-07-23 14:42:05 -0400 | [diff] [blame] | 113 | inode = gfs2_lookupi(dir, &dentry->d_name, 0); |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 114 | if (inode && IS_ERR(inode)) |
David Howells | e231c2e | 2008-02-07 00:15:26 -0800 | [diff] [blame] | 115 | return ERR_CAST(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 116 | |
Steven Whitehouse | 9656b2c | 2008-01-08 08:14:30 +0000 | [diff] [blame] | 117 | if (inode) { |
| 118 | struct gfs2_glock *gl = GFS2_I(inode)->i_gl; |
| 119 | struct gfs2_holder gh; |
| 120 | int error; |
| 121 | error = gfs2_glock_nq_init(gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); |
| 122 | if (error) { |
| 123 | iput(inode); |
| 124 | return ERR_PTR(error); |
| 125 | } |
| 126 | gfs2_glock_dq_uninit(&gh); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 127 | return d_splice_alias(inode, dentry); |
Steven Whitehouse | 9656b2c | 2008-01-08 08:14:30 +0000 | [diff] [blame] | 128 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 129 | d_add(dentry, inode); |
| 130 | |
| 131 | return NULL; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * gfs2_link - Link to a file |
| 136 | * @old_dentry: The inode to link |
| 137 | * @dir: Add link to this directory |
| 138 | * @dentry: The name of the link |
| 139 | * |
| 140 | * Link the inode in "old_dentry" into the directory "dir" with the |
| 141 | * name in "dentry". |
| 142 | * |
| 143 | * Returns: errno |
| 144 | */ |
| 145 | |
| 146 | static int gfs2_link(struct dentry *old_dentry, struct inode *dir, |
| 147 | struct dentry *dentry) |
| 148 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 149 | struct gfs2_inode *dip = GFS2_I(dir); |
| 150 | struct gfs2_sbd *sdp = GFS2_SB(dir); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 151 | struct inode *inode = old_dentry->d_inode; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 152 | struct gfs2_inode *ip = GFS2_I(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 153 | struct gfs2_holder ghs[2]; |
| 154 | int alloc_required; |
| 155 | int error; |
| 156 | |
Steven Whitehouse | b60623c | 2006-11-01 12:22:46 -0500 | [diff] [blame] | 157 | if (S_ISDIR(inode->i_mode)) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 158 | return -EPERM; |
| 159 | |
| 160 | gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); |
| 161 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); |
| 162 | |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 163 | error = gfs2_glock_nq(ghs); /* parent */ |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 164 | if (error) |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 165 | goto out_parent; |
| 166 | |
| 167 | error = gfs2_glock_nq(ghs + 1); /* child */ |
| 168 | if (error) |
| 169 | goto out_child; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 170 | |
Miklos Szeredi | f58ba88 | 2008-07-02 21:12:01 +0200 | [diff] [blame] | 171 | error = gfs2_permission(dir, MAY_WRITE | MAY_EXEC); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 172 | if (error) |
| 173 | goto out_gunlock; |
| 174 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 175 | error = gfs2_dir_check(dir, &dentry->d_name, NULL); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 176 | switch (error) { |
| 177 | case -ENOENT: |
| 178 | break; |
| 179 | case 0: |
| 180 | error = -EEXIST; |
| 181 | default: |
| 182 | goto out_gunlock; |
| 183 | } |
| 184 | |
| 185 | error = -EINVAL; |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 186 | if (!dip->i_inode.i_nlink) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 187 | goto out_gunlock; |
| 188 | error = -EFBIG; |
Steven Whitehouse | cd91549 | 2006-09-04 12:49:07 -0400 | [diff] [blame] | 189 | if (dip->i_di.di_entries == (u32)-1) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 190 | goto out_gunlock; |
| 191 | error = -EPERM; |
| 192 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
| 193 | goto out_gunlock; |
| 194 | error = -EINVAL; |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 195 | if (!ip->i_inode.i_nlink) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 196 | goto out_gunlock; |
| 197 | error = -EMLINK; |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 198 | if (ip->i_inode.i_nlink == (u32)-1) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 199 | goto out_gunlock; |
| 200 | |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 201 | alloc_required = error = gfs2_diradd_alloc_required(dir, &dentry->d_name); |
| 202 | if (error < 0) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 203 | goto out_gunlock; |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 204 | error = 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 205 | |
| 206 | if (alloc_required) { |
| 207 | struct gfs2_alloc *al = gfs2_alloc_get(dip); |
Cyrill Gorcunov | 182fe5a | 2008-03-03 21:54:21 +0300 | [diff] [blame] | 208 | if (!al) { |
| 209 | error = -ENOMEM; |
| 210 | goto out_gunlock; |
| 211 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 212 | |
Steven Whitehouse | d82661d | 2008-03-10 15:34:50 +0000 | [diff] [blame] | 213 | error = gfs2_quota_lock_check(dip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 214 | if (error) |
| 215 | goto out_alloc; |
| 216 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 217 | al->al_requested = sdp->sd_max_dirres; |
| 218 | |
| 219 | error = gfs2_inplace_reserve(dip); |
| 220 | if (error) |
| 221 | goto out_gunlock_q; |
| 222 | |
Steven Whitehouse | 1b50259 | 2006-05-18 14:10:52 -0400 | [diff] [blame] | 223 | error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 224 | al->al_rgd->rd_length + |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 225 | 2 * RES_DINODE + RES_STATFS + |
| 226 | RES_QUOTA, 0); |
| 227 | if (error) |
| 228 | goto out_ipres; |
| 229 | } else { |
| 230 | error = gfs2_trans_begin(sdp, 2 * RES_DINODE + RES_LEAF, 0); |
| 231 | if (error) |
| 232 | goto out_ipres; |
| 233 | } |
| 234 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 235 | error = gfs2_dir_add(dir, &dentry->d_name, ip, IF2DT(inode->i_mode)); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 236 | if (error) |
| 237 | goto out_end_trans; |
| 238 | |
| 239 | error = gfs2_change_nlink(ip, +1); |
| 240 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 241 | out_end_trans: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 242 | gfs2_trans_end(sdp); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 243 | out_ipres: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 244 | if (alloc_required) |
| 245 | gfs2_inplace_release(dip); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 246 | out_gunlock_q: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 247 | if (alloc_required) |
| 248 | gfs2_quota_unlock(dip); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 249 | out_alloc: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 250 | if (alloc_required) |
| 251 | gfs2_alloc_put(dip); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 252 | out_gunlock: |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 253 | gfs2_glock_dq(ghs + 1); |
| 254 | out_child: |
| 255 | gfs2_glock_dq(ghs); |
| 256 | out_parent: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 257 | gfs2_holder_uninit(ghs); |
| 258 | gfs2_holder_uninit(ghs + 1); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 259 | if (!error) { |
Steven Whitehouse | 29937ac | 2006-07-06 17:58:03 -0400 | [diff] [blame] | 260 | atomic_inc(&inode->i_count); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 261 | d_instantiate(dentry, inode); |
| 262 | mark_inode_dirty(inode); |
| 263 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 264 | return error; |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * gfs2_unlink - Unlink a file |
| 269 | * @dir: The inode of the directory containing the file to unlink |
| 270 | * @dentry: The file itself |
| 271 | * |
| 272 | * Unlink a file. Call gfs2_unlinki() |
| 273 | * |
| 274 | * Returns: errno |
| 275 | */ |
| 276 | |
| 277 | static int gfs2_unlink(struct inode *dir, struct dentry *dentry) |
| 278 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 279 | struct gfs2_inode *dip = GFS2_I(dir); |
| 280 | struct gfs2_sbd *sdp = GFS2_SB(dir); |
| 281 | struct gfs2_inode *ip = GFS2_I(dentry->d_inode); |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 282 | struct gfs2_holder ghs[3]; |
| 283 | struct gfs2_rgrpd *rgd; |
| 284 | struct gfs2_holder ri_gh; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 285 | int error; |
| 286 | |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 287 | error = gfs2_rindex_hold(sdp, &ri_gh); |
| 288 | if (error) |
| 289 | return error; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 290 | |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 291 | gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); |
| 292 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); |
| 293 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 294 | rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr); |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 295 | gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, ghs + 2); |
| 296 | |
| 297 | |
Steven Whitehouse | 8497a46 | 2007-08-26 14:23:56 +0100 | [diff] [blame] | 298 | error = gfs2_glock_nq(ghs); /* parent */ |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 299 | if (error) |
Steven Whitehouse | 8497a46 | 2007-08-26 14:23:56 +0100 | [diff] [blame] | 300 | goto out_parent; |
| 301 | |
| 302 | error = gfs2_glock_nq(ghs + 1); /* child */ |
| 303 | if (error) |
| 304 | goto out_child; |
| 305 | |
| 306 | error = gfs2_glock_nq(ghs + 2); /* rgrp */ |
| 307 | if (error) |
| 308 | goto out_rgrp; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 309 | |
| 310 | error = gfs2_unlink_ok(dip, &dentry->d_name, ip); |
| 311 | if (error) |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 312 | goto out_gunlock; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 313 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 314 | error = gfs2_trans_begin(sdp, 2*RES_DINODE + RES_LEAF + RES_RG_BIT, 0); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 315 | if (error) |
Steven Whitehouse | 8497a46 | 2007-08-26 14:23:56 +0100 | [diff] [blame] | 316 | goto out_rgrp; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 317 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 318 | error = gfs2_dir_del(dip, &dentry->d_name); |
| 319 | if (error) |
| 320 | goto out_end_trans; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 321 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 322 | error = gfs2_change_nlink(ip, -1); |
| 323 | |
| 324 | out_end_trans: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 325 | gfs2_trans_end(sdp); |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 326 | out_gunlock: |
Steven Whitehouse | 8497a46 | 2007-08-26 14:23:56 +0100 | [diff] [blame] | 327 | gfs2_glock_dq(ghs + 2); |
| 328 | out_rgrp: |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 329 | gfs2_holder_uninit(ghs + 2); |
Steven Whitehouse | 8497a46 | 2007-08-26 14:23:56 +0100 | [diff] [blame] | 330 | gfs2_glock_dq(ghs + 1); |
| 331 | out_child: |
| 332 | gfs2_holder_uninit(ghs + 1); |
| 333 | gfs2_glock_dq(ghs); |
| 334 | out_parent: |
| 335 | gfs2_holder_uninit(ghs); |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 336 | gfs2_glock_dq_uninit(&ri_gh); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 337 | return error; |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * gfs2_symlink - Create a symlink |
| 342 | * @dir: The directory to create the symlink in |
| 343 | * @dentry: The dentry to put the symlink in |
| 344 | * @symname: The thing which the link points to |
| 345 | * |
| 346 | * Returns: errno |
| 347 | */ |
| 348 | |
| 349 | static int gfs2_symlink(struct inode *dir, struct dentry *dentry, |
| 350 | const char *symname) |
| 351 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 352 | struct gfs2_inode *dip = GFS2_I(dir), *ip; |
| 353 | struct gfs2_sbd *sdp = GFS2_SB(dir); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 354 | struct gfs2_holder ghs[2]; |
| 355 | struct inode *inode; |
| 356 | struct buffer_head *dibh; |
| 357 | int size; |
| 358 | int error; |
| 359 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 360 | /* Must be stuffed with a null terminator for gfs2_follow_link() */ |
| 361 | size = strlen(symname); |
| 362 | if (size > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode) - 1) |
| 363 | return -ENAMETOOLONG; |
| 364 | |
| 365 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); |
| 366 | |
Steven Whitehouse | e7f14f4 | 2006-10-31 21:45:08 -0500 | [diff] [blame] | 367 | inode = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO, 0); |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 368 | if (IS_ERR(inode)) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 369 | gfs2_holder_uninit(ghs); |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 370 | return PTR_ERR(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 373 | ip = ghs[1].gh_gl->gl_object; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 374 | |
| 375 | ip->i_di.di_size = size; |
| 376 | |
| 377 | error = gfs2_meta_inode_buffer(ip, &dibh); |
| 378 | |
| 379 | if (!gfs2_assert_withdraw(sdp, !error)) { |
Steven Whitehouse | 539e5d6 | 2006-10-31 15:07:05 -0500 | [diff] [blame] | 380 | gfs2_dinode_out(ip, dibh->b_data); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 381 | memcpy(dibh->b_data + sizeof(struct gfs2_dinode), symname, |
| 382 | size); |
| 383 | brelse(dibh); |
| 384 | } |
| 385 | |
| 386 | gfs2_trans_end(sdp); |
Steven Whitehouse | 6dbd822 | 2008-01-10 15:18:55 +0000 | [diff] [blame] | 387 | if (dip->i_alloc->al_rgd) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 388 | gfs2_inplace_release(dip); |
| 389 | gfs2_quota_unlock(dip); |
| 390 | gfs2_alloc_put(dip); |
| 391 | |
| 392 | gfs2_glock_dq_uninit_m(2, ghs); |
| 393 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 394 | d_instantiate(dentry, inode); |
| 395 | mark_inode_dirty(inode); |
| 396 | |
| 397 | return 0; |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * gfs2_mkdir - Make a directory |
| 402 | * @dir: The parent directory of the new one |
| 403 | * @dentry: The dentry of the new directory |
| 404 | * @mode: The mode of the new directory |
| 405 | * |
| 406 | * Returns: errno |
| 407 | */ |
| 408 | |
| 409 | static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
| 410 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 411 | struct gfs2_inode *dip = GFS2_I(dir), *ip; |
| 412 | struct gfs2_sbd *sdp = GFS2_SB(dir); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 413 | struct gfs2_holder ghs[2]; |
| 414 | struct inode *inode; |
| 415 | struct buffer_head *dibh; |
| 416 | int error; |
| 417 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 418 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); |
| 419 | |
Steven Whitehouse | e7f14f4 | 2006-10-31 21:45:08 -0500 | [diff] [blame] | 420 | inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode, 0); |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 421 | if (IS_ERR(inode)) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 422 | gfs2_holder_uninit(ghs); |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 423 | return PTR_ERR(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 424 | } |
| 425 | |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 426 | ip = ghs[1].gh_gl->gl_object; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 427 | |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 428 | ip->i_inode.i_nlink = 2; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 429 | ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode); |
| 430 | ip->i_di.di_flags |= GFS2_DIF_JDATA; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 431 | ip->i_di.di_entries = 2; |
| 432 | |
| 433 | error = gfs2_meta_inode_buffer(ip, &dibh); |
| 434 | |
| 435 | if (!gfs2_assert_withdraw(sdp, !error)) { |
| 436 | struct gfs2_dinode *di = (struct gfs2_dinode *)dibh->b_data; |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 437 | struct gfs2_dirent *dent = (struct gfs2_dirent *)(di+1); |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 438 | struct qstr str; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 439 | |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 440 | gfs2_str2qstr(&str, "."); |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 441 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
| 442 | gfs2_qstr2dirent(&str, GFS2_DIRENT_SIZE(str.len), dent); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 443 | dent->de_inum = di->di_num; /* already GFS2 endian */ |
Steven Whitehouse | 7ecdb70 | 2006-10-03 21:03:35 -0400 | [diff] [blame] | 444 | dent->de_type = cpu_to_be16(DT_DIR); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 445 | di->di_entries = cpu_to_be32(1); |
| 446 | |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 447 | gfs2_str2qstr(&str, ".."); |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 448 | dent = (struct gfs2_dirent *)((char*)dent + GFS2_DIRENT_SIZE(1)); |
| 449 | gfs2_qstr2dirent(&str, dibh->b_size - GFS2_DIRENT_SIZE(1) - sizeof(struct gfs2_dinode), dent); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 450 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 451 | gfs2_inum_out(dip, dent); |
Steven Whitehouse | 7ecdb70 | 2006-10-03 21:03:35 -0400 | [diff] [blame] | 452 | dent->de_type = cpu_to_be16(DT_DIR); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 453 | |
Steven Whitehouse | 539e5d6 | 2006-10-31 15:07:05 -0500 | [diff] [blame] | 454 | gfs2_dinode_out(ip, di); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 455 | |
| 456 | brelse(dibh); |
| 457 | } |
| 458 | |
| 459 | error = gfs2_change_nlink(dip, +1); |
| 460 | gfs2_assert_withdraw(sdp, !error); /* dip already pinned */ |
| 461 | |
| 462 | gfs2_trans_end(sdp); |
Steven Whitehouse | 6dbd822 | 2008-01-10 15:18:55 +0000 | [diff] [blame] | 463 | if (dip->i_alloc->al_rgd) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 464 | gfs2_inplace_release(dip); |
| 465 | gfs2_quota_unlock(dip); |
| 466 | gfs2_alloc_put(dip); |
| 467 | |
| 468 | gfs2_glock_dq_uninit_m(2, ghs); |
| 469 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 470 | d_instantiate(dentry, inode); |
| 471 | mark_inode_dirty(inode); |
| 472 | |
| 473 | return 0; |
| 474 | } |
| 475 | |
| 476 | /** |
| 477 | * gfs2_rmdir - Remove a directory |
| 478 | * @dir: The parent directory of the directory to be removed |
| 479 | * @dentry: The dentry of the directory to remove |
| 480 | * |
| 481 | * Remove a directory. Call gfs2_rmdiri() |
| 482 | * |
| 483 | * Returns: errno |
| 484 | */ |
| 485 | |
| 486 | static int gfs2_rmdir(struct inode *dir, struct dentry *dentry) |
| 487 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 488 | struct gfs2_inode *dip = GFS2_I(dir); |
| 489 | struct gfs2_sbd *sdp = GFS2_SB(dir); |
| 490 | struct gfs2_inode *ip = GFS2_I(dentry->d_inode); |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 491 | struct gfs2_holder ghs[3]; |
| 492 | struct gfs2_rgrpd *rgd; |
| 493 | struct gfs2_holder ri_gh; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 494 | int error; |
| 495 | |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 496 | error = gfs2_rindex_hold(sdp, &ri_gh); |
| 497 | if (error) |
| 498 | return error; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 499 | gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); |
| 500 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); |
| 501 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 502 | rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr); |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 503 | gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, ghs + 2); |
| 504 | |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 505 | error = gfs2_glock_nq(ghs); /* parent */ |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 506 | if (error) |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 507 | goto out_parent; |
| 508 | |
| 509 | error = gfs2_glock_nq(ghs + 1); /* child */ |
| 510 | if (error) |
| 511 | goto out_child; |
| 512 | |
| 513 | error = gfs2_glock_nq(ghs + 2); /* rgrp */ |
| 514 | if (error) |
| 515 | goto out_rgrp; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 516 | |
| 517 | error = gfs2_unlink_ok(dip, &dentry->d_name, ip); |
| 518 | if (error) |
| 519 | goto out_gunlock; |
| 520 | |
| 521 | if (ip->i_di.di_entries < 2) { |
| 522 | if (gfs2_consist_inode(ip)) |
Steven Whitehouse | 4cc14f0 | 2006-10-31 19:00:24 -0500 | [diff] [blame] | 523 | gfs2_dinode_print(ip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 524 | error = -EIO; |
| 525 | goto out_gunlock; |
| 526 | } |
| 527 | if (ip->i_di.di_entries > 2) { |
| 528 | error = -ENOTEMPTY; |
| 529 | goto out_gunlock; |
| 530 | } |
| 531 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 532 | error = gfs2_trans_begin(sdp, 2 * RES_DINODE + 3 * RES_LEAF + RES_RG_BIT, 0); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 533 | if (error) |
| 534 | goto out_gunlock; |
| 535 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 536 | error = gfs2_rmdiri(dip, &dentry->d_name, ip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 537 | |
| 538 | gfs2_trans_end(sdp); |
| 539 | |
Steven Whitehouse | a91ea69 | 2006-09-04 12:04:26 -0400 | [diff] [blame] | 540 | out_gunlock: |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 541 | gfs2_glock_dq(ghs + 2); |
| 542 | out_rgrp: |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 543 | gfs2_holder_uninit(ghs + 2); |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 544 | gfs2_glock_dq(ghs + 1); |
| 545 | out_child: |
| 546 | gfs2_holder_uninit(ghs + 1); |
| 547 | gfs2_glock_dq(ghs); |
| 548 | out_parent: |
| 549 | gfs2_holder_uninit(ghs); |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 550 | gfs2_glock_dq_uninit(&ri_gh); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 551 | return error; |
| 552 | } |
| 553 | |
| 554 | /** |
| 555 | * gfs2_mknod - Make a special file |
| 556 | * @dir: The directory in which the special file will reside |
| 557 | * @dentry: The dentry of the special file |
| 558 | * @mode: The mode of the special file |
| 559 | * @rdev: The device specification of the special file |
| 560 | * |
| 561 | */ |
| 562 | |
| 563 | static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, |
| 564 | dev_t dev) |
| 565 | { |
Steven Whitehouse | e7f14f4 | 2006-10-31 21:45:08 -0500 | [diff] [blame] | 566 | struct gfs2_inode *dip = GFS2_I(dir); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 567 | struct gfs2_sbd *sdp = GFS2_SB(dir); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 568 | struct gfs2_holder ghs[2]; |
| 569 | struct inode *inode; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 570 | |
| 571 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); |
| 572 | |
Steven Whitehouse | e7f14f4 | 2006-10-31 21:45:08 -0500 | [diff] [blame] | 573 | inode = gfs2_createi(ghs, &dentry->d_name, mode, dev); |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 574 | if (IS_ERR(inode)) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 575 | gfs2_holder_uninit(ghs); |
Steven Whitehouse | 7359a19 | 2006-02-13 12:27:43 +0000 | [diff] [blame] | 576 | return PTR_ERR(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 577 | } |
| 578 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 579 | gfs2_trans_end(sdp); |
Steven Whitehouse | 6dbd822 | 2008-01-10 15:18:55 +0000 | [diff] [blame] | 580 | if (dip->i_alloc->al_rgd) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 581 | gfs2_inplace_release(dip); |
| 582 | gfs2_quota_unlock(dip); |
| 583 | gfs2_alloc_put(dip); |
| 584 | |
| 585 | gfs2_glock_dq_uninit_m(2, ghs); |
| 586 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 587 | d_instantiate(dentry, inode); |
| 588 | mark_inode_dirty(inode); |
| 589 | |
| 590 | return 0; |
| 591 | } |
| 592 | |
Steven Whitehouse | 0188d6c | 2008-08-26 09:38:26 +0100 | [diff] [blame] | 593 | /* |
| 594 | * gfs2_ok_to_move - check if it's ok to move a directory to another directory |
| 595 | * @this: move this |
| 596 | * @to: to here |
| 597 | * |
| 598 | * Follow @to back to the root and make sure we don't encounter @this |
| 599 | * Assumes we already hold the rename lock. |
| 600 | * |
| 601 | * Returns: errno |
| 602 | */ |
| 603 | |
| 604 | static int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to) |
| 605 | { |
| 606 | struct inode *dir = &to->i_inode; |
| 607 | struct super_block *sb = dir->i_sb; |
| 608 | struct inode *tmp; |
| 609 | struct qstr dotdot; |
| 610 | int error = 0; |
| 611 | |
| 612 | gfs2_str2qstr(&dotdot, ".."); |
| 613 | |
| 614 | igrab(dir); |
| 615 | |
| 616 | for (;;) { |
| 617 | if (dir == &this->i_inode) { |
| 618 | error = -EINVAL; |
| 619 | break; |
| 620 | } |
| 621 | if (dir == sb->s_root->d_inode) { |
| 622 | error = 0; |
| 623 | break; |
| 624 | } |
| 625 | |
| 626 | tmp = gfs2_lookupi(dir, &dotdot, 1); |
| 627 | if (IS_ERR(tmp)) { |
| 628 | error = PTR_ERR(tmp); |
| 629 | break; |
| 630 | } |
| 631 | |
| 632 | iput(dir); |
| 633 | dir = tmp; |
| 634 | } |
| 635 | |
| 636 | iput(dir); |
| 637 | |
| 638 | return error; |
| 639 | } |
| 640 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 641 | /** |
| 642 | * gfs2_rename - Rename a file |
| 643 | * @odir: Parent directory of old file name |
| 644 | * @odentry: The old dentry of the file |
| 645 | * @ndir: Parent directory of new file name |
| 646 | * @ndentry: The new dentry of the file |
| 647 | * |
| 648 | * Returns: errno |
| 649 | */ |
| 650 | |
| 651 | static int gfs2_rename(struct inode *odir, struct dentry *odentry, |
| 652 | struct inode *ndir, struct dentry *ndentry) |
| 653 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 654 | struct gfs2_inode *odip = GFS2_I(odir); |
| 655 | struct gfs2_inode *ndip = GFS2_I(ndir); |
| 656 | struct gfs2_inode *ip = GFS2_I(odentry->d_inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 657 | struct gfs2_inode *nip = NULL; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 658 | struct gfs2_sbd *sdp = GFS2_SB(odir); |
Steven Whitehouse | 0188d6c | 2008-08-26 09:38:26 +0100 | [diff] [blame] | 659 | struct gfs2_holder ghs[5], r_gh = { .gh_gl = NULL, }; |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 660 | struct gfs2_rgrpd *nrgd; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 661 | unsigned int num_gh; |
| 662 | int dir_rename = 0; |
| 663 | int alloc_required; |
| 664 | unsigned int x; |
| 665 | int error; |
| 666 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 667 | if (ndentry->d_inode) { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 668 | nip = GFS2_I(ndentry->d_inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 669 | if (ip == nip) |
| 670 | return 0; |
| 671 | } |
| 672 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 673 | |
Steven Whitehouse | 0188d6c | 2008-08-26 09:38:26 +0100 | [diff] [blame] | 674 | if (odip != ndip) { |
| 675 | error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE, |
| 676 | 0, &r_gh); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 677 | if (error) |
| 678 | goto out; |
| 679 | |
Steven Whitehouse | 0188d6c | 2008-08-26 09:38:26 +0100 | [diff] [blame] | 680 | if (S_ISDIR(ip->i_inode.i_mode)) { |
| 681 | dir_rename = 1; |
| 682 | /* don't move a dirctory into it's subdir */ |
| 683 | error = gfs2_ok_to_move(ip, ndip); |
| 684 | if (error) |
| 685 | goto out_gunlock_r; |
| 686 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 687 | } |
| 688 | |
Steven Whitehouse | d9d1ca3 | 2006-06-21 15:38:17 -0400 | [diff] [blame] | 689 | num_gh = 1; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 690 | gfs2_holder_init(odip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); |
Steven Whitehouse | d9d1ca3 | 2006-06-21 15:38:17 -0400 | [diff] [blame] | 691 | if (odip != ndip) { |
| 692 | gfs2_holder_init(ndip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh); |
| 693 | num_gh++; |
| 694 | } |
| 695 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh); |
| 696 | num_gh++; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 697 | |
Steven Whitehouse | d9d1ca3 | 2006-06-21 15:38:17 -0400 | [diff] [blame] | 698 | if (nip) { |
| 699 | gfs2_holder_init(nip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh); |
| 700 | num_gh++; |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 701 | /* grab the resource lock for unlink flag twiddling |
| 702 | * this is the case of the target file already existing |
| 703 | * so we unlink before doing the rename |
| 704 | */ |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 705 | nrgd = gfs2_blk2rgrpd(sdp, nip->i_no_addr); |
Russell Cattelan | ddee760 | 2007-01-29 17:13:44 -0600 | [diff] [blame] | 706 | if (nrgd) |
| 707 | gfs2_holder_init(nrgd->rd_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh++); |
Steven Whitehouse | d9d1ca3 | 2006-06-21 15:38:17 -0400 | [diff] [blame] | 708 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 709 | |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 710 | for (x = 0; x < num_gh; x++) { |
| 711 | error = gfs2_glock_nq(ghs + x); |
| 712 | if (error) |
| 713 | goto out_gunlock; |
| 714 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 715 | |
| 716 | /* Check out the old directory */ |
| 717 | |
| 718 | error = gfs2_unlink_ok(odip, &odentry->d_name, ip); |
| 719 | if (error) |
| 720 | goto out_gunlock; |
| 721 | |
| 722 | /* Check out the new directory */ |
| 723 | |
| 724 | if (nip) { |
| 725 | error = gfs2_unlink_ok(ndip, &ndentry->d_name, nip); |
| 726 | if (error) |
| 727 | goto out_gunlock; |
| 728 | |
Steven Whitehouse | b60623c | 2006-11-01 12:22:46 -0500 | [diff] [blame] | 729 | if (S_ISDIR(nip->i_inode.i_mode)) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 730 | if (nip->i_di.di_entries < 2) { |
| 731 | if (gfs2_consist_inode(nip)) |
Steven Whitehouse | 4cc14f0 | 2006-10-31 19:00:24 -0500 | [diff] [blame] | 732 | gfs2_dinode_print(nip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 733 | error = -EIO; |
| 734 | goto out_gunlock; |
| 735 | } |
| 736 | if (nip->i_di.di_entries > 2) { |
| 737 | error = -ENOTEMPTY; |
| 738 | goto out_gunlock; |
| 739 | } |
| 740 | } |
| 741 | } else { |
Miklos Szeredi | f58ba88 | 2008-07-02 21:12:01 +0200 | [diff] [blame] | 742 | error = gfs2_permission(ndir, MAY_WRITE | MAY_EXEC); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 743 | if (error) |
| 744 | goto out_gunlock; |
| 745 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 746 | error = gfs2_dir_check(ndir, &ndentry->d_name, NULL); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 747 | switch (error) { |
| 748 | case -ENOENT: |
| 749 | error = 0; |
| 750 | break; |
| 751 | case 0: |
| 752 | error = -EEXIST; |
| 753 | default: |
| 754 | goto out_gunlock; |
| 755 | }; |
| 756 | |
| 757 | if (odip != ndip) { |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 758 | if (!ndip->i_inode.i_nlink) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 759 | error = -EINVAL; |
| 760 | goto out_gunlock; |
| 761 | } |
Steven Whitehouse | cd91549 | 2006-09-04 12:49:07 -0400 | [diff] [blame] | 762 | if (ndip->i_di.di_entries == (u32)-1) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 763 | error = -EFBIG; |
| 764 | goto out_gunlock; |
| 765 | } |
Steven Whitehouse | b60623c | 2006-11-01 12:22:46 -0500 | [diff] [blame] | 766 | if (S_ISDIR(ip->i_inode.i_mode) && |
Steven Whitehouse | 4f56110 | 2006-11-01 14:04:17 -0500 | [diff] [blame] | 767 | ndip->i_inode.i_nlink == (u32)-1) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 768 | error = -EMLINK; |
| 769 | goto out_gunlock; |
| 770 | } |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | /* Check out the dir to be renamed */ |
| 775 | |
| 776 | if (dir_rename) { |
Miklos Szeredi | f58ba88 | 2008-07-02 21:12:01 +0200 | [diff] [blame] | 777 | error = gfs2_permission(odentry->d_inode, MAY_WRITE); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 778 | if (error) |
| 779 | goto out_gunlock; |
| 780 | } |
| 781 | |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 782 | alloc_required = error = gfs2_diradd_alloc_required(ndir, &ndentry->d_name); |
| 783 | if (error < 0) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 784 | goto out_gunlock; |
Steven Whitehouse | c752666 | 2006-03-20 12:30:04 -0500 | [diff] [blame] | 785 | error = 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 786 | |
| 787 | if (alloc_required) { |
| 788 | struct gfs2_alloc *al = gfs2_alloc_get(ndip); |
Cyrill Gorcunov | 182fe5a | 2008-03-03 21:54:21 +0300 | [diff] [blame] | 789 | if (!al) { |
| 790 | error = -ENOMEM; |
| 791 | goto out_gunlock; |
| 792 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 793 | |
Steven Whitehouse | d82661d | 2008-03-10 15:34:50 +0000 | [diff] [blame] | 794 | error = gfs2_quota_lock_check(ndip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 795 | if (error) |
| 796 | goto out_alloc; |
| 797 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 798 | al->al_requested = sdp->sd_max_dirres; |
| 799 | |
| 800 | error = gfs2_inplace_reserve(ndip); |
| 801 | if (error) |
| 802 | goto out_gunlock_q; |
| 803 | |
Steven Whitehouse | fe1bded | 2006-04-18 10:09:15 -0400 | [diff] [blame] | 804 | error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + |
Steven Whitehouse | bb8d8a6 | 2007-06-01 14:11:58 +0100 | [diff] [blame] | 805 | al->al_rgd->rd_length + |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 806 | 4 * RES_DINODE + 4 * RES_LEAF + |
S. Wendy Cheng | 87d21e0 | 2007-01-18 16:07:03 -0500 | [diff] [blame] | 807 | RES_STATFS + RES_QUOTA + 4, 0); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 808 | if (error) |
| 809 | goto out_ipreserv; |
| 810 | } else { |
| 811 | error = gfs2_trans_begin(sdp, 4 * RES_DINODE + |
S. Wendy Cheng | 87d21e0 | 2007-01-18 16:07:03 -0500 | [diff] [blame] | 812 | 5 * RES_LEAF + 4, 0); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 813 | if (error) |
| 814 | goto out_gunlock; |
| 815 | } |
| 816 | |
| 817 | /* Remove the target file, if it exists */ |
| 818 | |
| 819 | if (nip) { |
Steven Whitehouse | b60623c | 2006-11-01 12:22:46 -0500 | [diff] [blame] | 820 | if (S_ISDIR(nip->i_inode.i_mode)) |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 821 | error = gfs2_rmdiri(ndip, &ndentry->d_name, nip); |
| 822 | else { |
| 823 | error = gfs2_dir_del(ndip, &ndentry->d_name); |
| 824 | if (error) |
| 825 | goto out_end_trans; |
S. Wendy Cheng | 87d21e0 | 2007-01-18 16:07:03 -0500 | [diff] [blame] | 826 | error = gfs2_change_nlink(nip, -1); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 827 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 828 | if (error) |
| 829 | goto out_end_trans; |
| 830 | } |
| 831 | |
| 832 | if (dir_rename) { |
| 833 | struct qstr name; |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 834 | gfs2_str2qstr(&name, ".."); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 835 | |
| 836 | error = gfs2_change_nlink(ndip, +1); |
| 837 | if (error) |
| 838 | goto out_end_trans; |
| 839 | error = gfs2_change_nlink(odip, -1); |
| 840 | if (error) |
| 841 | goto out_end_trans; |
| 842 | |
Steven Whitehouse | ffed8ab | 2007-06-07 11:29:35 +0100 | [diff] [blame] | 843 | error = gfs2_dir_mvino(ip, &name, ndip, DT_DIR); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 844 | if (error) |
| 845 | goto out_end_trans; |
| 846 | } else { |
| 847 | struct buffer_head *dibh; |
| 848 | error = gfs2_meta_inode_buffer(ip, &dibh); |
| 849 | if (error) |
| 850 | goto out_end_trans; |
Steven Whitehouse | 4bd91ba | 2007-06-05 09:39:18 +0100 | [diff] [blame] | 851 | ip->i_inode.i_ctime = CURRENT_TIME; |
Steven Whitehouse | d4e9c4c | 2006-01-18 11:19:28 +0000 | [diff] [blame] | 852 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
Steven Whitehouse | 539e5d6 | 2006-10-31 15:07:05 -0500 | [diff] [blame] | 853 | gfs2_dinode_out(ip, dibh->b_data); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 854 | brelse(dibh); |
| 855 | } |
| 856 | |
| 857 | error = gfs2_dir_del(odip, &odentry->d_name); |
| 858 | if (error) |
| 859 | goto out_end_trans; |
| 860 | |
Steven Whitehouse | dbb7cae | 2007-05-15 15:37:50 +0100 | [diff] [blame] | 861 | error = gfs2_dir_add(ndir, &ndentry->d_name, ip, IF2DT(ip->i_inode.i_mode)); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 862 | if (error) |
| 863 | goto out_end_trans; |
| 864 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 865 | out_end_trans: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 866 | gfs2_trans_end(sdp); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 867 | out_ipreserv: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 868 | if (alloc_required) |
| 869 | gfs2_inplace_release(ndip); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 870 | out_gunlock_q: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 871 | if (alloc_required) |
| 872 | gfs2_quota_unlock(ndip); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 873 | out_alloc: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 874 | if (alloc_required) |
| 875 | gfs2_alloc_put(ndip); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 876 | out_gunlock: |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 877 | while (x--) { |
| 878 | gfs2_glock_dq(ghs + x); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 879 | gfs2_holder_uninit(ghs + x); |
Bob Peterson | 72dbf47 | 2008-08-12 13:39:29 -0500 | [diff] [blame] | 880 | } |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 881 | out_gunlock_r: |
Steven Whitehouse | 0188d6c | 2008-08-26 09:38:26 +0100 | [diff] [blame] | 882 | if (r_gh.gh_gl) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 883 | gfs2_glock_dq_uninit(&r_gh); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 884 | out: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 885 | return error; |
| 886 | } |
| 887 | |
| 888 | /** |
| 889 | * gfs2_readlink - Read the value of a symlink |
| 890 | * @dentry: the symlink |
| 891 | * @buf: the buffer to read the symlink data into |
| 892 | * @size: the size of the buffer |
| 893 | * |
| 894 | * Returns: errno |
| 895 | */ |
| 896 | |
| 897 | static int gfs2_readlink(struct dentry *dentry, char __user *user_buf, |
| 898 | int user_size) |
| 899 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 900 | struct gfs2_inode *ip = GFS2_I(dentry->d_inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 901 | char array[GFS2_FAST_NAME_SIZE], *buf = array; |
| 902 | unsigned int len = GFS2_FAST_NAME_SIZE; |
| 903 | int error; |
| 904 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 905 | error = gfs2_readlinki(ip, &buf, &len); |
| 906 | if (error) |
| 907 | return error; |
| 908 | |
| 909 | if (user_size > len - 1) |
| 910 | user_size = len - 1; |
| 911 | |
| 912 | if (copy_to_user(user_buf, buf, user_size)) |
| 913 | error = -EFAULT; |
| 914 | else |
| 915 | error = user_size; |
| 916 | |
| 917 | if (buf != array) |
| 918 | kfree(buf); |
| 919 | |
| 920 | return error; |
| 921 | } |
| 922 | |
| 923 | /** |
| 924 | * gfs2_follow_link - Follow a symbolic link |
| 925 | * @dentry: The dentry of the link |
| 926 | * @nd: Data that we pass to vfs_follow_link() |
| 927 | * |
| 928 | * This can handle symlinks of any size. It is optimised for symlinks |
| 929 | * under GFS2_FAST_NAME_SIZE. |
| 930 | * |
| 931 | * Returns: 0 on success or error code |
| 932 | */ |
| 933 | |
| 934 | static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) |
| 935 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 936 | struct gfs2_inode *ip = GFS2_I(dentry->d_inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 937 | char array[GFS2_FAST_NAME_SIZE], *buf = array; |
| 938 | unsigned int len = GFS2_FAST_NAME_SIZE; |
| 939 | int error; |
| 940 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 941 | error = gfs2_readlinki(ip, &buf, &len); |
| 942 | if (!error) { |
| 943 | error = vfs_follow_link(nd, buf); |
| 944 | if (buf != array) |
| 945 | kfree(buf); |
| 946 | } |
| 947 | |
| 948 | return ERR_PTR(error); |
| 949 | } |
| 950 | |
| 951 | /** |
| 952 | * gfs2_permission - |
| 953 | * @inode: |
| 954 | * @mask: |
| 955 | * @nd: passed from Linux VFS, ignored by us |
| 956 | * |
Steven Whitehouse | 300c7d7 | 2006-11-27 09:55:28 -0500 | [diff] [blame] | 957 | * This may be called from the VFS directly, or from within GFS2 with the |
| 958 | * inode locked, so we look to see if the glock is already locked and only |
| 959 | * lock the glock if its not already been done. |
| 960 | * |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 961 | * Returns: errno |
| 962 | */ |
| 963 | |
Miklos Szeredi | f58ba88 | 2008-07-02 21:12:01 +0200 | [diff] [blame] | 964 | int gfs2_permission(struct inode *inode, int mask) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 965 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 966 | struct gfs2_inode *ip = GFS2_I(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 967 | struct gfs2_holder i_gh; |
| 968 | int error; |
Steven Whitehouse | 300c7d7 | 2006-11-27 09:55:28 -0500 | [diff] [blame] | 969 | int unlock = 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 970 | |
Steven Whitehouse | 7afd88d | 2008-02-22 16:07:18 +0000 | [diff] [blame] | 971 | if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) { |
Steven Whitehouse | 300c7d7 | 2006-11-27 09:55:28 -0500 | [diff] [blame] | 972 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh); |
| 973 | if (error) |
| 974 | return error; |
| 975 | unlock = 1; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 976 | } |
| 977 | |
Miklos Szeredi | f58ba88 | 2008-07-02 21:12:01 +0200 | [diff] [blame] | 978 | if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode)) |
| 979 | error = -EACCES; |
| 980 | else |
| 981 | error = generic_permission(inode, mask, gfs2_check_acl); |
Steven Whitehouse | 300c7d7 | 2006-11-27 09:55:28 -0500 | [diff] [blame] | 982 | if (unlock) |
| 983 | gfs2_glock_dq_uninit(&i_gh); |
| 984 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 985 | return error; |
| 986 | } |
| 987 | |
| 988 | static int setattr_size(struct inode *inode, struct iattr *attr) |
| 989 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 990 | struct gfs2_inode *ip = GFS2_I(inode); |
Steven Whitehouse | 16615be | 2007-09-17 10:59:52 +0100 | [diff] [blame] | 991 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 992 | int error; |
| 993 | |
| 994 | if (attr->ia_size != ip->i_di.di_size) { |
Steven Whitehouse | 16615be | 2007-09-17 10:59:52 +0100 | [diff] [blame] | 995 | error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 996 | if (error) |
| 997 | return error; |
Steven Whitehouse | 16615be | 2007-09-17 10:59:52 +0100 | [diff] [blame] | 998 | error = vmtruncate(inode, attr->ia_size); |
| 999 | gfs2_trans_end(sdp); |
| 1000 | if (error) |
| 1001 | return error; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1002 | } |
| 1003 | |
Steven Whitehouse | aa6a85a | 2006-01-24 10:37:06 +0000 | [diff] [blame] | 1004 | error = gfs2_truncatei(ip, attr->ia_size); |
Wendy Cheng | 090ffaa | 2007-06-27 11:00:03 -0400 | [diff] [blame] | 1005 | if (error && (inode->i_size != ip->i_di.di_size)) |
| 1006 | i_size_write(inode, ip->i_di.di_size); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1007 | |
| 1008 | return error; |
| 1009 | } |
| 1010 | |
| 1011 | static int setattr_chown(struct inode *inode, struct iattr *attr) |
| 1012 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 1013 | struct gfs2_inode *ip = GFS2_I(inode); |
| 1014 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1015 | struct buffer_head *dibh; |
Steven Whitehouse | cd91549 | 2006-09-04 12:49:07 -0400 | [diff] [blame] | 1016 | u32 ouid, ogid, nuid, ngid; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1017 | int error; |
| 1018 | |
Steven Whitehouse | 2933f92 | 2006-11-01 13:23:29 -0500 | [diff] [blame] | 1019 | ouid = inode->i_uid; |
| 1020 | ogid = inode->i_gid; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1021 | nuid = attr->ia_uid; |
| 1022 | ngid = attr->ia_gid; |
| 1023 | |
| 1024 | if (!(attr->ia_valid & ATTR_UID) || ouid == nuid) |
| 1025 | ouid = nuid = NO_QUOTA_CHANGE; |
| 1026 | if (!(attr->ia_valid & ATTR_GID) || ogid == ngid) |
| 1027 | ogid = ngid = NO_QUOTA_CHANGE; |
| 1028 | |
Cyrill Gorcunov | 182fe5a | 2008-03-03 21:54:21 +0300 | [diff] [blame] | 1029 | if (!gfs2_alloc_get(ip)) |
| 1030 | return -ENOMEM; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1031 | |
| 1032 | error = gfs2_quota_lock(ip, nuid, ngid); |
| 1033 | if (error) |
| 1034 | goto out_alloc; |
| 1035 | |
| 1036 | if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) { |
| 1037 | error = gfs2_quota_check(ip, nuid, ngid); |
| 1038 | if (error) |
| 1039 | goto out_gunlock_q; |
| 1040 | } |
| 1041 | |
| 1042 | error = gfs2_trans_begin(sdp, RES_DINODE + 2 * RES_QUOTA, 0); |
| 1043 | if (error) |
| 1044 | goto out_gunlock_q; |
| 1045 | |
| 1046 | error = gfs2_meta_inode_buffer(ip, &dibh); |
| 1047 | if (error) |
| 1048 | goto out_end_trans; |
| 1049 | |
| 1050 | error = inode_setattr(inode, attr); |
| 1051 | gfs2_assert_warn(sdp, !error); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1052 | |
Steven Whitehouse | d4e9c4c | 2006-01-18 11:19:28 +0000 | [diff] [blame] | 1053 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
Steven Whitehouse | 539e5d6 | 2006-10-31 15:07:05 -0500 | [diff] [blame] | 1054 | gfs2_dinode_out(ip, dibh->b_data); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1055 | brelse(dibh); |
| 1056 | |
| 1057 | if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) { |
Steven Whitehouse | 77658aa | 2008-02-12 14:17:27 +0000 | [diff] [blame] | 1058 | u64 blocks = gfs2_get_inode_blocks(&ip->i_inode); |
| 1059 | gfs2_quota_change(ip, -blocks, ouid, ogid); |
| 1060 | gfs2_quota_change(ip, blocks, nuid, ngid); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1061 | } |
| 1062 | |
Steven Whitehouse | a91ea69 | 2006-09-04 12:04:26 -0400 | [diff] [blame] | 1063 | out_end_trans: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1064 | gfs2_trans_end(sdp); |
Steven Whitehouse | a91ea69 | 2006-09-04 12:04:26 -0400 | [diff] [blame] | 1065 | out_gunlock_q: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1066 | gfs2_quota_unlock(ip); |
Steven Whitehouse | a91ea69 | 2006-09-04 12:04:26 -0400 | [diff] [blame] | 1067 | out_alloc: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1068 | gfs2_alloc_put(ip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1069 | return error; |
| 1070 | } |
| 1071 | |
| 1072 | /** |
| 1073 | * gfs2_setattr - Change attributes on an inode |
| 1074 | * @dentry: The dentry which is changing |
| 1075 | * @attr: The structure describing the change |
| 1076 | * |
| 1077 | * The VFS layer wants to change one or more of an inodes attributes. Write |
| 1078 | * that change out to disk. |
| 1079 | * |
| 1080 | * Returns: errno |
| 1081 | */ |
| 1082 | |
| 1083 | static int gfs2_setattr(struct dentry *dentry, struct iattr *attr) |
| 1084 | { |
| 1085 | struct inode *inode = dentry->d_inode; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 1086 | struct gfs2_inode *ip = GFS2_I(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1087 | struct gfs2_holder i_gh; |
| 1088 | int error; |
| 1089 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1090 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh); |
| 1091 | if (error) |
| 1092 | return error; |
| 1093 | |
| 1094 | error = -EPERM; |
| 1095 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
| 1096 | goto out; |
| 1097 | |
| 1098 | error = inode_change_ok(inode, attr); |
| 1099 | if (error) |
| 1100 | goto out; |
| 1101 | |
| 1102 | if (attr->ia_valid & ATTR_SIZE) |
| 1103 | error = setattr_size(inode, attr); |
| 1104 | else if (attr->ia_valid & (ATTR_UID | ATTR_GID)) |
| 1105 | error = setattr_chown(inode, attr); |
| 1106 | else if ((attr->ia_valid & ATTR_MODE) && IS_POSIXACL(inode)) |
| 1107 | error = gfs2_acl_chmod(ip, attr); |
| 1108 | else |
| 1109 | error = gfs2_setattr_simple(ip, attr); |
| 1110 | |
Steven Whitehouse | a91ea69 | 2006-09-04 12:04:26 -0400 | [diff] [blame] | 1111 | out: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1112 | gfs2_glock_dq_uninit(&i_gh); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1113 | if (!error) |
| 1114 | mark_inode_dirty(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1115 | return error; |
| 1116 | } |
| 1117 | |
| 1118 | /** |
| 1119 | * gfs2_getattr - Read out an inode's attributes |
Steven Whitehouse | 26c1a57 | 2006-09-04 15:32:10 -0400 | [diff] [blame] | 1120 | * @mnt: The vfsmount the inode is being accessed from |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1121 | * @dentry: The dentry to stat |
| 1122 | * @stat: The inode's stats |
| 1123 | * |
Steven Whitehouse | dcf3dd8 | 2006-11-27 10:12:05 -0500 | [diff] [blame] | 1124 | * This may be called from the VFS directly, or from within GFS2 with the |
| 1125 | * inode locked, so we look to see if the glock is already locked and only |
| 1126 | * lock the glock if its not already been done. Note that its the NFS |
| 1127 | * readdirplus operation which causes this to be called (from filldir) |
| 1128 | * with the glock already held. |
| 1129 | * |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1130 | * Returns: errno |
| 1131 | */ |
| 1132 | |
| 1133 | static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, |
| 1134 | struct kstat *stat) |
| 1135 | { |
| 1136 | struct inode *inode = dentry->d_inode; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 1137 | struct gfs2_inode *ip = GFS2_I(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1138 | struct gfs2_holder gh; |
| 1139 | int error; |
Steven Whitehouse | dcf3dd8 | 2006-11-27 10:12:05 -0500 | [diff] [blame] | 1140 | int unlock = 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1141 | |
Steven Whitehouse | 7afd88d | 2008-02-22 16:07:18 +0000 | [diff] [blame] | 1142 | if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) { |
Steven Whitehouse | dcf3dd8 | 2006-11-27 10:12:05 -0500 | [diff] [blame] | 1143 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); |
| 1144 | if (error) |
| 1145 | return error; |
| 1146 | unlock = 1; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1147 | } |
| 1148 | |
Steven Whitehouse | dcf3dd8 | 2006-11-27 10:12:05 -0500 | [diff] [blame] | 1149 | generic_fillattr(inode, stat); |
Steven Whitehouse | d7c103d | 2007-01-25 17:14:59 +0000 | [diff] [blame] | 1150 | if (unlock) |
Steven Whitehouse | dcf3dd8 | 2006-11-27 10:12:05 -0500 | [diff] [blame] | 1151 | gfs2_glock_dq_uninit(&gh); |
| 1152 | |
| 1153 | return 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1154 | } |
| 1155 | |
| 1156 | static int gfs2_setxattr(struct dentry *dentry, const char *name, |
| 1157 | const void *data, size_t size, int flags) |
| 1158 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 1159 | struct inode *inode = dentry->d_inode; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1160 | struct gfs2_ea_request er; |
| 1161 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1162 | memset(&er, 0, sizeof(struct gfs2_ea_request)); |
| 1163 | er.er_type = gfs2_ea_name2type(name, &er.er_name); |
| 1164 | if (er.er_type == GFS2_EATYPE_UNUSED) |
| 1165 | return -EOPNOTSUPP; |
| 1166 | er.er_data = (char *)data; |
| 1167 | er.er_name_len = strlen(er.er_name); |
| 1168 | er.er_data_len = size; |
| 1169 | er.er_flags = flags; |
| 1170 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 1171 | gfs2_assert_warn(GFS2_SB(inode), !(er.er_flags & GFS2_ERF_MODE)); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1172 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 1173 | return gfs2_ea_set(GFS2_I(inode), &er); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | static ssize_t gfs2_getxattr(struct dentry *dentry, const char *name, |
| 1177 | void *data, size_t size) |
| 1178 | { |
| 1179 | struct gfs2_ea_request er; |
| 1180 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1181 | memset(&er, 0, sizeof(struct gfs2_ea_request)); |
| 1182 | er.er_type = gfs2_ea_name2type(name, &er.er_name); |
| 1183 | if (er.er_type == GFS2_EATYPE_UNUSED) |
| 1184 | return -EOPNOTSUPP; |
| 1185 | er.er_data = data; |
| 1186 | er.er_name_len = strlen(er.er_name); |
| 1187 | er.er_data_len = size; |
| 1188 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 1189 | return gfs2_ea_get(GFS2_I(dentry->d_inode), &er); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1190 | } |
| 1191 | |
| 1192 | static ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size) |
| 1193 | { |
| 1194 | struct gfs2_ea_request er; |
| 1195 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1196 | memset(&er, 0, sizeof(struct gfs2_ea_request)); |
| 1197 | er.er_data = (size) ? buffer : NULL; |
| 1198 | er.er_data_len = size; |
| 1199 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 1200 | return gfs2_ea_list(GFS2_I(dentry->d_inode), &er); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1201 | } |
| 1202 | |
| 1203 | static int gfs2_removexattr(struct dentry *dentry, const char *name) |
| 1204 | { |
| 1205 | struct gfs2_ea_request er; |
| 1206 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1207 | memset(&er, 0, sizeof(struct gfs2_ea_request)); |
| 1208 | er.er_type = gfs2_ea_name2type(name, &er.er_name); |
| 1209 | if (er.er_type == GFS2_EATYPE_UNUSED) |
| 1210 | return -EOPNOTSUPP; |
| 1211 | er.er_name_len = strlen(er.er_name); |
| 1212 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 1213 | return gfs2_ea_remove(GFS2_I(dentry->d_inode), &er); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1214 | } |
| 1215 | |
Steven Whitehouse | e9079cc | 2008-10-14 14:43:29 +0100 | [diff] [blame^] | 1216 | static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, |
| 1217 | u64 start, u64 len) |
| 1218 | { |
| 1219 | struct gfs2_inode *ip = GFS2_I(inode); |
| 1220 | struct gfs2_holder gh; |
| 1221 | int ret; |
| 1222 | |
| 1223 | ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC); |
| 1224 | if (ret) |
| 1225 | return ret; |
| 1226 | |
| 1227 | mutex_lock(&inode->i_mutex); |
| 1228 | |
| 1229 | ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh); |
| 1230 | if (ret) |
| 1231 | goto out; |
| 1232 | |
| 1233 | if (gfs2_is_stuffed(ip)) { |
| 1234 | u64 phys = ip->i_no_addr << inode->i_blkbits; |
| 1235 | u64 size = i_size_read(inode); |
| 1236 | u32 flags = FIEMAP_EXTENT_LAST|FIEMAP_EXTENT_NOT_ALIGNED| |
| 1237 | FIEMAP_EXTENT_DATA_INLINE; |
| 1238 | phys += sizeof(struct gfs2_dinode); |
| 1239 | phys += start; |
| 1240 | if (start + len > size) |
| 1241 | len = size - start; |
| 1242 | if (start < size) |
| 1243 | ret = fiemap_fill_next_extent(fieinfo, start, phys, |
| 1244 | len, flags); |
| 1245 | if (ret == 1) |
| 1246 | ret = 0; |
| 1247 | } else { |
| 1248 | ret = __generic_block_fiemap(inode, fieinfo, start, len, |
| 1249 | gfs2_block_map); |
| 1250 | } |
| 1251 | |
| 1252 | gfs2_glock_dq_uninit(&gh); |
| 1253 | out: |
| 1254 | mutex_unlock(&inode->i_mutex); |
| 1255 | return ret; |
| 1256 | } |
| 1257 | |
Arjan van de Ven | 92e1d5b | 2007-02-12 00:55:39 -0800 | [diff] [blame] | 1258 | const struct inode_operations gfs2_file_iops = { |
Al Viro | e6305c4 | 2008-07-15 21:03:57 -0400 | [diff] [blame] | 1259 | .permission = gfs2_permission, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1260 | .setattr = gfs2_setattr, |
| 1261 | .getattr = gfs2_getattr, |
| 1262 | .setxattr = gfs2_setxattr, |
| 1263 | .getxattr = gfs2_getxattr, |
| 1264 | .listxattr = gfs2_listxattr, |
| 1265 | .removexattr = gfs2_removexattr, |
Steven Whitehouse | e9079cc | 2008-10-14 14:43:29 +0100 | [diff] [blame^] | 1266 | .fiemap = gfs2_fiemap, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1267 | }; |
| 1268 | |
Arjan van de Ven | 92e1d5b | 2007-02-12 00:55:39 -0800 | [diff] [blame] | 1269 | const struct inode_operations gfs2_dir_iops = { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1270 | .create = gfs2_create, |
| 1271 | .lookup = gfs2_lookup, |
| 1272 | .link = gfs2_link, |
| 1273 | .unlink = gfs2_unlink, |
| 1274 | .symlink = gfs2_symlink, |
| 1275 | .mkdir = gfs2_mkdir, |
| 1276 | .rmdir = gfs2_rmdir, |
| 1277 | .mknod = gfs2_mknod, |
| 1278 | .rename = gfs2_rename, |
Al Viro | e6305c4 | 2008-07-15 21:03:57 -0400 | [diff] [blame] | 1279 | .permission = gfs2_permission, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1280 | .setattr = gfs2_setattr, |
| 1281 | .getattr = gfs2_getattr, |
| 1282 | .setxattr = gfs2_setxattr, |
| 1283 | .getxattr = gfs2_getxattr, |
| 1284 | .listxattr = gfs2_listxattr, |
| 1285 | .removexattr = gfs2_removexattr, |
Steven Whitehouse | e9079cc | 2008-10-14 14:43:29 +0100 | [diff] [blame^] | 1286 | .fiemap = gfs2_fiemap, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1287 | }; |
| 1288 | |
Arjan van de Ven | 92e1d5b | 2007-02-12 00:55:39 -0800 | [diff] [blame] | 1289 | const struct inode_operations gfs2_symlink_iops = { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1290 | .readlink = gfs2_readlink, |
| 1291 | .follow_link = gfs2_follow_link, |
Al Viro | e6305c4 | 2008-07-15 21:03:57 -0400 | [diff] [blame] | 1292 | .permission = gfs2_permission, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1293 | .setattr = gfs2_setattr, |
| 1294 | .getattr = gfs2_getattr, |
| 1295 | .setxattr = gfs2_setxattr, |
| 1296 | .getxattr = gfs2_getxattr, |
| 1297 | .listxattr = gfs2_listxattr, |
| 1298 | .removexattr = gfs2_removexattr, |
Steven Whitehouse | e9079cc | 2008-10-14 14:43:29 +0100 | [diff] [blame^] | 1299 | .fiemap = gfs2_fiemap, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1300 | }; |
| 1301 | |