VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   57 Tags
7336d0e654f7a fs/gfs2/inode.c     (Thomas Gleixner     2019-05-31 01:09:56 -0700    1) // SPDX-License-Identifier: GPL-2.0-only
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000    2) /*
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000    3)  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100    4)  * Copyright (C) 2004-2011 Red Hat, Inc.  All rights reserved.
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000    5)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000    6) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000    7) #include <linux/slab.h>
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000    8) #include <linux/spinlock.h>
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000    9) #include <linux/completion.h>
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   10) #include <linux/buffer_head.h>
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   11) #include <linux/namei.h>
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   12) #include <linux/mm.h>
5b825c3af1d8a fs/gfs2/inode.c     (Ingo Molnar         2017-02-02 17:54:15 +0100   13) #include <linux/cred.h>
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   14) #include <linux/xattr.h>
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   15) #include <linux/posix_acl.h>
5c676f6d359b0 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-02-27 17:23:27 -0500   16) #include <linux/gfs2_ondisk.h>
71b86f562b5eb fs/gfs2/ops_inode.c (Steven Whitehouse   2006-03-28 14:14:04 -0500   17) #include <linux/crc32.h>
aac1a55b450c6 fs/gfs2/inode.c     (Bob Peterson        2017-02-16 21:13:54 +0100   18) #include <linux/iomap.h>
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   19) #include <linux/security.h>
10c5db286452b fs/gfs2/inode.c     (Christoph Hellwig   2020-05-23 09:30:11 +0200   20) #include <linux/fiemap.h>
7c0f6ba682b9c fs/gfs2/inode.c     (Linus Torvalds      2016-12-24 11:46:01 -0800   21) #include <linux/uaccess.h>
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   22) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   23) #include "gfs2.h"
5c676f6d359b0 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-02-27 17:23:27 -0500   24) #include "incore.h"
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   25) #include "acl.h"
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   26) #include "bmap.h"
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   27) #include "dir.h"
307cf6e63cfa5 fs/gfs2/ops_inode.c (Steven Whitehouse   2009-08-26 18:51:04 +0100   28) #include "xattr.h"
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   29) #include "glock.h"
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   30) #include "inode.h"
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   31) #include "meta_io.h"
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   32) #include "quota.h"
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   33) #include "rgrp.h"
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000   34) #include "trans.h"
5c676f6d359b0 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-02-27 17:23:27 -0500   35) #include "util.h"
b276058371f5c fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 16:05:55 +0100   36) #include "super.h"
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   37) #include "glops.h"
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   38) 
e3a77eebfa256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 21:14:15 +0100   39) static const struct inode_operations gfs2_file_iops;
e3a77eebfa256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 21:14:15 +0100   40) static const struct inode_operations gfs2_dir_iops;
e3a77eebfa256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 21:14:15 +0100   41) static const struct inode_operations gfs2_symlink_iops;
e3a77eebfa256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 21:14:15 +0100   42) 
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   43) static int iget_test(struct inode *inode, void *opaque)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   44) {
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   45) 	u64 no_addr = *(u64 *)opaque;
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   46) 
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   47) 	return GFS2_I(inode)->i_no_addr == no_addr;
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   48) }
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   49) 
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   50) static int iget_set(struct inode *inode, void *opaque)
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   51) {
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   52) 	u64 no_addr = *(u64 *)opaque;
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   53) 
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   54) 	GFS2_I(inode)->i_no_addr = no_addr;
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   55) 	inode->i_ino = no_addr;
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   56) 	return 0;
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   57) }
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   58) 
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   59) static struct inode *gfs2_iget(struct super_block *sb, u64 no_addr)
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   60) {
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   61) 	struct inode *inode;
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   62) 
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   63) repeat:
cda9dd4207aeb fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:24:50 -0500   64) 	inode = iget5_locked(sb, no_addr, iget_test, iget_set, &no_addr);
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   65) 	if (!inode)
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   66) 		return inode;
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   67) 	if (is_bad_inode(inode)) {
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   68) 		iput(inode);
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   69) 		goto repeat;
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   70) 	}
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500   71) 	return inode;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   72) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   73) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   74) /**
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   75)  * gfs2_set_iop - Sets inode operations
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   76)  * @inode: The inode with correct i_mode filled in
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   77)  *
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   78)  * GFS2 lookup code fills in vfs inode contents based on info obtained
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   79)  * from directory entry inside gfs2_inode_lookup().
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   80)  */
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   81) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   82) static void gfs2_set_iop(struct inode *inode)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   83) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   84) 	struct gfs2_sbd *sdp = GFS2_SB(inode);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   85) 	umode_t mode = inode->i_mode;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   86) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   87) 	if (S_ISREG(mode)) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   88) 		inode->i_op = &gfs2_file_iops;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   89) 		if (gfs2_localflocks(sdp))
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   90) 			inode->i_fop = &gfs2_file_fops_nolock;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   91) 		else
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   92) 			inode->i_fop = &gfs2_file_fops;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   93) 	} else if (S_ISDIR(mode)) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   94) 		inode->i_op = &gfs2_dir_iops;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   95) 		if (gfs2_localflocks(sdp))
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   96) 			inode->i_fop = &gfs2_dir_fops_nolock;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   97) 		else
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   98) 			inode->i_fop = &gfs2_dir_fops;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100   99) 	} else if (S_ISLNK(mode)) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  100) 		inode->i_op = &gfs2_symlink_iops;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  101) 	} else {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  102) 		inode->i_op = &gfs2_file_iops;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  103) 		init_special_inode(inode, inode->i_mode, inode->i_rdev);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  104) 	}
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  105) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  106) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  107) /**
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  108)  * gfs2_inode_lookup - Lookup an inode
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  109)  * @sb: The super block
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  110)  * @type: The type of the inode
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  111)  * @no_addr: The inode number
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  112)  * @no_formal_ino: The inode generation number
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  113)  * @blktype: Requested block type (GFS2_BLKST_DINODE or GFS2_BLKST_UNLINKED;
61b91cfdc6c0c fs/gfs2/inode.c     (Andreas Gruenbacher 2017-08-01 09:54:33 -0500  114)  *           GFS2_BLKST_FREE to indicate not to verify)
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  115)  *
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  116)  * If @type is DT_UNKNOWN, the inode type is fetched from disk.
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  117)  *
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  118)  * If @blktype is anything other than GFS2_BLKST_FREE (which is used as a
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  119)  * placeholder because it doesn't otherwise make sense), the on-disk block type
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  120)  * is verified to be @blktype.
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  121)  *
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  122)  * When @no_formal_ino is non-zero, this function will return ERR_PTR(-ESTALE)
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  123)  * if it detects that @no_formal_ino doesn't match the actual inode generation
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  124)  * number.  However, it doesn't always know unless @type is DT_UNKNOWN.
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  125)  *
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  126)  * Returns: A VFS inode, or an error
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  127)  */
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  128) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  129) struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  130) 				u64 no_addr, u64 no_formal_ino,
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  131) 				unsigned int blktype)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  132) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  133) 	struct inode *inode;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  134) 	struct gfs2_inode *ip;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  135) 	struct gfs2_glock *io_gl = NULL;
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  136) 	struct gfs2_holder i_gh;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  137) 	int error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  138) 
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500  139) 	gfs2_holder_mark_uninitialized(&i_gh);
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  140) 	inode = gfs2_iget(sb, no_addr);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  141) 	if (!inode)
ac3beb6a5de04 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-16 10:31:13 +0000  142) 		return ERR_PTR(-ENOMEM);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  143) 
e97321fa095f1 fs/gfs2/inode.c     (Bob Peterson        2016-04-12 16:14:26 -0400  144) 	ip = GFS2_I(inode);
e97321fa095f1 fs/gfs2/inode.c     (Bob Peterson        2016-04-12 16:14:26 -0400  145) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  146) 	if (inode->i_state & I_NEW) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  147) 		struct gfs2_sbd *sdp = GFS2_SB(inode);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  148) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  149) 		error = gfs2_glock_get(sdp, no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  150) 		if (unlikely(error))
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  151) 			goto fail;
4fd1a5795214b fs/gfs2/inode.c     (Andreas Gruenbacher 2017-06-30 07:47:15 -0500  152) 		flush_delayed_work(&ip->i_gl->gl_work);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  153) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  154) 		error = gfs2_glock_get(sdp, no_addr, &gfs2_iopen_glops, CREATE, &io_gl);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  155) 		if (unlikely(error))
40e7e86ef1655 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-24 14:14:46 +0100  156) 			goto fail;
dd0ecf5441256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-30 16:07:25 +0100  157) 		if (blktype != GFS2_BLKST_UNLINKED)
dd0ecf5441256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-30 16:07:25 +0100  158) 			gfs2_cancel_delete_work(io_gl);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  159) 
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  160) 		if (type == DT_UNKNOWN || blktype != GFS2_BLKST_FREE) {
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  161) 			/*
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  162) 			 * The GL_SKIP flag indicates to skip reading the inode
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  163) 			 * block.  We read the inode with gfs2_inode_refresh
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  164) 			 * after possibly checking the block type.
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  165) 			 */
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  166) 			error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE,
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  167) 						   GL_SKIP, &i_gh);
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  168) 			if (error)
40e7e86ef1655 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-24 14:14:46 +0100  169) 				goto fail;
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  170) 
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  171) 			error = -ESTALE;
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  172) 			if (no_formal_ino &&
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  173) 			    gfs2_inode_already_deleted(ip->i_gl, no_formal_ino))
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  174) 				goto fail;
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  175) 
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  176) 			if (blktype != GFS2_BLKST_FREE) {
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  177) 				error = gfs2_check_blk_type(sdp, no_addr,
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  178) 							    blktype);
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  179) 				if (error)
40e7e86ef1655 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-24 14:14:46 +0100  180) 					goto fail;
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  181) 			}
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  182) 		}
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  183) 
4d7c18c7df89e fs/gfs2/inode.c     (Bob Peterson        2017-07-18 12:15:01 -0500  184) 		glock_set_object(ip->i_gl, ip);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  185) 		set_bit(GIF_INVALID, &ip->i_flags);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  186) 		error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  187) 		if (unlikely(error))
40e7e86ef1655 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-24 14:14:46 +0100  188) 			goto fail;
4fd1a5795214b fs/gfs2/inode.c     (Andreas Gruenbacher 2017-06-30 07:47:15 -0500  189) 		glock_set_object(ip->i_iopen_gh.gh_gl, ip);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  190) 		gfs2_glock_put(io_gl);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  191) 		io_gl = NULL;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  192) 
2b0fb353c029d fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:26:00 +0100  193) 		/* Lowest possible timestamp; will be overwritten in gfs2_dinode_in. */
2b0fb353c029d fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:26:00 +0100  194) 		inode->i_atime.tv_sec = 1LL << (8 * sizeof(inode->i_atime.tv_sec) - 1);
2b0fb353c029d fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:26:00 +0100  195) 		inode->i_atime.tv_nsec = 0;
2b0fb353c029d fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:26:00 +0100  196) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  197) 		if (type == DT_UNKNOWN) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  198) 			/* Inode glock must be locked already */
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  199) 			error = gfs2_inode_refresh(GFS2_I(inode));
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  200) 			if (error)
40e7e86ef1655 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-24 14:14:46 +0100  201) 				goto fail;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  202) 		} else {
2b0fb353c029d fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:26:00 +0100  203) 			ip->i_no_formal_ino = no_formal_ino;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  204) 			inode->i_mode = DT2IF(type);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  205) 		}
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  206) 
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  207) 		if (gfs2_holder_initialized(&i_gh))
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  208) 			gfs2_glock_dq_uninit(&i_gh);
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  209) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  210) 		gfs2_set_iop(inode);
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  211) 	}
332f51d7db13f fs/gfs2/inode.c     (Andreas Gruenbacher 2016-09-26 13:24:34 -0500  212) 
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  213) 	if (no_formal_ino && ip->i_no_formal_ino &&
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  214) 	    no_formal_ino != ip->i_no_formal_ino) {
5902f4dd6e666 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-06-09 14:33:11 +0200  215) 		error = -ESTALE;
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  216) 		if (inode->i_state & I_NEW)
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  217) 			goto fail;
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  218) 		iput(inode);
5902f4dd6e666 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-06-09 14:33:11 +0200  219) 		return ERR_PTR(error);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  220) 	}
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  221) 
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  222) 	if (inode->i_state & I_NEW)
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  223) 		unlock_new_inode(inode);
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  224) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  225) 	return inode;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  226) 
40e7e86ef1655 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-24 14:14:46 +0100  227) fail:
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  228) 	if (io_gl)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  229) 		gfs2_glock_put(io_gl);
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500  230) 	if (gfs2_holder_initialized(&i_gh))
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  231) 		gfs2_glock_dq_uninit(&i_gh);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  232) 	iget_failed(inode);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  233) 	return ERR_PTR(error);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  234) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  235) 
6bdcadea75768 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 05:31:38 +0100  236) /**
6bdcadea75768 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 05:31:38 +0100  237)  * gfs2_lookup_by_inum - look up an inode by inode number
6bdcadea75768 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 05:31:38 +0100  238)  * @sdp: The super block
6bdcadea75768 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 05:31:38 +0100  239)  * @no_addr: The inode number
6bdcadea75768 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 05:31:38 +0100  240)  * @no_formal_ino: The inode generation number (0 for any)
6bdcadea75768 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 05:31:38 +0100  241)  * @blktype: Requested block type (see gfs2_inode_lookup)
6bdcadea75768 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 05:31:38 +0100  242)  */
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  243) struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
6bdcadea75768 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 05:31:38 +0100  244) 				  u64 no_formal_ino, unsigned int blktype)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  245) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  246) 	struct super_block *sb = sdp->sd_vfs;
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  247) 	struct inode *inode;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  248) 	int error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  249) 
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  250) 	inode = gfs2_inode_lookup(sb, DT_UNKNOWN, no_addr, no_formal_ino,
b66648ad6dcfe fs/gfs2/inode.c     (Andreas Gruenbacher 2020-01-15 06:21:42 +0100  251) 				  blktype);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  252) 	if (IS_ERR(inode))
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  253) 		return inode;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  254) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  255) 	if (no_formal_ino) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  256) 		error = -EIO;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  257) 		if (GFS2_I(inode)->i_diskflags & GFS2_DIF_SYSTEM)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  258) 			goto fail_iput;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  259) 	}
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  260) 	return inode;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  261) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  262) fail_iput:
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  263) 	iput(inode);
3ce37b2cb4917 fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-14 12:22:27 -0500  264) 	return ERR_PTR(error);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  265) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  266) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  267) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  268) struct inode *gfs2_lookup_simple(struct inode *dip, const char *name)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  269) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  270) 	struct qstr qstr;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  271) 	struct inode *inode;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  272) 	gfs2_str2qstr(&qstr, name);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  273) 	inode = gfs2_lookupi(dip, &qstr, 1);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  274) 	/* gfs2_lookupi has inconsistent callers: vfs
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  275) 	 * related routines expect NULL for no entry found,
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  276) 	 * gfs2_lookup_simple callers expect ENOENT
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  277) 	 * and do not check for NULL.
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  278) 	 */
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  279) 	if (inode == NULL)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  280) 		return ERR_PTR(-ENOENT);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  281) 	else
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  282) 		return inode;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  283) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  284) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  285) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  286) /**
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  287)  * gfs2_lookupi - Look up a filename in a directory and return its inode
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100  288)  * @dir: The inode of the directory containing the inode to look-up
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  289)  * @name: The name of the inode to look for
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  290)  * @is_root: If 1, ignore the caller's permissions
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  291)  *
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  292)  * This can be called via the VFS filldir function when NFS is doing
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  293)  * a readdirplus and the inode which its intending to stat isn't
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  294)  * already in cache. In this case we must not take the directory glock
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  295)  * again, since the readdir call will have already taken that lock.
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  296)  *
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  297)  * Returns: errno
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  298)  */
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  299) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  300) struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  301) 			   int is_root)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  302) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  303) 	struct super_block *sb = dir->i_sb;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  304) 	struct gfs2_inode *dip = GFS2_I(dir);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  305) 	struct gfs2_holder d_gh;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  306) 	int error = 0;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  307) 	struct inode *inode = NULL;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  308) 
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500  309) 	gfs2_holder_mark_uninitialized(&d_gh);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  310) 	if (!name->len || name->len > GFS2_FNAMESIZE)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  311) 		return ERR_PTR(-ENAMETOOLONG);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  312) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  313) 	if ((name->len == 1 && memcmp(name->name, ".", 1) == 0) ||
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  314) 	    (name->len == 2 && memcmp(name->name, "..", 2) == 0 &&
2b0143b5c986b fs/gfs2/inode.c     (David Howells       2015-03-17 22:25:59 +0000  315) 	     dir == d_inode(sb->s_root))) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  316) 		igrab(dir);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  317) 		return dir;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  318) 	}
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  319) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  320) 	if (gfs2_glock_is_locked_by_me(dip->i_gl) == NULL) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  321) 		error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  322) 		if (error)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  323) 			return ERR_PTR(error);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  324) 	}
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  325) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  326) 	if (!is_root) {
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100  327) 		error = gfs2_permission(&init_user_ns, dir, MAY_EXEC);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  328) 		if (error)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  329) 			goto out;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  330) 	}
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  331) 
5a00f3cc978be fs/gfs2/inode.c     (Steven Whitehouse   2013-06-11 13:45:29 +0100  332) 	inode = gfs2_dir_search(dir, name, false);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  333) 	if (IS_ERR(inode))
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  334) 		error = PTR_ERR(inode);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  335) out:
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500  336) 	if (gfs2_holder_initialized(&d_gh))
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  337) 		gfs2_glock_dq_uninit(&d_gh);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  338) 	if (error == -ENOENT)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  339) 		return NULL;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  340) 	return inode ? inode : ERR_PTR(error);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  341) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  342) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  343) /**
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  344)  * create_ok - OK to create a new on-disk inode here?
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  345)  * @dip:  Directory in which dinode is to be created
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  346)  * @name:  Name of new dinode
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  347)  * @mode:
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  348)  *
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  349)  * Returns: errno
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  350)  */
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  351) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  352) static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
175a4eb7ea531 fs/gfs2/inode.c     (Al Viro             2011-07-26 03:30:54 -0400  353) 		     umode_t mode)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  354) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  355) 	int error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  356) 
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100  357) 	error = gfs2_permission(&init_user_ns, &dip->i_inode,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100  358) 				MAY_WRITE | MAY_EXEC);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  359) 	if (error)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  360) 		return error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  361) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  362) 	/*  Don't create entries in an unlinked directory  */
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  363) 	if (!dip->i_inode.i_nlink)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  364) 		return -ENOENT;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  365) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  366) 	if (dip->i_entries == (u32)-1)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  367) 		return -EFBIG;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  368) 	if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  369) 		return -EMLINK;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  370) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  371) 	return 0;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  372) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  373) 
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  374) static void munge_mode_uid_gid(const struct gfs2_inode *dip,
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  375) 			       struct inode *inode)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  376) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  377) 	if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir &&
6b24c0d279eac fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 21:56:13 -0800  378) 	    (dip->i_inode.i_mode & S_ISUID) &&
6b24c0d279eac fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 21:56:13 -0800  379) 	    !uid_eq(dip->i_inode.i_uid, GLOBAL_ROOT_UID)) {
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  380) 		if (S_ISDIR(inode->i_mode))
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  381) 			inode->i_mode |= S_ISUID;
6b24c0d279eac fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 21:56:13 -0800  382) 		else if (!uid_eq(dip->i_inode.i_uid, current_fsuid()))
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  383) 			inode->i_mode &= ~07111;
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  384) 		inode->i_uid = dip->i_inode.i_uid;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  385) 	} else
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  386) 		inode->i_uid = current_fsuid();
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  387) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  388) 	if (dip->i_inode.i_mode & S_ISGID) {
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  389) 		if (S_ISDIR(inode->i_mode))
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  390) 			inode->i_mode |= S_ISGID;
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  391) 		inode->i_gid = dip->i_inode.i_gid;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  392) 	} else
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  393) 		inode->i_gid = current_fsgid();
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  394) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  395) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  396) static int alloc_dinode(struct gfs2_inode *ip, u32 flags, unsigned *dblocks)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  397) {
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  398) 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  399) 	struct gfs2_alloc_parms ap = { .target = *dblocks, .aflags = flags, };
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  400) 	int error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  401) 
b8fbf471edb3d fs/gfs2/inode.c     (Abhi Das            2015-03-18 12:03:41 -0500  402) 	error = gfs2_quota_lock_check(ip, &ap);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  403) 	if (error)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  404) 		goto out;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  405) 
7b9cff467144c fs/gfs2/inode.c     (Steven Whitehouse   2013-10-02 11:13:25 +0100  406) 	error = gfs2_inplace_reserve(ip, &ap);
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  407) 	if (error)
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  408) 		goto out_quota;
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  409) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  410) 	error = gfs2_trans_begin(sdp, (*dblocks * RES_RG_BIT) + RES_STATFS + RES_QUOTA, 0);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  411) 	if (error)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  412) 		goto out_ipreserv;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  413) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  414) 	error = gfs2_alloc_blocks(ip, &ip->i_no_addr, dblocks, 1, &ip->i_generation);
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  415) 	ip->i_no_formal_ino = ip->i_generation;
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  416) 	ip->i_inode.i_ino = ip->i_no_addr;
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  417) 	ip->i_goal = ip->i_no_addr;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  418) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  419) 	gfs2_trans_end(sdp);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  420) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  421) out_ipreserv:
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  422) 	gfs2_inplace_release(ip);
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  423) out_quota:
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  424) 	gfs2_quota_unlock(ip);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  425) out:
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  426) 	return error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  427) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  428) 
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  429) static void gfs2_init_dir(struct buffer_head *dibh,
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  430) 			  const struct gfs2_inode *parent)
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  431) {
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  432) 	struct gfs2_dinode *di = (struct gfs2_dinode *)dibh->b_data;
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  433) 	struct gfs2_dirent *dent = (struct gfs2_dirent *)(di+1);
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  434) 
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  435) 	gfs2_qstr2dirent(&gfs2_qdot, GFS2_DIRENT_SIZE(gfs2_qdot.len), dent);
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  436) 	dent->de_inum = di->di_num; /* already GFS2 endian */
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  437) 	dent->de_type = cpu_to_be16(DT_DIR);
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  438) 
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  439) 	dent = (struct gfs2_dirent *)((char*)dent + GFS2_DIRENT_SIZE(1));
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  440) 	gfs2_qstr2dirent(&gfs2_qdotdot, dibh->b_size - GFS2_DIRENT_SIZE(1) - sizeof(struct gfs2_dinode), dent);
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  441) 	gfs2_inum_out(parent, dent);
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  442) 	dent->de_type = cpu_to_be16(DT_DIR);
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  443) 	
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  444) }
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  445) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  446) /**
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  447)  * gfs2_init_xattr - Initialise an xattr block for a new inode
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  448)  * @ip: The inode in question
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  449)  *
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  450)  * This sets up an empty xattr block for a new inode, ready to
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  451)  * take any ACLs, LSM xattrs, etc.
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  452)  */
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  453) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  454) static void gfs2_init_xattr(struct gfs2_inode *ip)
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  455) {
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  456) 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  457) 	struct buffer_head *bh;
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  458) 	struct gfs2_ea_header *ea;
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  459) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  460) 	bh = gfs2_meta_new(ip->i_gl, ip->i_eattr);
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  461) 	gfs2_trans_add_meta(ip->i_gl, bh);
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  462) 	gfs2_metatype_set(bh, GFS2_METATYPE_EA, GFS2_FORMAT_EA);
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  463) 	gfs2_buffer_clear_tail(bh, sizeof(struct gfs2_meta_header));
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  464) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  465) 	ea = GFS2_EA_BH2FIRST(bh);
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  466) 	ea->ea_rec_len = cpu_to_be32(sdp->sd_jbsize);
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  467) 	ea->ea_type = GFS2_EATYPE_UNUSED;
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  468) 	ea->ea_flags = GFS2_EAFLAG_LAST;
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  469) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  470) 	brelse(bh);
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  471) }
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  472) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  473) /**
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  474)  * init_dinode - Fill in a new dinode structure
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  475)  * @dip: The directory this inode is being created in
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  476)  * @ip: The inode
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  477)  * @symname: The symlink destination (if a symlink)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  478)  *
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  479)  */
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  480) 
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  481) static void init_dinode(struct gfs2_inode *dip, struct gfs2_inode *ip,
79ba74808df11 fs/gfs2/inode.c     (Steven Whitehouse   2013-03-01 09:29:12 +0000  482) 			const char *symname)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  483) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  484) 	struct gfs2_dinode *di;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  485) 	struct buffer_head *dibh;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  486) 
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  487) 	dibh = gfs2_meta_new(ip->i_gl, ip->i_no_addr);
350a9b0a7269c fs/gfs2/inode.c     (Steven Whitehouse   2012-12-14 12:36:02 +0000  488) 	gfs2_trans_add_meta(ip->i_gl, dibh);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  489) 	di = (struct gfs2_dinode *)dibh->b_data;
79ba74808df11 fs/gfs2/inode.c     (Steven Whitehouse   2013-03-01 09:29:12 +0000  490) 	gfs2_dinode_out(ip, di);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  491) 
6f24784f00f2b fs/gfs2/inode.c     (Al Viro             2021-01-31 19:23:55 -0500  492) 	di->di_major = cpu_to_be32(imajor(&ip->i_inode));
6f24784f00f2b fs/gfs2/inode.c     (Al Viro             2021-01-31 19:23:55 -0500  493) 	di->di_minor = cpu_to_be32(iminor(&ip->i_inode));
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  494) 	di->__pad1 = 0;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  495) 	di->__pad2 = 0;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  496) 	di->__pad3 = 0;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  497) 	memset(&di->__pad4, 0, sizeof(di->__pad4));
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  498) 	memset(&di->di_reserved, 0, sizeof(di->di_reserved));
79ba74808df11 fs/gfs2/inode.c     (Steven Whitehouse   2013-03-01 09:29:12 +0000  499) 	gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
160b4026dc3e7 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 10:34:59 +0100  500) 
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  501) 	switch(ip->i_inode.i_mode & S_IFMT) {
160b4026dc3e7 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 10:34:59 +0100  502) 	case S_IFDIR:
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  503) 		gfs2_init_dir(dibh, dip);
160b4026dc3e7 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 10:34:59 +0100  504) 		break;
160b4026dc3e7 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 10:34:59 +0100  505) 	case S_IFLNK:
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  506) 		memcpy(dibh->b_data + sizeof(struct gfs2_dinode), symname, ip->i_inode.i_size);
160b4026dc3e7 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 10:34:59 +0100  507) 		break;
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  508) 	}
e2d0a13bba051 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 09:55:55 +0100  509) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  510) 	set_buffer_uptodate(dibh);
79ba74808df11 fs/gfs2/inode.c     (Steven Whitehouse   2013-03-01 09:29:12 +0000  511) 	brelse(dibh);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  512) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  513) 
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  514) /**
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100  515)  * gfs2_trans_da_blks - Calculate number of blocks to link inode
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  516)  * @dip: The directory we are linking into
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  517)  * @da: The dir add information
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  518)  * @nr_inodes: The number of inodes involved
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  519)  *
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  520)  * This calculate the number of blocks we need to reserve in a
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  521)  * transaction to link @nr_inodes into a directory. In most cases
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  522)  * @nr_inodes will be 2 (the directory plus the inode being linked in)
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  523)  * but in case of rename, 4 may be required.
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  524)  *
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  525)  * Returns: Number of blocks
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  526)  */
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  527) 
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  528) static unsigned gfs2_trans_da_blks(const struct gfs2_inode *dip,
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  529) 				   const struct gfs2_diradd *da,
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  530) 				   unsigned nr_inodes)
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  531) {
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  532) 	return da->nr_blocks + gfs2_rg_blocks(dip, da->nr_blocks) +
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  533) 	       (nr_inodes * RES_DINODE) + RES_QUOTA + RES_STATFS;
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  534) }
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  535) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  536) static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000  537) 		       struct gfs2_inode *ip, struct gfs2_diradd *da)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  538) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  539) 	struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000  540) 	struct gfs2_alloc_parms ap = { .target = da->nr_blocks, };
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  541) 	int error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  542) 
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000  543) 	if (da->nr_blocks) {
b8fbf471edb3d fs/gfs2/inode.c     (Abhi Das            2015-03-18 12:03:41 -0500  544) 		error = gfs2_quota_lock_check(dip, &ap);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  545) 		if (error)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  546) 			goto fail_quota_locks;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  547) 
7b9cff467144c fs/gfs2/inode.c     (Steven Whitehouse   2013-10-02 11:13:25 +0100  548) 		error = gfs2_inplace_reserve(dip, &ap);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  549) 		if (error)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  550) 			goto fail_quota_locks;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  551) 
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000  552) 		error = gfs2_trans_begin(sdp, gfs2_trans_da_blks(dip, da, 2), 0);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  553) 		if (error)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  554) 			goto fail_ipreserv;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  555) 	} else {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  556) 		error = gfs2_trans_begin(sdp, RES_LEAF + 2 * RES_DINODE, 0);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  557) 		if (error)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  558) 			goto fail_quota_locks;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  559) 	}
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  560) 
2b47dad866d04 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:49:43 +0000  561) 	error = gfs2_dir_add(&dip->i_inode, name, ip, da);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  562) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  563) 	gfs2_trans_end(sdp);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  564) fail_ipreserv:
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  565) 	gfs2_inplace_release(dip);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  566) fail_quota_locks:
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  567) 	gfs2_quota_unlock(dip);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  568) 	return error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  569) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  570) 
46cc1e5fce46e fs/gfs2/inode.c     (H Hartley Sweeten   2011-09-23 15:51:32 -0700  571) static int gfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
9d8f13ba3f483 fs/gfs2/inode.c     (Mimi Zohar          2011-06-06 15:29:25 -0400  572) 		    void *fs_info)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  573) {
9d8f13ba3f483 fs/gfs2/inode.c     (Mimi Zohar          2011-06-06 15:29:25 -0400  574) 	const struct xattr *xattr;
9d8f13ba3f483 fs/gfs2/inode.c     (Mimi Zohar          2011-06-06 15:29:25 -0400  575) 	int err = 0;
9d8f13ba3f483 fs/gfs2/inode.c     (Mimi Zohar          2011-06-06 15:29:25 -0400  576) 
9d8f13ba3f483 fs/gfs2/inode.c     (Mimi Zohar          2011-06-06 15:29:25 -0400  577) 	for (xattr = xattr_array; xattr->name != NULL; xattr++) {
9d8f13ba3f483 fs/gfs2/inode.c     (Mimi Zohar          2011-06-06 15:29:25 -0400  578) 		err = __gfs2_xattr_set(inode, xattr->name, xattr->value,
9d8f13ba3f483 fs/gfs2/inode.c     (Mimi Zohar          2011-06-06 15:29:25 -0400  579) 				       xattr->value_len, 0,
9d8f13ba3f483 fs/gfs2/inode.c     (Mimi Zohar          2011-06-06 15:29:25 -0400  580) 				       GFS2_EATYPE_SECURITY);
9d8f13ba3f483 fs/gfs2/inode.c     (Mimi Zohar          2011-06-06 15:29:25 -0400  581) 		if (err < 0)
9d8f13ba3f483 fs/gfs2/inode.c     (Mimi Zohar          2011-06-06 15:29:25 -0400  582) 			break;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  583) 	}
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  584) 	return err;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  585) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  586) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  587) /**
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  588)  * gfs2_create_inode - Create a new inode
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  589)  * @dir: The parent directory
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  590)  * @dentry: The new dentry
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  591)  * @file: If non-NULL, the file which is being opened
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  592)  * @mode: The permissions on the new inode
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  593)  * @dev: For device nodes, this is the device number
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  594)  * @symname: For symlinks, this is the link destination
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  595)  * @size: The initial size of the inode (ignored for directories)
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100  596)  * @excl: Force fail if inode exists
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  597)  *
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  598)  * Returns: 0 on success, or error code
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  599)  */
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  600) 
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  601) static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  602) 			     struct file *file,
175a4eb7ea531 fs/gfs2/inode.c     (Al Viro             2011-07-26 03:30:54 -0400  603) 			     umode_t mode, dev_t dev, const char *symname,
b452a458caaa9 fs/gfs2/inode.c     (Al Viro             2018-06-08 13:06:28 -0400  604) 			     unsigned int size, int excl)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  605) {
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  606) 	const struct qstr *name = &dentry->d_name;
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  607) 	struct posix_acl *default_acl, *acl;
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  608) 	struct gfs2_holder ghs[2];
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  609) 	struct inode *inode = NULL;
8e2e00473598d fs/gfs2/inode.c     (Bob Peterson        2012-07-19 08:12:40 -0400  610) 	struct gfs2_inode *dip = GFS2_I(dir), *ip;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  611) 	struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
a55a47a3bc82c fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-27 14:23:04 +0100  612) 	struct gfs2_glock *io_gl;
783013c0f5c72 fs/gfs2/inode.c     (Bob Peterson        2015-12-04 10:19:14 -0600  613) 	int error, free_vfs_inode = 1;
9dbe9610b9df4 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:37:10 +0000  614) 	u32 aflags = 0;
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  615) 	unsigned blocks = 1;
19aeb5a65f1a6 fs/gfs2/inode.c     (Bob Peterson        2014-09-29 08:52:04 -0400  616) 	struct gfs2_diradd da = { .bh = NULL, .save_loc = 1, };
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  617) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  618) 	if (!name->len || name->len > GFS2_FNAMESIZE)
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  619) 		return -ENAMETOOLONG;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  620) 
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600  621) 	error = gfs2_qa_get(dip);
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100  622) 	if (error)
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100  623) 		return error;
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100  624) 
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  625) 	error = gfs2_rindex_update(sdp);
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  626) 	if (error)
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600  627) 		goto fail;
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  628) 
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  629) 	error = gfs2_glock_nq_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  630) 	if (error)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  631) 		goto fail;
e0b62e21b71bb fs/gfs2/inode.c     (Andreas Gruenbacher 2017-06-30 08:16:46 -0500  632) 	gfs2_holder_mark_uninitialized(ghs + 1);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  633) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  634) 	error = create_ok(dip, name, mode);
5a00f3cc978be fs/gfs2/inode.c     (Steven Whitehouse   2013-06-11 13:45:29 +0100  635) 	if (error)
5a00f3cc978be fs/gfs2/inode.c     (Steven Whitehouse   2013-06-11 13:45:29 +0100  636) 		goto fail_gunlock;
5a00f3cc978be fs/gfs2/inode.c     (Steven Whitehouse   2013-06-11 13:45:29 +0100  637) 
5a00f3cc978be fs/gfs2/inode.c     (Steven Whitehouse   2013-06-11 13:45:29 +0100  638) 	inode = gfs2_dir_search(dir, &dentry->d_name, !S_ISREG(mode) || excl);
5a00f3cc978be fs/gfs2/inode.c     (Steven Whitehouse   2013-06-11 13:45:29 +0100  639) 	error = PTR_ERR(inode);
5a00f3cc978be fs/gfs2/inode.c     (Steven Whitehouse   2013-06-11 13:45:29 +0100  640) 	if (!IS_ERR(inode)) {
571a4b57975aa fs/gfs2/inode.c     (Al Viro             2014-11-19 19:34:49 +0000  641) 		if (S_ISDIR(inode->i_mode)) {
571a4b57975aa fs/gfs2/inode.c     (Al Viro             2014-11-19 19:34:49 +0000  642) 			iput(inode);
571a4b57975aa fs/gfs2/inode.c     (Al Viro             2014-11-19 19:34:49 +0000  643) 			inode = ERR_PTR(-EISDIR);
571a4b57975aa fs/gfs2/inode.c     (Al Viro             2014-11-19 19:34:49 +0000  644) 			goto fail_gunlock;
571a4b57975aa fs/gfs2/inode.c     (Al Viro             2014-11-19 19:34:49 +0000  645) 		}
44bb31bac555b fs/gfs2/inode.c     (Al Viro             2014-11-19 19:35:24 +0000  646) 		d_instantiate(dentry, inode);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  647) 		error = 0;
0d0d110720d79 fs/gfs2/inode.c     (Miklos Szeredi      2013-09-16 14:52:00 +0200  648) 		if (file) {
44bb31bac555b fs/gfs2/inode.c     (Al Viro             2014-11-19 19:35:24 +0000  649) 			if (S_ISREG(inode->i_mode))
be12af3ef5e61 fs/gfs2/inode.c     (Al Viro             2018-06-08 11:44:56 -0400  650) 				error = finish_open(file, dentry, gfs2_open_common);
44bb31bac555b fs/gfs2/inode.c     (Al Viro             2014-11-19 19:35:24 +0000  651) 			else
44bb31bac555b fs/gfs2/inode.c     (Al Viro             2014-11-19 19:35:24 +0000  652) 				error = finish_no_open(file, NULL);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  653) 		}
9a63edd12ba3c fs/gfs2/inode.c     (Steven Whitehouse   2011-08-18 14:35:53 +0100  654) 		gfs2_glock_dq_uninit(ghs);
2297ab6144c2e fs/gfs2/inode.c     (Bob Peterson        2020-05-04 10:18:43 -0500  655) 		goto fail;
5a00f3cc978be fs/gfs2/inode.c     (Steven Whitehouse   2013-06-11 13:45:29 +0100  656) 	} else if (error != -ENOENT) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  657) 		goto fail_gunlock;
5a00f3cc978be fs/gfs2/inode.c     (Steven Whitehouse   2013-06-11 13:45:29 +0100  658) 	}
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  659) 
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000  660) 	error = gfs2_diradd_alloc_required(dir, name, &da);
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  661) 	if (error < 0)
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  662) 		goto fail_gunlock;
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  663) 
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  664) 	inode = new_inode(sdp->sd_vfs);
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  665) 	error = -ENOMEM;
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  666) 	if (!inode)
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  667) 		goto fail_gunlock;
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  668) 
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  669) 	error = posix_acl_create(dir, &mode, &default_acl, &acl);
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  670) 	if (error)
783013c0f5c72 fs/gfs2/inode.c     (Bob Peterson        2015-12-04 10:19:14 -0600  671) 		goto fail_gunlock;
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  672) 
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  673) 	ip = GFS2_I(inode);
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600  674) 	error = gfs2_qa_get(ip);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  675) 	if (error)
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  676) 		goto fail_free_acls;
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  677) 
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  678) 	inode->i_mode = mode;
79ba74808df11 fs/gfs2/inode.c     (Steven Whitehouse   2013-03-01 09:29:12 +0000  679) 	set_nlink(inode, S_ISDIR(mode) ? 2 : 1);
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  680) 	inode->i_rdev = dev;
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  681) 	inode->i_size = size;
078cd8279e659 fs/gfs2/inode.c     (Deepa Dinamani      2016-09-14 07:48:04 -0700  682) 	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  683) 	munge_mode_uid_gid(dip, inode);
00a158be83839 fs/gfs2/inode.c     (Abhi Das            2014-09-18 21:40:28 -0500  684) 	check_and_update_goal(dip);
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  685) 	ip->i_goal = dip->i_goal;
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  686) 	ip->i_diskflags = 0;
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  687) 	ip->i_eattr = 0;
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  688) 	ip->i_height = 0;
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  689) 	ip->i_depth = 0;
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  690) 	ip->i_entries = 0;
cc963a11b67b7 fs/gfs2/inode.c     (Bob Peterson        2017-03-16 15:29:13 -0400  691) 	ip->i_no_addr = 0; /* Temporarily zero until real addr is assigned */
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  692) 
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  693) 	switch(mode & S_IFMT) {
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  694) 	case S_IFREG:
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  695) 		if ((dip->i_diskflags & GFS2_DIF_INHERIT_JDATA) ||
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  696) 		    gfs2_tune_get(sdp, gt_new_files_jdata))
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  697) 			ip->i_diskflags |= GFS2_DIF_JDATA;
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  698) 		gfs2_set_aops(inode);
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  699) 		break;
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  700) 	case S_IFDIR:
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  701) 		ip->i_diskflags |= (dip->i_diskflags & GFS2_DIF_INHERIT_JDATA);
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  702) 		ip->i_diskflags |= GFS2_DIF_JDATA;
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  703) 		ip->i_entries = 2;
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  704) 		break;
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  705) 	}
acc546fd6108c fs/gfs2/inode.c     (Abhi Das            2015-11-10 15:07:26 -0600  706) 
acc546fd6108c fs/gfs2/inode.c     (Abhi Das            2015-11-10 15:07:26 -0600  707) 	/* Force SYSTEM flag on all files and subdirs of a SYSTEM directory */
acc546fd6108c fs/gfs2/inode.c     (Abhi Das            2015-11-10 15:07:26 -0600  708) 	if (dip->i_diskflags & GFS2_DIF_SYSTEM)
acc546fd6108c fs/gfs2/inode.c     (Abhi Das            2015-11-10 15:07:26 -0600  709) 		ip->i_diskflags |= GFS2_DIF_SYSTEM;
acc546fd6108c fs/gfs2/inode.c     (Abhi Das            2015-11-10 15:07:26 -0600  710) 
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  711) 	gfs2_set_inode_flags(inode);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  712) 
2b0143b5c986b fs/gfs2/inode.c     (David Howells       2015-03-17 22:25:59 +0000  713) 	if ((GFS2_I(d_inode(sdp->sd_root_dir)) == dip) ||
9dbe9610b9df4 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:37:10 +0000  714) 	    (dip->i_diskflags & GFS2_DIF_TOPDIR))
9dbe9610b9df4 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:37:10 +0000  715) 		aflags |= GFS2_AF_ORLOV;
9dbe9610b9df4 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:37:10 +0000  716) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  717) 	if (default_acl || acl)
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  718) 		blocks++;
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  719) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  720) 	error = alloc_dinode(ip, aflags, &blocks);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  721) 	if (error)
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  722) 		goto fail_free_inode;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  723) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  724) 	gfs2_set_inode_blocks(inode, blocks);
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  725) 
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  726) 	error = gfs2_glock_get(sdp, ip->i_no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  727) 	if (error)
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  728) 		goto fail_free_inode;
98e5a91a6136a fs/gfs2/inode.c     (Andreas Gruenbacher 2017-07-19 11:10:19 -0500  729) 	flush_delayed_work(&ip->i_gl->gl_work);
6f6597baae206 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-06-30 07:55:08 -0500  730) 	glock_set_object(ip->i_gl, ip);
98e5a91a6136a fs/gfs2/inode.c     (Andreas Gruenbacher 2017-07-19 11:10:19 -0500  731) 
dd0ecf5441256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-30 16:07:25 +0100  732) 	error = gfs2_glock_get(sdp, ip->i_no_addr, &gfs2_iopen_glops, CREATE, &io_gl);
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  733) 	if (error)
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  734) 		goto fail_free_inode;
dd0ecf5441256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-30 16:07:25 +0100  735) 	gfs2_cancel_delete_work(io_gl);
dd0ecf5441256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-30 16:07:25 +0100  736) 	glock_set_object(io_gl, ip);
dd0ecf5441256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-30 16:07:25 +0100  737) 
dd0ecf5441256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-30 16:07:25 +0100  738) 	error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, ghs + 1);
dd0ecf5441256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-30 16:07:25 +0100  739) 	if (error)
dd0ecf5441256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-30 16:07:25 +0100  740) 		goto fail_gunlock2;
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  741) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  742) 	error = gfs2_trans_begin(sdp, blocks, 0);
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  743) 	if (error)
dd0ecf5441256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-30 16:07:25 +0100  744) 		goto fail_gunlock2;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  745) 
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  746) 	if (blocks > 1) {
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  747) 		ip->i_eattr = ip->i_no_addr + 1;
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  748) 		gfs2_init_xattr(ip);
b2c8b3ea871e4 fs/gfs2/inode.c     (Steven Whitehouse   2014-02-04 15:45:11 +0000  749) 	}
79ba74808df11 fs/gfs2/inode.c     (Steven Whitehouse   2013-03-01 09:29:12 +0000  750) 	init_dinode(dip, ip, symname);
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  751) 	gfs2_trans_end(sdp);
fd4b4e042c6aa fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 16:15:20 +0000  752) 
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  753) 	error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh);
ff7f4cb461163 fs/gfs2/inode.c     (Steven Whitehouse   2012-09-10 10:03:50 +0100  754) 	if (error)
ff7f4cb461163 fs/gfs2/inode.c     (Steven Whitehouse   2012-09-10 10:03:50 +0100  755) 		goto fail_gunlock2;
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100  756) 
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  757) 	gfs2_set_iop(inode);
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  758) 	insert_inode_hash(inode);
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  759) 
783013c0f5c72 fs/gfs2/inode.c     (Bob Peterson        2015-12-04 10:19:14 -0600  760) 	free_vfs_inode = 0; /* After this point, the inode is no longer
783013c0f5c72 fs/gfs2/inode.c     (Bob Peterson        2015-12-04 10:19:14 -0600  761) 			       considered free. Any failures need to undo
783013c0f5c72 fs/gfs2/inode.c     (Bob Peterson        2015-12-04 10:19:14 -0600  762) 			       the gfs2 structures. */
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  763) 	if (default_acl) {
1a39ba99b5d53 fs/gfs2/inode.c     (Al Viro             2016-05-13 03:59:17 +0200  764) 		error = __gfs2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
6ff9b09e00a44 fs/gfs2/inode.c     (Andreas Gruenbacher 2018-11-26 18:45:35 +0100  765) 		if (error)
6ff9b09e00a44 fs/gfs2/inode.c     (Andreas Gruenbacher 2018-11-26 18:45:35 +0100  766) 			goto fail_gunlock3;
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  767) 		posix_acl_release(default_acl);
6ff9b09e00a44 fs/gfs2/inode.c     (Andreas Gruenbacher 2018-11-26 18:45:35 +0100  768) 		default_acl = NULL;
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  769) 	}
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  770) 	if (acl) {
6ff9b09e00a44 fs/gfs2/inode.c     (Andreas Gruenbacher 2018-11-26 18:45:35 +0100  771) 		error = __gfs2_set_acl(inode, acl, ACL_TYPE_ACCESS);
6ff9b09e00a44 fs/gfs2/inode.c     (Andreas Gruenbacher 2018-11-26 18:45:35 +0100  772) 		if (error)
6ff9b09e00a44 fs/gfs2/inode.c     (Andreas Gruenbacher 2018-11-26 18:45:35 +0100  773) 			goto fail_gunlock3;
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  774) 		posix_acl_release(acl);
6ff9b09e00a44 fs/gfs2/inode.c     (Andreas Gruenbacher 2018-11-26 18:45:35 +0100  775) 		acl = NULL;
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  776) 	}
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  777) 
f45dc26deda00 fs/gfs2/inode.c     (Bob Peterson        2014-03-19 09:37:00 -0400  778) 	error = security_inode_init_security(&ip->i_inode, &dip->i_inode, name,
f45dc26deda00 fs/gfs2/inode.c     (Bob Peterson        2014-03-19 09:37:00 -0400  779) 					     &gfs2_initxattrs, NULL);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  780) 	if (error)
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  781) 		goto fail_gunlock3;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  782) 
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000  783) 	error = link_dinode(dip, name, ip, &da);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  784) 	if (error)
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  785) 		goto fail_gunlock3;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  786) 
79ba74808df11 fs/gfs2/inode.c     (Steven Whitehouse   2013-03-01 09:29:12 +0000  787) 	mark_inode_dirty(inode);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  788) 	d_instantiate(dentry, inode);
2c47c1be51fbd fs/gfs2/inode.c     (Bob Peterson        2019-11-19 11:40:46 -0500  789) 	/* After instantiate, errors should result in evict which will destroy
2c47c1be51fbd fs/gfs2/inode.c     (Bob Peterson        2019-11-19 11:40:46 -0500  790) 	 * both inode and iopen glocks properly. */
c5bf8fef52ce1 fs/gfs2/inode.c     (Miklos Szeredi      2013-09-16 14:52:03 +0200  791) 	if (file) {
73a09dd94377e fs/gfs2/inode.c     (Al Viro             2018-06-08 13:22:02 -0400  792) 		file->f_mode |= FMODE_CREATED;
be12af3ef5e61 fs/gfs2/inode.c     (Al Viro             2018-06-08 11:44:56 -0400  793) 		error = finish_open(file, dentry, gfs2_open_common);
c5bf8fef52ce1 fs/gfs2/inode.c     (Miklos Szeredi      2013-09-16 14:52:03 +0200  794) 	}
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  795) 	gfs2_glock_dq_uninit(ghs);
2297ab6144c2e fs/gfs2/inode.c     (Bob Peterson        2020-05-04 10:18:43 -0500  796) 	gfs2_qa_put(ip);
28fb30275570e fs/gfs2/inode.c     (Steven Whitehouse   2013-02-26 19:09:35 +0000  797) 	gfs2_glock_dq_uninit(ghs + 1);
2c47c1be51fbd fs/gfs2/inode.c     (Bob Peterson        2019-11-19 11:40:46 -0500  798) 	gfs2_glock_put(io_gl);
2297ab6144c2e fs/gfs2/inode.c     (Bob Peterson        2020-05-04 10:18:43 -0500  799) 	gfs2_qa_put(dip);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  800) 	return error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  801) 
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  802) fail_gunlock3:
9c1b28081f43c fs/gfs2/inode.c     (Bob Peterson        2017-07-18 12:26:07 -0500  803) 	glock_clear_object(io_gl, ip);
783013c0f5c72 fs/gfs2/inode.c     (Bob Peterson        2015-12-04 10:19:14 -0600  804) 	gfs2_glock_dq_uninit(&ip->i_iopen_gh);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  805) fail_gunlock2:
dd0ecf5441256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-30 16:07:25 +0100  806) 	glock_clear_object(io_gl, ip);
2c47c1be51fbd fs/gfs2/inode.c     (Bob Peterson        2019-11-19 11:40:46 -0500  807) 	gfs2_glock_put(io_gl);
c9aecf73717f5 fs/gfs2/inode.c     (Steven Whitehouse   2012-10-31 10:30:22 +0000  808) fail_free_inode:
9c1b28081f43c fs/gfs2/inode.c     (Bob Peterson        2017-07-18 12:26:07 -0500  809) 	if (ip->i_gl) {
9c1b28081f43c fs/gfs2/inode.c     (Bob Peterson        2017-07-18 12:26:07 -0500  810) 		glock_clear_object(ip->i_gl, ip);
1a0b00d15d400 fs/gfs2/inode.c     (Bob Peterson        2020-06-01 11:37:09 -0400  811) 		if (free_vfs_inode) /* else evict will do the put for us */
1a0b00d15d400 fs/gfs2/inode.c     (Bob Peterson        2020-06-01 11:37:09 -0400  812) 			gfs2_glock_put(ip->i_gl);
9c1b28081f43c fs/gfs2/inode.c     (Bob Peterson        2017-07-18 12:26:07 -0500  813) 	}
1595548fe72ca fs/gfs2/inode.c     (Andreas Gruenbacher 2020-03-06 10:32:35 -0600  814) 	gfs2_rs_delete(ip, NULL);
1595548fe72ca fs/gfs2/inode.c     (Andreas Gruenbacher 2020-03-06 10:32:35 -0600  815) 	gfs2_qa_put(ip);
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800  816) fail_free_acls:
6ff9b09e00a44 fs/gfs2/inode.c     (Andreas Gruenbacher 2018-11-26 18:45:35 +0100  817) 	posix_acl_release(default_acl);
6ff9b09e00a44 fs/gfs2/inode.c     (Andreas Gruenbacher 2018-11-26 18:45:35 +0100  818) 	posix_acl_release(acl);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  819) fail_gunlock:
2b47dad866d04 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:49:43 +0000  820) 	gfs2_dir_no_add(&da);
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  821) 	gfs2_glock_dq_uninit(ghs);
15a798f7deb39 fs/gfs2/inode.c     (Kefeng Wang         2019-06-05 22:24:24 +0800  822) 	if (!IS_ERR_OR_NULL(inode)) {
79ba74808df11 fs/gfs2/inode.c     (Steven Whitehouse   2013-03-01 09:29:12 +0000  823) 		clear_nlink(inode);
059788039f1e6 fs/gfs2/inode.c     (Abhi Das            2014-03-31 10:33:17 -0500  824) 		if (!free_vfs_inode)
059788039f1e6 fs/gfs2/inode.c     (Abhi Das            2014-03-31 10:33:17 -0500  825) 			mark_inode_dirty(inode);
059788039f1e6 fs/gfs2/inode.c     (Abhi Das            2014-03-31 10:33:17 -0500  826) 		set_bit(free_vfs_inode ? GIF_FREE_VFS_INODE : GIF_ALLOC_FAILED,
059788039f1e6 fs/gfs2/inode.c     (Abhi Das            2014-03-31 10:33:17 -0500  827) 			&GFS2_I(inode)->i_flags);
40ac218f52aa5 fs/gfs2/inode.c     (Steven Whitehouse   2011-08-02 13:17:27 +0100  828) 		iput(inode);
40ac218f52aa5 fs/gfs2/inode.c     (Steven Whitehouse   2011-08-02 13:17:27 +0100  829) 	}
e0b62e21b71bb fs/gfs2/inode.c     (Andreas Gruenbacher 2017-06-30 08:16:46 -0500  830) 	if (gfs2_holder_initialized(ghs + 1))
e0b62e21b71bb fs/gfs2/inode.c     (Andreas Gruenbacher 2017-06-30 08:16:46 -0500  831) 		gfs2_glock_dq_uninit(ghs + 1);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  832) fail:
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600  833) 	gfs2_qa_put(dip);
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  834) 	return error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100  835) }
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100  836) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  837) /**
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  838)  * gfs2_create - Create a file
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100  839)  * @mnt_userns: User namespace of the mount the inode was found from
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  840)  * @dir: The directory in which to create the file
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  841)  * @dentry: The dentry of the new file
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  842)  * @mode: The mode of the new file
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100  843)  * @excl: Force fail if inode exists
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  844)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  845)  * Returns: errno
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  846)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  847) 
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100  848) static int gfs2_create(struct user_namespace *mnt_userns, struct inode *dir,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100  849) 		       struct dentry *dentry, umode_t mode, bool excl)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  850) {
b452a458caaa9 fs/gfs2/inode.c     (Al Viro             2018-06-08 13:06:28 -0400  851) 	return gfs2_create_inode(dir, dentry, NULL, S_IFREG | mode, 0, NULL, 0, excl);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  852) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  853) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  854) /**
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  855)  * __gfs2_lookup - Look up a filename in a directory and return its inode
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  856)  * @dir: The directory inode
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  857)  * @dentry: The dentry of the new inode
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  858)  * @file: File to be opened
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  859)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  860)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  861)  * Returns: errno
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  862)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  863) 
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  864) static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry,
b452a458caaa9 fs/gfs2/inode.c     (Al Viro             2018-06-08 13:06:28 -0400  865) 				    struct file *file)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  866) {
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  867) 	struct inode *inode;
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  868) 	struct dentry *d;
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  869) 	struct gfs2_holder gh;
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  870) 	struct gfs2_glock *gl;
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  871) 	int error;
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  872) 
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  873) 	inode = gfs2_lookupi(dir, &dentry->d_name, 0);
7b7a91152d3c2 fs/gfs2/inode.c     (Benjamin Coddington 2014-09-10 14:09:20 -0400  874) 	if (inode == NULL) {
7b7a91152d3c2 fs/gfs2/inode.c     (Benjamin Coddington 2014-09-10 14:09:20 -0400  875) 		d_add(dentry, NULL);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  876) 		return NULL;
7b7a91152d3c2 fs/gfs2/inode.c     (Benjamin Coddington 2014-09-10 14:09:20 -0400  877) 	}
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  878) 	if (IS_ERR(inode))
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  879) 		return ERR_CAST(inode);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  880) 
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  881) 	gl = GFS2_I(inode)->i_gl;
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  882) 	error = gfs2_glock_nq_init(gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  883) 	if (error) {
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  884) 		iput(inode);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  885) 		return ERR_PTR(error);
9656b2c14c6ee fs/gfs2/ops_inode.c (Steven Whitehouse   2008-01-08 08:14:30 +0000  886) 	}
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  887) 
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  888) 	d = d_splice_alias(inode, dentry);
d57b9c9a999a8 fs/gfs2/inode.c     (J. Bruce Fields     2014-01-16 13:51:07 -0500  889) 	if (IS_ERR(d)) {
d57b9c9a999a8 fs/gfs2/inode.c     (J. Bruce Fields     2014-01-16 13:51:07 -0500  890) 		gfs2_glock_dq_uninit(&gh);
d57b9c9a999a8 fs/gfs2/inode.c     (J. Bruce Fields     2014-01-16 13:51:07 -0500  891) 		return d;
d57b9c9a999a8 fs/gfs2/inode.c     (J. Bruce Fields     2014-01-16 13:51:07 -0500  892) 	}
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  893) 	if (file && S_ISREG(inode->i_mode))
be12af3ef5e61 fs/gfs2/inode.c     (Al Viro             2018-06-08 11:44:56 -0400  894) 		error = finish_open(file, dentry, gfs2_open_common);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  895) 
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  896) 	gfs2_glock_dq_uninit(&gh);
5ca1db41ecdeb fs/gfs2/inode.c     (Miklos Szeredi      2013-09-23 13:21:04 +0100  897) 	if (error) {
5ca1db41ecdeb fs/gfs2/inode.c     (Miklos Szeredi      2013-09-23 13:21:04 +0100  898) 		dput(d);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  899) 		return ERR_PTR(error);
5ca1db41ecdeb fs/gfs2/inode.c     (Miklos Szeredi      2013-09-23 13:21:04 +0100  900) 	}
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  901) 	return d;
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  902) }
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  903) 
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  904) static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry,
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  905) 				  unsigned flags)
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100  906) {
b452a458caaa9 fs/gfs2/inode.c     (Al Viro             2018-06-08 13:06:28 -0400  907) 	return __gfs2_lookup(dir, dentry, NULL);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  908) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  909) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  910) /**
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  911)  * gfs2_link - Link to a file
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  912)  * @old_dentry: The inode to link
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  913)  * @dir: Add link to this directory
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  914)  * @dentry: The name of the link
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  915)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  916)  * Link the inode in "old_dentry" into the directory "dir" with the
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  917)  * name in "dentry".
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  918)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  919)  * Returns: errno
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  920)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  921) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  922) static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  923) 		     struct dentry *dentry)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  924) {
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400  925) 	struct gfs2_inode *dip = GFS2_I(dir);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400  926) 	struct gfs2_sbd *sdp = GFS2_SB(dir);
2b0143b5c986b fs/gfs2/inode.c     (David Howells       2015-03-17 22:25:59 +0000  927) 	struct inode *inode = d_inode(old_dentry);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400  928) 	struct gfs2_inode *ip = GFS2_I(inode);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  929) 	struct gfs2_holder ghs[2];
2baee03fb9165 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 12:08:36 +0100  930) 	struct buffer_head *dibh;
19aeb5a65f1a6 fs/gfs2/inode.c     (Bob Peterson        2014-09-29 08:52:04 -0400  931) 	struct gfs2_diradd da = { .bh = NULL, .save_loc = 1, };
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  932) 	int error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  933) 
b60623c238b6a fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-01 12:22:46 -0500  934) 	if (S_ISDIR(inode->i_mode))
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  935) 		return -EPERM;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  936) 
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600  937) 	error = gfs2_qa_get(dip);
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100  938) 	if (error)
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100  939) 		return error;
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100  940) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  941) 	gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  942) 	gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  943) 
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500  944) 	error = gfs2_glock_nq(ghs); /* parent */
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500  945) 	if (error)
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500  946) 		goto out_parent;
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500  947) 
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500  948) 	error = gfs2_glock_nq(ghs + 1); /* child */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  949) 	if (error)
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500  950) 		goto out_child;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  951) 
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100  952) 	error = -ENOENT;
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100  953) 	if (inode->i_nlink == 0)
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100  954) 		goto out_gunlock;
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100  955) 
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100  956) 	error = gfs2_permission(&init_user_ns, dir, MAY_WRITE | MAY_EXEC);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  957) 	if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  958) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  959) 
dbb7cae2a3617 fs/gfs2/ops_inode.c (Steven Whitehouse   2007-05-15 15:37:50 +0100  960) 	error = gfs2_dir_check(dir, &dentry->d_name, NULL);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  961) 	switch (error) {
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  962) 	case -ENOENT:
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  963) 		break;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  964) 	case 0:
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  965) 		error = -EEXIST;
e5966cf20f0c7 fs/gfs2/inode.c     (Gustavo A. R. Silva 2020-11-20 12:25:03 -0600  966) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  967) 	default:
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  968) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  969) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  970) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  971) 	error = -EINVAL;
4f56110a00af5 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-01 14:04:17 -0500  972) 	if (!dip->i_inode.i_nlink)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  973) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  974) 	error = -EFBIG;
ad6203f2b46c2 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-11-03 13:59:19 +0000  975) 	if (dip->i_entries == (u32)-1)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  976) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  977) 	error = -EPERM;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  978) 	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  979) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  980) 	error = -EINVAL;
4f56110a00af5 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-01 14:04:17 -0500  981) 	if (!ip->i_inode.i_nlink)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  982) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  983) 	error = -EMLINK;
4f56110a00af5 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-01 14:04:17 -0500  984) 	if (ip->i_inode.i_nlink == (u32)-1)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  985) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  986) 
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000  987) 	error = gfs2_diradd_alloc_required(dir, &dentry->d_name, &da);
c752666c17f87 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-03-20 12:30:04 -0500  988) 	if (error < 0)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  989) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  990) 
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000  991) 	if (da.nr_blocks) {
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000  992) 		struct gfs2_alloc_parms ap = { .target = da.nr_blocks, };
b8fbf471edb3d fs/gfs2/inode.c     (Abhi Das            2015-03-18 12:03:41 -0500  993) 		error = gfs2_quota_lock_check(dip, &ap);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  994) 		if (error)
5407e24229408 fs/gfs2/inode.c     (Bob Peterson        2012-05-18 09:28:23 -0400  995) 			goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  996) 
7b9cff467144c fs/gfs2/inode.c     (Steven Whitehouse   2013-10-02 11:13:25 +0100  997) 		error = gfs2_inplace_reserve(dip, &ap);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  998) 		if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000  999) 			goto out_gunlock_q;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1000) 
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000 1001) 		error = gfs2_trans_begin(sdp, gfs2_trans_da_blks(dip, &da, 2), 0);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1002) 		if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1003) 			goto out_ipres;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1004) 	} else {
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1005) 		error = gfs2_trans_begin(sdp, 2 * RES_DINODE + RES_LEAF, 0);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1006) 		if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1007) 			goto out_ipres;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1008) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1009) 
2baee03fb9165 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 12:08:36 +0100 1010) 	error = gfs2_meta_inode_buffer(ip, &dibh);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1011) 	if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1012) 		goto out_end_trans;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1013) 
2b47dad866d04 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:49:43 +0000 1014) 	error = gfs2_dir_add(dir, &dentry->d_name, ip, &da);
2baee03fb9165 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 12:08:36 +0100 1015) 	if (error)
2baee03fb9165 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 12:08:36 +0100 1016) 		goto out_brelse;
2baee03fb9165 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 12:08:36 +0100 1017) 
350a9b0a7269c fs/gfs2/inode.c     (Steven Whitehouse   2012-12-14 12:36:02 +0000 1018) 	gfs2_trans_add_meta(ip->i_gl, dibh);
2baee03fb9165 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 12:08:36 +0100 1019) 	inc_nlink(&ip->i_inode);
078cd8279e659 fs/gfs2/inode.c     (Deepa Dinamani      2016-09-14 07:48:04 -0700 1020) 	ip->i_inode.i_ctime = current_time(&ip->i_inode);
ab9bbda0204df fs/gfs2/inode.c     (Steven Whitehouse   2011-08-15 14:20:36 +0100 1021) 	ihold(inode);
ab9bbda0204df fs/gfs2/inode.c     (Steven Whitehouse   2011-08-15 14:20:36 +0100 1022) 	d_instantiate(dentry, inode);
ab9bbda0204df fs/gfs2/inode.c     (Steven Whitehouse   2011-08-15 14:20:36 +0100 1023) 	mark_inode_dirty(inode);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1024) 
2baee03fb9165 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 12:08:36 +0100 1025) out_brelse:
2baee03fb9165 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 12:08:36 +0100 1026) 	brelse(dibh);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1027) out_end_trans:
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1028) 	gfs2_trans_end(sdp);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1029) out_ipres:
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000 1030) 	if (da.nr_blocks)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1031) 		gfs2_inplace_release(dip);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1032) out_gunlock_q:
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000 1033) 	if (da.nr_blocks)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1034) 		gfs2_quota_unlock(dip);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1035) out_gunlock:
2b47dad866d04 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:49:43 +0000 1036) 	gfs2_dir_no_add(&da);
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1037) 	gfs2_glock_dq(ghs + 1);
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1038) out_child:
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1039) 	gfs2_glock_dq(ghs);
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1040) out_parent:
2297ab6144c2e fs/gfs2/inode.c     (Bob Peterson        2020-05-04 10:18:43 -0500 1041) 	gfs2_qa_put(dip);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1042) 	gfs2_holder_uninit(ghs);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1043) 	gfs2_holder_uninit(ghs + 1);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1044) 	return error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1045) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1046) 
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1047) /*
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1048)  * gfs2_unlink_ok - check to see that a inode is still in a directory
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1049)  * @dip: the directory
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1050)  * @name: the name of the file
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1051)  * @ip: the inode
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1052)  *
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1053)  * Assumes that the lock on (at least) @dip is held.
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1054)  *
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1055)  * Returns: 0 if the parent/child relationship is correct, errno if it isn't
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1056)  */
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1057) 
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1058) static int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1059) 			  const struct gfs2_inode *ip)
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1060) {
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1061) 	int error;
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1062) 
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1063) 	if (IS_IMMUTABLE(&ip->i_inode) || IS_APPEND(&ip->i_inode))
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1064) 		return -EPERM;
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1065) 
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1066) 	if ((dip->i_inode.i_mode & S_ISVTX) &&
6b24c0d279eac fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 21:56:13 -0800 1067) 	    !uid_eq(dip->i_inode.i_uid, current_fsuid()) &&
6b24c0d279eac fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 21:56:13 -0800 1068) 	    !uid_eq(ip->i_inode.i_uid, current_fsuid()) && !capable(CAP_FOWNER))
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1069) 		return -EPERM;
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1070) 
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1071) 	if (IS_APPEND(&dip->i_inode))
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1072) 		return -EPERM;
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1073) 
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1074) 	error = gfs2_permission(&init_user_ns, &dip->i_inode,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1075) 				MAY_WRITE | MAY_EXEC);
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1076) 	if (error)
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1077) 		return error;
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1078) 
37975f1503715 fs/gfs2/inode.c     (Fabian Frederick    2014-10-09 22:49:21 +0200 1079) 	return gfs2_dir_check(&dip->i_inode, name, ip);
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1080) }
87ec21741138b fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:54:50 +0100 1081) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1082) /**
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1083)  * gfs2_unlink_inode - Removes an inode from its parent dir and unlinks it
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1084)  * @dip: The parent directory
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100 1085)  * @dentry: The dentry to unlink
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1086)  *
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1087)  * Called with all the locks and in a transaction. This will only be
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1088)  * called for a directory after it has been checked to ensure it is empty.
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1089)  *
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1090)  * Returns: 0 on success, or an error
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1091)  */
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1092) 
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1093) static int gfs2_unlink_inode(struct gfs2_inode *dip,
4327a9bf71f4b fs/gfs2/inode.c     (Bob Peterson        2012-11-12 13:03:29 -0500 1094) 			     const struct dentry *dentry)
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1095) {
2b0143b5c986b fs/gfs2/inode.c     (David Howells       2015-03-17 22:25:59 +0000 1096) 	struct inode *inode = d_inode(dentry);
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1097) 	struct gfs2_inode *ip = GFS2_I(inode);
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1098) 	int error;
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1099) 
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1100) 	error = gfs2_dir_del(dip, dentry);
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1101) 	if (error)
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1102) 		return error;
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1103) 
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1104) 	ip->i_entries = 0;
078cd8279e659 fs/gfs2/inode.c     (Deepa Dinamani      2016-09-14 07:48:04 -0700 1105) 	inode->i_ctime = current_time(inode);
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1106) 	if (S_ISDIR(inode->i_mode))
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1107) 		clear_nlink(inode);
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1108) 	else
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1109) 		drop_nlink(inode);
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1110) 	mark_inode_dirty(inode);
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1111) 	if (inode->i_nlink == 0)
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1112) 		gfs2_unlink_di(inode);
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1113) 	return 0;
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1114) }
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1115) 
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1116) 
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1117) /**
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1118)  * gfs2_unlink - Unlink an inode (this does rmdir as well)
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1119)  * @dir: The inode of the directory containing the inode to unlink
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1120)  * @dentry: The file itself
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1121)  *
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1122)  * This routine uses the type of the inode as a flag to figure out
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1123)  * whether this is an unlink or an rmdir.
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1124)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1125)  * Returns: errno
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1126)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1127) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1128) static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1129) {
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1130) 	struct gfs2_inode *dip = GFS2_I(dir);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1131) 	struct gfs2_sbd *sdp = GFS2_SB(dir);
2b0143b5c986b fs/gfs2/inode.c     (David Howells       2015-03-17 22:25:59 +0000 1132) 	struct inode *inode = d_inode(dentry);
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1133) 	struct gfs2_inode *ip = GFS2_I(inode);
ddee76089cc9b fs/gfs2/ops_inode.c (Russell Cattelan    2007-01-29 17:13:44 -0600 1134) 	struct gfs2_holder ghs[3];
ddee76089cc9b fs/gfs2/ops_inode.c (Russell Cattelan    2007-01-29 17:13:44 -0600 1135) 	struct gfs2_rgrpd *rgd;
5e2f7d617b574 fs/gfs2/inode.c     (Bob Peterson        2012-04-04 22:11:16 -0400 1136) 	int error;
5e2f7d617b574 fs/gfs2/inode.c     (Bob Peterson        2012-04-04 22:11:16 -0400 1137) 
5e2f7d617b574 fs/gfs2/inode.c     (Bob Peterson        2012-04-04 22:11:16 -0400 1138) 	error = gfs2_rindex_update(sdp);
5e2f7d617b574 fs/gfs2/inode.c     (Bob Peterson        2012-04-04 22:11:16 -0400 1139) 	if (error)
5e2f7d617b574 fs/gfs2/inode.c     (Bob Peterson        2012-04-04 22:11:16 -0400 1140) 		return error;
5e2f7d617b574 fs/gfs2/inode.c     (Bob Peterson        2012-04-04 22:11:16 -0400 1141) 
5e2f7d617b574 fs/gfs2/inode.c     (Bob Peterson        2012-04-04 22:11:16 -0400 1142) 	error = -EROFS;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1143) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1144) 	gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
ddee76089cc9b fs/gfs2/ops_inode.c (Russell Cattelan    2007-01-29 17:13:44 -0600 1145) 	gfs2_holder_init(ip->i_gl,  LM_ST_EXCLUSIVE, 0, ghs + 1);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1146) 
66fc061bda352 fs/gfs2/inode.c     (Steven Whitehouse   2012-02-08 12:58:32 +0000 1147) 	rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
a365fbf354907 fs/gfs2/inode.c     (Steven Whitehouse   2012-02-24 15:09:14 +0000 1148) 	if (!rgd)
87654896ca619 fs/gfs2/inode.c     (Steven Whitehouse   2011-11-08 14:04:20 +0000 1149) 		goto out_inodes;
a365fbf354907 fs/gfs2/inode.c     (Steven Whitehouse   2012-02-24 15:09:14 +0000 1150) 
4fc7ec31c3c44 fs/gfs2/inode.c     (Bob Peterson        2018-04-24 10:35:02 -0700 1151) 	gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, LM_FLAG_NODE_SCOPE, ghs + 2);
ddee76089cc9b fs/gfs2/ops_inode.c (Russell Cattelan    2007-01-29 17:13:44 -0600 1152) 
ddee76089cc9b fs/gfs2/ops_inode.c (Russell Cattelan    2007-01-29 17:13:44 -0600 1153) 
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1154) 	error = gfs2_glock_nq(ghs); /* parent */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1155) 	if (error)
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1156) 		goto out_parent;
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1157) 
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1158) 	error = gfs2_glock_nq(ghs + 1); /* child */
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1159) 	if (error)
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1160) 		goto out_child;
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1161) 
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1162) 	error = -ENOENT;
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1163) 	if (inode->i_nlink == 0)
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1164) 		goto out_rgrp;
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1165) 
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1166) 	if (S_ISDIR(inode->i_mode)) {
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1167) 		error = -ENOTEMPTY;
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1168) 		if (ip->i_entries > 2 || inode->i_nlink > 2)
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1169) 			goto out_rgrp;
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1170) 	}
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1171) 
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1172) 	error = gfs2_glock_nq(ghs + 2); /* rgrp */
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1173) 	if (error)
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1174) 		goto out_rgrp;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1175) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1176) 	error = gfs2_unlink_ok(dip, &dentry->d_name, ip);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1177) 	if (error)
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1178) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1179) 
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1180) 	error = gfs2_trans_begin(sdp, 2*RES_DINODE + 3*RES_LEAF + RES_RG_BIT, 0);
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1181) 	if (error)
2eb5909dee9bc fs/gfs2/inode.c     (Bob Peterson        2018-01-29 10:00:23 -0700 1182) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1183) 
4327a9bf71f4b fs/gfs2/inode.c     (Bob Peterson        2012-11-12 13:03:29 -0500 1184) 	error = gfs2_unlink_inode(dip, dentry);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1185) 	gfs2_trans_end(sdp);
2eb5909dee9bc fs/gfs2/inode.c     (Bob Peterson        2018-01-29 10:00:23 -0700 1186) 
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1187) out_gunlock:
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1188) 	gfs2_glock_dq(ghs + 2);
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1189) out_rgrp:
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1190) 	gfs2_glock_dq(ghs + 1);
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1191) out_child:
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1192) 	gfs2_glock_dq(ghs);
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1193) out_parent:
87654896ca619 fs/gfs2/inode.c     (Steven Whitehouse   2011-11-08 14:04:20 +0000 1194) 	gfs2_holder_uninit(ghs + 2);
87654896ca619 fs/gfs2/inode.c     (Steven Whitehouse   2011-11-08 14:04:20 +0000 1195) out_inodes:
87654896ca619 fs/gfs2/inode.c     (Steven Whitehouse   2011-11-08 14:04:20 +0000 1196) 	gfs2_holder_uninit(ghs + 1);
8497a46e178ad fs/gfs2/ops_inode.c (Steven Whitehouse   2007-08-26 14:23:56 +0100 1197) 	gfs2_holder_uninit(ghs);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1198) 	return error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1199) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1200) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1201) /**
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1202)  * gfs2_symlink - Create a symlink
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100 1203)  * @mnt_userns: User namespace of the mount the inode was found from
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1204)  * @dir: The directory to create the symlink in
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1205)  * @dentry: The dentry to put the symlink in
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1206)  * @symname: The thing which the link points to
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1207)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1208)  * Returns: errno
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1209)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1210) 
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1211) static int gfs2_symlink(struct user_namespace *mnt_userns, struct inode *dir,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1212) 			struct dentry *dentry, const char *symname)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1213) {
160b4026dc3e7 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 10:34:59 +0100 1214) 	unsigned int size;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1215) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1216) 	size = strlen(symname);
235628c5c7604 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-11-14 16:53:12 +0100 1217) 	if (size >= gfs2_max_stuffed_size(GFS2_I(dir)))
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1218) 		return -ENAMETOOLONG;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1219) 
b452a458caaa9 fs/gfs2/inode.c     (Al Viro             2018-06-08 13:06:28 -0400 1220) 	return gfs2_create_inode(dir, dentry, NULL, S_IFLNK | S_IRWXUGO, 0, symname, size, 0);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1221) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1222) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1223) /**
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1224)  * gfs2_mkdir - Make a directory
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100 1225)  * @mnt_userns: User namespace of the mount the inode was found from
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1226)  * @dir: The parent directory of the new one
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1227)  * @dentry: The dentry of the new directory
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1228)  * @mode: The mode of the new directory
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1229)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1230)  * Returns: errno
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1231)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1232) 
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1233) static int gfs2_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1234) 		      struct dentry *dentry, umode_t mode)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1235) {
235628c5c7604 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-11-14 16:53:12 +0100 1236) 	unsigned dsize = gfs2_max_stuffed_size(GFS2_I(dir));
b452a458caaa9 fs/gfs2/inode.c     (Al Viro             2018-06-08 13:06:28 -0400 1237) 	return gfs2_create_inode(dir, dentry, NULL, S_IFDIR | mode, 0, NULL, dsize, 0);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1238) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1239) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1240) /**
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1241)  * gfs2_mknod - Make a special file
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100 1242)  * @mnt_userns: User namespace of the mount the inode was found from
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1243)  * @dir: The directory in which the special file will reside
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1244)  * @dentry: The dentry of the special file
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1245)  * @mode: The mode of the special file
f2741d9898269 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 12:11:17 +0100 1246)  * @dev: The device specification of the special file
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1247)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1248)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1249) 
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1250) static int gfs2_mknod(struct user_namespace *mnt_userns, struct inode *dir,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1251) 		      struct dentry *dentry, umode_t mode, dev_t dev)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1252) {
b452a458caaa9 fs/gfs2/inode.c     (Al Viro             2018-06-08 13:06:28 -0400 1253) 	return gfs2_create_inode(dir, dentry, NULL, mode, dev, NULL, 0, 0);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1254) }
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1255) 
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1256) /**
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1257)  * gfs2_atomic_open - Atomically open a file
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1258)  * @dir: The directory
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1259)  * @dentry: The proposed new entry
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1260)  * @file: The proposed new struct file
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1261)  * @flags: open flags
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1262)  * @mode: File mode
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1263)  *
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1264)  * Returns: error code or 0 for success
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1265)  */
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1266) 
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1267) static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
86fbca4923f95 fs/gfs2/inode.c     (Antonio Ospite      2015-05-01 12:54:38 -0500 1268) 			    struct file *file, unsigned flags,
44907d7900246 fs/gfs2/inode.c     (Al Viro             2018-06-08 13:32:02 -0400 1269) 			    umode_t mode)
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1270) {
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1271) 	struct dentry *d;
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1272) 	bool excl = !!(flags & O_EXCL);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1273) 
00699ad8571af fs/gfs2/inode.c     (Al Viro             2016-07-05 09:44:53 -0400 1274) 	if (!d_in_lookup(dentry))
4d93bc3e81736 fs/gfs2/inode.c     (Al Viro             2014-09-12 18:21:05 -0400 1275) 		goto skip_lookup;
4d93bc3e81736 fs/gfs2/inode.c     (Al Viro             2014-09-12 18:21:05 -0400 1276) 
b452a458caaa9 fs/gfs2/inode.c     (Al Viro             2018-06-08 13:06:28 -0400 1277) 	d = __gfs2_lookup(dir, dentry, file);
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1278) 	if (IS_ERR(d))
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1279) 		return PTR_ERR(d);
5ca1db41ecdeb fs/gfs2/inode.c     (Miklos Szeredi      2013-09-23 13:21:04 +0100 1280) 	if (d != NULL)
5ca1db41ecdeb fs/gfs2/inode.c     (Miklos Szeredi      2013-09-23 13:21:04 +0100 1281) 		dentry = d;
2b0143b5c986b fs/gfs2/inode.c     (David Howells       2015-03-17 22:25:59 +0000 1282) 	if (d_really_is_positive(dentry)) {
aad888f828fec fs/gfs2/inode.c     (Al Viro             2018-06-08 12:58:04 -0400 1283) 		if (!(file->f_mode & FMODE_OPENED))
ec7d879c45761 fs/gfs2/inode.c     (Al Viro             2014-11-19 19:35:58 +0000 1284) 			return finish_no_open(file, d);
5ca1db41ecdeb fs/gfs2/inode.c     (Miklos Szeredi      2013-09-23 13:21:04 +0100 1285) 		dput(d);
2103913265028 fs/gfs2/inode.c     (Al Viro             2020-03-10 09:31:41 -0400 1286) 		return excl && (flags & O_CREAT) ? -EEXIST : 0;
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1287) 	}
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1288) 
5ca1db41ecdeb fs/gfs2/inode.c     (Miklos Szeredi      2013-09-23 13:21:04 +0100 1289) 	BUG_ON(d != NULL);
4d93bc3e81736 fs/gfs2/inode.c     (Al Viro             2014-09-12 18:21:05 -0400 1290) 
4d93bc3e81736 fs/gfs2/inode.c     (Al Viro             2014-09-12 18:21:05 -0400 1291) skip_lookup:
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1292) 	if (!(flags & O_CREAT))
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1293) 		return -ENOENT;
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 1294) 
b452a458caaa9 fs/gfs2/inode.c     (Al Viro             2018-06-08 13:06:28 -0400 1295) 	return gfs2_create_inode(dir, dentry, file, S_IFREG | mode, 0, NULL, 0, excl);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1296) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1297) 
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1298) /*
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1299)  * gfs2_ok_to_move - check if it's ok to move a directory to another directory
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1300)  * @this: move this
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1301)  * @to: to here
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1302)  *
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1303)  * Follow @to back to the root and make sure we don't encounter @this
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1304)  * Assumes we already hold the rename lock.
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1305)  *
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1306)  * Returns: errno
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1307)  */
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1308) 
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1309) static int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1310) {
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1311) 	struct inode *dir = &to->i_inode;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1312) 	struct super_block *sb = dir->i_sb;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1313) 	struct inode *tmp;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1314) 	int error = 0;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1315) 
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1316) 	igrab(dir);
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1317) 
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1318) 	for (;;) {
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1319) 		if (dir == &this->i_inode) {
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1320) 			error = -EINVAL;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1321) 			break;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1322) 		}
2b0143b5c986b fs/gfs2/inode.c     (David Howells       2015-03-17 22:25:59 +0000 1323) 		if (dir == d_inode(sb->s_root)) {
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1324) 			error = 0;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1325) 			break;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1326) 		}
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1327) 
8d1235852b462 fs/gfs2/ops_inode.c (Steven Whitehouse   2010-09-17 12:30:23 +0100 1328) 		tmp = gfs2_lookupi(dir, &gfs2_qdotdot, 1);
48f8f711edf38 fs/gfs2/inode.c     (Abhi Das            2014-03-12 03:41:44 -0500 1329) 		if (!tmp) {
48f8f711edf38 fs/gfs2/inode.c     (Abhi Das            2014-03-12 03:41:44 -0500 1330) 			error = -ENOENT;
48f8f711edf38 fs/gfs2/inode.c     (Abhi Das            2014-03-12 03:41:44 -0500 1331) 			break;
48f8f711edf38 fs/gfs2/inode.c     (Abhi Das            2014-03-12 03:41:44 -0500 1332) 		}
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1333) 		if (IS_ERR(tmp)) {
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1334) 			error = PTR_ERR(tmp);
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1335) 			break;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1336) 		}
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1337) 
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1338) 		iput(dir);
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1339) 		dir = tmp;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1340) 	}
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1341) 
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1342) 	iput(dir);
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1343) 
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1344) 	return error;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1345) }
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1346) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1347) /**
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1348)  * update_moved_ino - Update an inode that's being moved
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1349)  * @ip: The inode being moved
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1350)  * @ndip: The parent directory of the new filename
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1351)  * @dir_rename: True of ip is a directory
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1352)  *
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1353)  * Returns: errno
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1354)  */
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1355) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1356) static int update_moved_ino(struct gfs2_inode *ip, struct gfs2_inode *ndip,
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1357) 			    int dir_rename)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1358) {
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1359) 	if (dir_rename)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1360) 		return gfs2_dir_mvino(ip, &gfs2_qdotdot, ndip, DT_DIR);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1361) 
078cd8279e659 fs/gfs2/inode.c     (Deepa Dinamani      2016-09-14 07:48:04 -0700 1362) 	ip->i_inode.i_ctime = current_time(&ip->i_inode);
83998ccd9bfff fs/gfs2/inode.c     (Andreas Gruenbacher 2018-02-28 12:48:53 -0700 1363) 	mark_inode_dirty_sync(&ip->i_inode);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1364) 	return 0;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1365) }
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1366) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1367) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1368) /**
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1369)  * gfs2_rename - Rename a file
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1370)  * @odir: Parent directory of old file name
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1371)  * @odentry: The old dentry of the file
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1372)  * @ndir: Parent directory of new file name
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1373)  * @ndentry: The new dentry of the file
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1374)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1375)  * Returns: errno
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1376)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1377) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1378) static int gfs2_rename(struct inode *odir, struct dentry *odentry,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1379) 		       struct inode *ndir, struct dentry *ndentry)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1380) {
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1381) 	struct gfs2_inode *odip = GFS2_I(odir);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1382) 	struct gfs2_inode *ndip = GFS2_I(ndir);
2b0143b5c986b fs/gfs2/inode.c     (David Howells       2015-03-17 22:25:59 +0000 1383) 	struct gfs2_inode *ip = GFS2_I(d_inode(odentry));
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1384) 	struct gfs2_inode *nip = NULL;
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1385) 	struct gfs2_sbd *sdp = GFS2_SB(odir);
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1386) 	struct gfs2_holder ghs[4], r_gh, rd_gh;
ddee76089cc9b fs/gfs2/ops_inode.c (Russell Cattelan    2007-01-29 17:13:44 -0600 1387) 	struct gfs2_rgrpd *nrgd;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1388) 	unsigned int num_gh;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1389) 	int dir_rename = 0;
19aeb5a65f1a6 fs/gfs2/inode.c     (Bob Peterson        2014-09-29 08:52:04 -0400 1390) 	struct gfs2_diradd da = { .nr_blocks = 0, .save_loc = 0, };
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1391) 	unsigned int x;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1392) 	int error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1393) 
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500 1394) 	gfs2_holder_mark_uninitialized(&r_gh);
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1395) 	gfs2_holder_mark_uninitialized(&rd_gh);
2b0143b5c986b fs/gfs2/inode.c     (David Howells       2015-03-17 22:25:59 +0000 1396) 	if (d_really_is_positive(ndentry)) {
2b0143b5c986b fs/gfs2/inode.c     (David Howells       2015-03-17 22:25:59 +0000 1397) 		nip = GFS2_I(d_inode(ndentry));
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1398) 		if (ip == nip)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1399) 			return 0;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1400) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1401) 
5e2f7d617b574 fs/gfs2/inode.c     (Bob Peterson        2012-04-04 22:11:16 -0400 1402) 	error = gfs2_rindex_update(sdp);
5e2f7d617b574 fs/gfs2/inode.c     (Bob Peterson        2012-04-04 22:11:16 -0400 1403) 	if (error)
5e2f7d617b574 fs/gfs2/inode.c     (Bob Peterson        2012-04-04 22:11:16 -0400 1404) 		return error;
5e2f7d617b574 fs/gfs2/inode.c     (Bob Peterson        2012-04-04 22:11:16 -0400 1405) 
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 1406) 	error = gfs2_qa_get(ndip);
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100 1407) 	if (error)
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100 1408) 		return error;
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100 1409) 
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1410) 	if (odip != ndip) {
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1411) 		error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE,
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1412) 					   0, &r_gh);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1413) 		if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1414) 			goto out;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1415) 
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1416) 		if (S_ISDIR(ip->i_inode.i_mode)) {
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1417) 			dir_rename = 1;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1418) 			/* don't move a directory into its subdir */
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1419) 			error = gfs2_ok_to_move(ip, ndip);
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1420) 			if (error)
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1421) 				goto out_gunlock_r;
0188d6c5807b6 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-08-26 09:38:26 +0100 1422) 		}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1423) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1424) 
d9d1ca30505c6 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-21 15:38:17 -0400 1425) 	num_gh = 1;
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1426) 	gfs2_holder_init(odip->i_gl, LM_ST_EXCLUSIVE, GL_ASYNC, ghs);
d9d1ca30505c6 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-21 15:38:17 -0400 1427) 	if (odip != ndip) {
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1428) 		gfs2_holder_init(ndip->i_gl, LM_ST_EXCLUSIVE,GL_ASYNC,
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1429) 				 ghs + num_gh);
d9d1ca30505c6 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-21 15:38:17 -0400 1430) 		num_gh++;
d9d1ca30505c6 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-21 15:38:17 -0400 1431) 	}
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1432) 	gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ASYNC, ghs + num_gh);
d9d1ca30505c6 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-21 15:38:17 -0400 1433) 	num_gh++;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1434) 
d9d1ca30505c6 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-21 15:38:17 -0400 1435) 	if (nip) {
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1436) 		gfs2_holder_init(nip->i_gl, LM_ST_EXCLUSIVE, GL_ASYNC,
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1437) 				 ghs + num_gh);
d9d1ca30505c6 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-21 15:38:17 -0400 1438) 		num_gh++;
d9d1ca30505c6 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-21 15:38:17 -0400 1439) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1440) 
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1441) 	for (x = 0; x < num_gh; x++) {
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1442) 		error = gfs2_glock_nq(ghs + x);
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1443) 		if (error)
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1444) 			goto out_gunlock;
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1445) 	}
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1446) 	error = gfs2_glock_async_wait(num_gh, ghs);
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1447) 	if (error)
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1448) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1449) 
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1450) 	if (nip) {
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1451) 		/* Grab the resource group glock for unlink flag twiddling.
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1452) 		 * This is the case where the target dinode already exists
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1453) 		 * so we unlink before doing the rename.
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1454) 		 */
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1455) 		nrgd = gfs2_blk2rgrpd(sdp, nip->i_no_addr, 1);
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1456) 		if (!nrgd) {
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1457) 			error = -ENOENT;
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1458) 			goto out_gunlock;
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1459) 		}
4fc7ec31c3c44 fs/gfs2/inode.c     (Bob Peterson        2018-04-24 10:35:02 -0700 1460) 		error = gfs2_glock_nq_init(nrgd->rd_gl, LM_ST_EXCLUSIVE,
4fc7ec31c3c44 fs/gfs2/inode.c     (Bob Peterson        2018-04-24 10:35:02 -0700 1461) 					   LM_FLAG_NODE_SCOPE, &rd_gh);
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1462) 		if (error)
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1463) 			goto out_gunlock;
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1464) 	}
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1465) 
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1466) 	error = -ENOENT;
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1467) 	if (ip->i_inode.i_nlink == 0)
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1468) 		goto out_gunlock;
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1469) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1470) 	/* Check out the old directory */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1471) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1472) 	error = gfs2_unlink_ok(odip, &odentry->d_name, ip);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1473) 	if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1474) 		goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1475) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1476) 	/* Check out the new directory */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1477) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1478) 	if (nip) {
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1479) 		error = gfs2_unlink_ok(ndip, &ndentry->d_name, nip);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1480) 		if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1481) 			goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1482) 
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1483) 		if (nip->i_inode.i_nlink == 0) {
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1484) 			error = -EAGAIN;
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1485) 			goto out_gunlock;
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1486) 		}
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1487) 
b60623c238b6a fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-01 12:22:46 -0500 1488) 		if (S_ISDIR(nip->i_inode.i_mode)) {
ad6203f2b46c2 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-11-03 13:59:19 +0000 1489) 			if (nip->i_entries < 2) {
94fb763b1a76a fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 13:36:10 +0100 1490) 				gfs2_consist_inode(nip);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1491) 				error = -EIO;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1492) 				goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1493) 			}
ad6203f2b46c2 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-11-03 13:59:19 +0000 1494) 			if (nip->i_entries > 2) {
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1495) 				error = -ENOTEMPTY;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1496) 				goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1497) 			}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1498) 		}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1499) 	} else {
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1500) 		error = gfs2_permission(&init_user_ns, ndir,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1501) 					MAY_WRITE | MAY_EXEC);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1502) 		if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1503) 			goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1504) 
dbb7cae2a3617 fs/gfs2/ops_inode.c (Steven Whitehouse   2007-05-15 15:37:50 +0100 1505) 		error = gfs2_dir_check(ndir, &ndentry->d_name, NULL);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1506) 		switch (error) {
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1507) 		case -ENOENT:
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1508) 			error = 0;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1509) 			break;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1510) 		case 0:
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1511) 			error = -EEXIST;
e5966cf20f0c7 fs/gfs2/inode.c     (Gustavo A. R. Silva 2020-11-20 12:25:03 -0600 1512) 			goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1513) 		default:
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1514) 			goto out_gunlock;
098b9c1453629 fs/gfs2/inode.c     (Aliasgar Surti      2019-10-04 10:55:29 -0500 1515) 		}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1516) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1517) 		if (odip != ndip) {
4f56110a00af5 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-01 14:04:17 -0500 1518) 			if (!ndip->i_inode.i_nlink) {
d192a8e5c6fec fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-05 12:35:40 +0100 1519) 				error = -ENOENT;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1520) 				goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1521) 			}
ad6203f2b46c2 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-11-03 13:59:19 +0000 1522) 			if (ndip->i_entries == (u32)-1) {
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1523) 				error = -EFBIG;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1524) 				goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1525) 			}
b60623c238b6a fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-01 12:22:46 -0500 1526) 			if (S_ISDIR(ip->i_inode.i_mode) &&
4f56110a00af5 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-01 14:04:17 -0500 1527) 			    ndip->i_inode.i_nlink == (u32)-1) {
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1528) 				error = -EMLINK;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1529) 				goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1530) 			}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1531) 		}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1532) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1533) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1534) 	/* Check out the dir to be renamed */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1535) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1536) 	if (dir_rename) {
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1537) 		error = gfs2_permission(&init_user_ns, d_inode(odentry),
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1538) 					MAY_WRITE);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1539) 		if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1540) 			goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1541) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1542) 
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000 1543) 	if (nip == NULL) {
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000 1544) 		error = gfs2_diradd_alloc_required(ndir, &ndentry->d_name, &da);
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000 1545) 		if (error)
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000 1546) 			goto out_gunlock;
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000 1547) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1548) 
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000 1549) 	if (da.nr_blocks) {
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000 1550) 		struct gfs2_alloc_parms ap = { .target = da.nr_blocks, };
b8fbf471edb3d fs/gfs2/inode.c     (Abhi Das            2015-03-18 12:03:41 -0500 1551) 		error = gfs2_quota_lock_check(ndip, &ap);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1552) 		if (error)
5407e24229408 fs/gfs2/inode.c     (Bob Peterson        2012-05-18 09:28:23 -0400 1553) 			goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1554) 
7b9cff467144c fs/gfs2/inode.c     (Steven Whitehouse   2013-10-02 11:13:25 +0100 1555) 		error = gfs2_inplace_reserve(ndip, &ap);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1556) 		if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1557) 			goto out_gunlock_q;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1558) 
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000 1559) 		error = gfs2_trans_begin(sdp, gfs2_trans_da_blks(ndip, &da, 4) +
534cf9ca55395 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:03:05 +0000 1560) 					 4 * RES_LEAF + 4, 0);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1561) 		if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1562) 			goto out_ipreserv;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1563) 	} else {
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1564) 		error = gfs2_trans_begin(sdp, 4 * RES_DINODE +
87d21e07f3880 fs/gfs2/ops_inode.c (S. Wendy Cheng      2007-01-18 16:07:03 -0500 1565) 					 5 * RES_LEAF + 4, 0);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1566) 		if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1567) 			goto out_gunlock;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1568) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1569) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1570) 	/* Remove the target file, if it exists */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1571) 
4327a9bf71f4b fs/gfs2/inode.c     (Bob Peterson        2012-11-12 13:03:29 -0500 1572) 	if (nip)
4327a9bf71f4b fs/gfs2/inode.c     (Bob Peterson        2012-11-12 13:03:29 -0500 1573) 		error = gfs2_unlink_inode(ndip, ndentry);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1574) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1575) 	error = update_moved_ino(ip, ndip, dir_rename);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1576) 	if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1577) 		goto out_end_trans;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1578) 
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 1579) 	error = gfs2_dir_del(odip, odentry);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1580) 	if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1581) 		goto out_end_trans;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1582) 
2b47dad866d04 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:49:43 +0000 1583) 	error = gfs2_dir_add(ndir, &ndentry->d_name, ip, &da);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1584) 	if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1585) 		goto out_end_trans;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1586) 
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1587) out_end_trans:
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1588) 	gfs2_trans_end(sdp);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1589) out_ipreserv:
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000 1590) 	if (da.nr_blocks)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1591) 		gfs2_inplace_release(ndip);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1592) out_gunlock_q:
3c1c0ae1db74b fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 11:28:41 +0000 1593) 	if (da.nr_blocks)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1594) 		gfs2_quota_unlock(ndip);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1595) out_gunlock:
2b47dad866d04 fs/gfs2/inode.c     (Steven Whitehouse   2014-01-06 12:49:43 +0000 1596) 	gfs2_dir_no_add(&da);
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1597) 	if (gfs2_holder_initialized(&rd_gh))
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1598) 		gfs2_glock_dq_uninit(&rd_gh);
bc74aaefdd538 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:00 -0500 1599) 
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1600) 	while (x--) {
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1601) 		if (gfs2_holder_queued(ghs + x))
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1602) 			gfs2_glock_dq(ghs + x);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1603) 		gfs2_holder_uninit(ghs + x);
72dbf4790fc67 fs/gfs2/ops_inode.c (Bob Peterson        2008-08-12 13:39:29 -0500 1604) 	}
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1605) out_gunlock_r:
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500 1606) 	if (gfs2_holder_initialized(&r_gh))
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1607) 		gfs2_glock_dq_uninit(&r_gh);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1608) out:
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 1609) 	gfs2_qa_put(ndip);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1610) 	return error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1611) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1612) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1613) /**
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1614)  * gfs2_exchange - exchange two files
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1615)  * @odir: Parent directory of old file name
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1616)  * @odentry: The old dentry of the file
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1617)  * @ndir: Parent directory of new file name
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1618)  * @ndentry: The new dentry of the file
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1619)  * @flags: The rename flags
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1620)  *
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1621)  * Returns: errno
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1622)  */
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1623) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1624) static int gfs2_exchange(struct inode *odir, struct dentry *odentry,
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1625) 			 struct inode *ndir, struct dentry *ndentry,
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1626) 			 unsigned int flags)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1627) {
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1628) 	struct gfs2_inode *odip = GFS2_I(odir);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1629) 	struct gfs2_inode *ndip = GFS2_I(ndir);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1630) 	struct gfs2_inode *oip = GFS2_I(odentry->d_inode);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1631) 	struct gfs2_inode *nip = GFS2_I(ndentry->d_inode);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1632) 	struct gfs2_sbd *sdp = GFS2_SB(odir);
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1633) 	struct gfs2_holder ghs[4], r_gh;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1634) 	unsigned int num_gh;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1635) 	unsigned int x;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1636) 	umode_t old_mode = oip->i_inode.i_mode;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1637) 	umode_t new_mode = nip->i_inode.i_mode;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1638) 	int error;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1639) 
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500 1640) 	gfs2_holder_mark_uninitialized(&r_gh);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1641) 	error = gfs2_rindex_update(sdp);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1642) 	if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1643) 		return error;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1644) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1645) 	if (odip != ndip) {
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1646) 		error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE,
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1647) 					   0, &r_gh);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1648) 		if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1649) 			goto out;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1650) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1651) 		if (S_ISDIR(old_mode)) {
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1652) 			/* don't move a directory into its subdir */
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1653) 			error = gfs2_ok_to_move(oip, ndip);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1654) 			if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1655) 				goto out_gunlock_r;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1656) 		}
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1657) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1658) 		if (S_ISDIR(new_mode)) {
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1659) 			/* don't move a directory into its subdir */
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1660) 			error = gfs2_ok_to_move(nip, odip);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1661) 			if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1662) 				goto out_gunlock_r;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1663) 		}
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1664) 	}
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1665) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1666) 	num_gh = 1;
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1667) 	gfs2_holder_init(odip->i_gl, LM_ST_EXCLUSIVE, GL_ASYNC, ghs);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1668) 	if (odip != ndip) {
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1669) 		gfs2_holder_init(ndip->i_gl, LM_ST_EXCLUSIVE, GL_ASYNC,
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1670) 				 ghs + num_gh);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1671) 		num_gh++;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1672) 	}
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1673) 	gfs2_holder_init(oip->i_gl, LM_ST_EXCLUSIVE, GL_ASYNC, ghs + num_gh);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1674) 	num_gh++;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1675) 
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1676) 	gfs2_holder_init(nip->i_gl, LM_ST_EXCLUSIVE, GL_ASYNC, ghs + num_gh);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1677) 	num_gh++;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1678) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1679) 	for (x = 0; x < num_gh; x++) {
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1680) 		error = gfs2_glock_nq(ghs + x);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1681) 		if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1682) 			goto out_gunlock;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1683) 	}
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1684) 
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1685) 	error = gfs2_glock_async_wait(num_gh, ghs);
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1686) 	if (error)
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1687) 		goto out_gunlock;
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1688) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1689) 	error = -ENOENT;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1690) 	if (oip->i_inode.i_nlink == 0 || nip->i_inode.i_nlink == 0)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1691) 		goto out_gunlock;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1692) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1693) 	error = gfs2_unlink_ok(odip, &odentry->d_name, oip);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1694) 	if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1695) 		goto out_gunlock;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1696) 	error = gfs2_unlink_ok(ndip, &ndentry->d_name, nip);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1697) 	if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1698) 		goto out_gunlock;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1699) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1700) 	if (S_ISDIR(old_mode)) {
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1701) 		error = gfs2_permission(&init_user_ns, odentry->d_inode,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1702) 					MAY_WRITE);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1703) 		if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1704) 			goto out_gunlock;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1705) 	}
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1706) 	if (S_ISDIR(new_mode)) {
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1707) 		error = gfs2_permission(&init_user_ns, ndentry->d_inode,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1708) 					MAY_WRITE);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1709) 		if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1710) 			goto out_gunlock;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1711) 	}
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1712) 	error = gfs2_trans_begin(sdp, 4 * RES_DINODE + 4 * RES_LEAF, 0);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1713) 	if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1714) 		goto out_gunlock;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1715) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1716) 	error = update_moved_ino(oip, ndip, S_ISDIR(old_mode));
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1717) 	if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1718) 		goto out_end_trans;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1719) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1720) 	error = update_moved_ino(nip, odip, S_ISDIR(new_mode));
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1721) 	if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1722) 		goto out_end_trans;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1723) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1724) 	error = gfs2_dir_mvino(ndip, &ndentry->d_name, oip,
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1725) 			       IF2DT(old_mode));
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1726) 	if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1727) 		goto out_end_trans;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1728) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1729) 	error = gfs2_dir_mvino(odip, &odentry->d_name, nip,
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1730) 			       IF2DT(new_mode));
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1731) 	if (error)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1732) 		goto out_end_trans;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1733) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1734) 	if (odip != ndip) {
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1735) 		if (S_ISDIR(new_mode) && !S_ISDIR(old_mode)) {
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1736) 			inc_nlink(&odip->i_inode);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1737) 			drop_nlink(&ndip->i_inode);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1738) 		} else if (S_ISDIR(old_mode) && !S_ISDIR(new_mode)) {
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1739) 			inc_nlink(&ndip->i_inode);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1740) 			drop_nlink(&odip->i_inode);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1741) 		}
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1742) 	}
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1743) 	mark_inode_dirty(&ndip->i_inode);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1744) 	if (odip != ndip)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1745) 		mark_inode_dirty(&odip->i_inode);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1746) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1747) out_end_trans:
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1748) 	gfs2_trans_end(sdp);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1749) out_gunlock:
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1750) 	while (x--) {
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1751) 		if (gfs2_holder_queued(ghs + x))
ad26967b9afa7 fs/gfs2/inode.c     (Bob Peterson        2019-08-30 12:31:02 -0500 1752) 			gfs2_glock_dq(ghs + x);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1753) 		gfs2_holder_uninit(ghs + x);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1754) 	}
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1755) out_gunlock_r:
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500 1756) 	if (gfs2_holder_initialized(&r_gh))
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1757) 		gfs2_glock_dq_uninit(&r_gh);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1758) out:
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1759) 	return error;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1760) }
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1761) 
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1762) static int gfs2_rename2(struct user_namespace *mnt_userns, struct inode *odir,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1763) 			struct dentry *odentry, struct inode *ndir,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1764) 			struct dentry *ndentry, unsigned int flags)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1765) {
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1766) 	flags &= ~RENAME_NOREPLACE;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1767) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1768) 	if (flags & ~RENAME_EXCHANGE)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1769) 		return -EINVAL;
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1770) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1771) 	if (flags & RENAME_EXCHANGE)
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1772) 		return gfs2_exchange(odir, odentry, ndir, ndentry, flags);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1773) 
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1774) 	return gfs2_rename(odir, odentry, ndir, ndentry);
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1775) }
a63b7bbc21759 fs/gfs2/inode.c     (Benjamin Marzinski  2015-05-05 12:12:19 -0500 1776) 
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1777) /**
6b2553918d8b4 fs/gfs2/inode.c     (Al Viro             2015-11-17 10:20:54 -0500 1778)  * gfs2_get_link - Follow a symbolic link
c177c2ac8c5aa fs/gfs2/ops_inode.c (Al Viro             2010-01-14 00:59:16 -0500 1779)  * @dentry: The dentry of the link
6b2553918d8b4 fs/gfs2/inode.c     (Al Viro             2015-11-17 10:20:54 -0500 1780)  * @inode: The inode of the link
fceef393a5381 fs/gfs2/inode.c     (Al Viro             2015-12-29 15:58:39 -0500 1781)  * @done: destructor for return value
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1782)  *
c177c2ac8c5aa fs/gfs2/ops_inode.c (Al Viro             2010-01-14 00:59:16 -0500 1783)  * This can handle symlinks of any size.
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1784)  *
c177c2ac8c5aa fs/gfs2/ops_inode.c (Al Viro             2010-01-14 00:59:16 -0500 1785)  * Returns: 0 on success or error code
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1786)  */
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1787) 
6b2553918d8b4 fs/gfs2/inode.c     (Al Viro             2015-11-17 10:20:54 -0500 1788) static const char *gfs2_get_link(struct dentry *dentry,
fceef393a5381 fs/gfs2/inode.c     (Al Viro             2015-12-29 15:58:39 -0500 1789) 				 struct inode *inode,
fceef393a5381 fs/gfs2/inode.c     (Al Viro             2015-12-29 15:58:39 -0500 1790) 				 struct delayed_call *done)
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1791) {
6b2553918d8b4 fs/gfs2/inode.c     (Al Viro             2015-11-17 10:20:54 -0500 1792) 	struct gfs2_inode *ip = GFS2_I(inode);
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1793) 	struct gfs2_holder i_gh;
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1794) 	struct buffer_head *dibh;
160b4026dc3e7 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 10:34:59 +0100 1795) 	unsigned int size;
c177c2ac8c5aa fs/gfs2/ops_inode.c (Al Viro             2010-01-14 00:59:16 -0500 1796) 	char *buf;
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1797) 	int error;
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1798) 
6b2553918d8b4 fs/gfs2/inode.c     (Al Viro             2015-11-17 10:20:54 -0500 1799) 	if (!dentry)
6b2553918d8b4 fs/gfs2/inode.c     (Al Viro             2015-11-17 10:20:54 -0500 1800) 		return ERR_PTR(-ECHILD);
6b2553918d8b4 fs/gfs2/inode.c     (Al Viro             2015-11-17 10:20:54 -0500 1801) 
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1802) 	gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh);
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1803) 	error = gfs2_glock_nq(&i_gh);
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1804) 	if (error) {
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1805) 		gfs2_holder_uninit(&i_gh);
680baacbca69d fs/gfs2/inode.c     (Al Viro             2015-05-02 13:32:22 -0400 1806) 		return ERR_PTR(error);
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1807) 	}
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1808) 
a2e0f79939e09 fs/gfs2/ops_inode.c (Steven Whitehouse   2010-08-11 09:53:11 +0100 1809) 	size = (unsigned int)i_size_read(&ip->i_inode);
a2e0f79939e09 fs/gfs2/ops_inode.c (Steven Whitehouse   2010-08-11 09:53:11 +0100 1810) 	if (size == 0) {
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1811) 		gfs2_consist_inode(ip);
c177c2ac8c5aa fs/gfs2/ops_inode.c (Al Viro             2010-01-14 00:59:16 -0500 1812) 		buf = ERR_PTR(-EIO);
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1813) 		goto out;
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1814) 	}
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1815) 
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1816) 	error = gfs2_meta_inode_buffer(ip, &dibh);
c177c2ac8c5aa fs/gfs2/ops_inode.c (Al Viro             2010-01-14 00:59:16 -0500 1817) 	if (error) {
c177c2ac8c5aa fs/gfs2/ops_inode.c (Al Viro             2010-01-14 00:59:16 -0500 1818) 		buf = ERR_PTR(error);
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1819) 		goto out;
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1820) 	}
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1821) 
160b4026dc3e7 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 10:34:59 +0100 1822) 	buf = kzalloc(size + 1, GFP_NOFS);
c177c2ac8c5aa fs/gfs2/ops_inode.c (Al Viro             2010-01-14 00:59:16 -0500 1823) 	if (!buf)
c177c2ac8c5aa fs/gfs2/ops_inode.c (Al Viro             2010-01-14 00:59:16 -0500 1824) 		buf = ERR_PTR(-ENOMEM);
c177c2ac8c5aa fs/gfs2/ops_inode.c (Al Viro             2010-01-14 00:59:16 -0500 1825) 	else
160b4026dc3e7 fs/gfs2/inode.c     (Steven Whitehouse   2011-05-13 10:34:59 +0100 1826) 		memcpy(buf, dibh->b_data + sizeof(struct gfs2_dinode), size);
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1827) 	brelse(dibh);
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1828) out:
536baf02f650f fs/gfs2/ops_inode.c (Steven Whitehouse   2009-05-22 10:48:59 +0100 1829) 	gfs2_glock_dq_uninit(&i_gh);
680baacbca69d fs/gfs2/inode.c     (Al Viro             2015-05-02 13:32:22 -0400 1830) 	if (!IS_ERR(buf))
fceef393a5381 fs/gfs2/inode.c     (Al Viro             2015-12-29 15:58:39 -0500 1831) 		set_delayed_call(done, kfree_link, buf);
680baacbca69d fs/gfs2/inode.c     (Al Viro             2015-05-02 13:32:22 -0400 1832) 	return buf;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1833) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1834) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1835) /**
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100 1836)  * gfs2_permission
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100 1837)  * @mnt_userns: User namespace of the mount the inode was found from
75d5cfbe4b78c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-01-19 09:42:40 +0000 1838)  * @inode: The inode
75d5cfbe4b78c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-01-19 09:42:40 +0000 1839)  * @mask: The mask to be tested
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1840)  *
300c7d75f3a5e fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 09:55:28 -0500 1841)  * This may be called from the VFS directly, or from within GFS2 with the
300c7d75f3a5e fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 09:55:28 -0500 1842)  * inode locked, so we look to see if the glock is already locked and only
300c7d75f3a5e fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 09:55:28 -0500 1843)  * lock the glock if its not already been done.
300c7d75f3a5e fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 09:55:28 -0500 1844)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1845)  * Returns: errno
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1846)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1847) 
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1848) int gfs2_permission(struct user_namespace *mnt_userns, struct inode *inode,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1849) 		    int mask)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1850) {
b74c79e99389c fs/gfs2/ops_inode.c (Nicholas Piggin     2011-01-07 17:49:58 +1100 1851) 	struct gfs2_inode *ip;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1852) 	struct gfs2_holder i_gh;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1853) 	int error;
b74c79e99389c fs/gfs2/ops_inode.c (Nicholas Piggin     2011-01-07 17:49:58 +1100 1854) 
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500 1855) 	gfs2_holder_mark_uninitialized(&i_gh);
b74c79e99389c fs/gfs2/ops_inode.c (Nicholas Piggin     2011-01-07 17:49:58 +1100 1856) 	ip = GFS2_I(inode);
7afd88d9166a7 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-02-22 16:07:18 +0000 1857) 	if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) {
2e60d7683c8d2 fs/gfs2/inode.c     (Benjamin Marzinski  2014-11-13 20:42:04 -0600 1858) 		if (mask & MAY_NOT_BLOCK)
2e60d7683c8d2 fs/gfs2/inode.c     (Benjamin Marzinski  2014-11-13 20:42:04 -0600 1859) 			return -ECHILD;
2e60d7683c8d2 fs/gfs2/inode.c     (Benjamin Marzinski  2014-11-13 20:42:04 -0600 1860) 		error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
2e60d7683c8d2 fs/gfs2/inode.c     (Benjamin Marzinski  2014-11-13 20:42:04 -0600 1861) 		if (error)
2e60d7683c8d2 fs/gfs2/inode.c     (Benjamin Marzinski  2014-11-13 20:42:04 -0600 1862) 			return error;
300c7d75f3a5e fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 09:55:28 -0500 1863) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1864) 
f58ba889106af fs/gfs2/ops_inode.c (Miklos Szeredi      2008-07-02 21:12:01 +0200 1865) 	if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
337684a1746f9 fs/gfs2/inode.c     (Eryu Guan           2016-08-02 19:58:28 +0800 1866) 		error = -EPERM;
f58ba889106af fs/gfs2/ops_inode.c (Miklos Szeredi      2008-07-02 21:12:01 +0200 1867) 	else
47291baa8ddfd fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:24 +0100 1868) 		error = generic_permission(&init_user_ns, inode, mask);
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500 1869) 	if (gfs2_holder_initialized(&i_gh))
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1870) 		gfs2_glock_dq_uninit(&i_gh);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1871) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1872) 	return error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1873) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1874) 
ab9bbda0204df fs/gfs2/inode.c     (Steven Whitehouse   2011-08-15 14:20:36 +0100 1875) static int __gfs2_setattr_simple(struct inode *inode, struct iattr *attr)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1876) {
2f221d6f7b881 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:26 +0100 1877) 	setattr_copy(&init_user_ns, inode, attr);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1878) 	mark_inode_dirty(inode);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1879) 	return 0;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1880) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1881) 
a4122a95ce6a6 fs/gfs2/inode.c     (Andreas Gruenbacher 2021-04-07 00:59:03 +0200 1882) static int gfs2_setattr_simple(struct inode *inode, struct iattr *attr)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1883) {
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1884) 	int error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1885) 
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1886) 	if (current->journal_info)
ab9bbda0204df fs/gfs2/inode.c     (Steven Whitehouse   2011-08-15 14:20:36 +0100 1887) 		return __gfs2_setattr_simple(inode, attr);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1888) 
ab9bbda0204df fs/gfs2/inode.c     (Steven Whitehouse   2011-08-15 14:20:36 +0100 1889) 	error = gfs2_trans_begin(GFS2_SB(inode), RES_DINODE, 0);
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1890) 	if (error)
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1891) 		return error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1892) 
ab9bbda0204df fs/gfs2/inode.c     (Steven Whitehouse   2011-08-15 14:20:36 +0100 1893) 	error = __gfs2_setattr_simple(inode, attr);
ab9bbda0204df fs/gfs2/inode.c     (Steven Whitehouse   2011-08-15 14:20:36 +0100 1894) 	gfs2_trans_end(GFS2_SB(inode));
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1895) 	return error;
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1896) }
194c011fc4650 fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 14:06:38 +0100 1897) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1898) static int setattr_chown(struct inode *inode, struct iattr *attr)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1899) {
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1900) 	struct gfs2_inode *ip = GFS2_I(inode);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1901) 	struct gfs2_sbd *sdp = GFS2_SB(inode);
7c06b5d67225d fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 20:27:54 -0800 1902) 	kuid_t ouid, nuid;
7c06b5d67225d fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 20:27:54 -0800 1903) 	kgid_t ogid, ngid;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1904) 	int error;
b8fbf471edb3d fs/gfs2/inode.c     (Abhi Das            2015-03-18 12:03:41 -0500 1905) 	struct gfs2_alloc_parms ap;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1906) 
2933f9254a6af fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-01 13:23:29 -0500 1907) 	ouid = inode->i_uid;
2933f9254a6af fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-01 13:23:29 -0500 1908) 	ogid = inode->i_gid;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1909) 	nuid = attr->ia_uid;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1910) 	ngid = attr->ia_gid;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1911) 
6b24c0d279eac fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 21:56:13 -0800 1912) 	if (!(attr->ia_valid & ATTR_UID) || uid_eq(ouid, nuid))
f4108a607f75b fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 17:49:26 -0800 1913) 		ouid = nuid = NO_UID_QUOTA_CHANGE;
6b24c0d279eac fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 21:56:13 -0800 1914) 	if (!(attr->ia_valid & ATTR_GID) || gid_eq(ogid, ngid))
f4108a607f75b fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 17:49:26 -0800 1915) 		ogid = ngid = NO_GID_QUOTA_CHANGE;
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 1916) 	error = gfs2_qa_get(ip);
62e96cf819881 fs/gfs2/inode.c     (Bob Peterson        2014-01-06 17:16:01 -0500 1917) 	if (error)
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 1918) 		return error;
62e96cf819881 fs/gfs2/inode.c     (Bob Peterson        2014-01-06 17:16:01 -0500 1919) 
62e96cf819881 fs/gfs2/inode.c     (Bob Peterson        2014-01-06 17:16:01 -0500 1920) 	error = gfs2_rindex_update(sdp);
62e96cf819881 fs/gfs2/inode.c     (Bob Peterson        2014-01-06 17:16:01 -0500 1921) 	if (error)
62e96cf819881 fs/gfs2/inode.c     (Bob Peterson        2014-01-06 17:16:01 -0500 1922) 		goto out;
62e96cf819881 fs/gfs2/inode.c     (Bob Peterson        2014-01-06 17:16:01 -0500 1923) 
62e96cf819881 fs/gfs2/inode.c     (Bob Peterson        2014-01-06 17:16:01 -0500 1924) 	error = gfs2_quota_lock(ip, nuid, ngid);
62e96cf819881 fs/gfs2/inode.c     (Bob Peterson        2014-01-06 17:16:01 -0500 1925) 	if (error)
62e96cf819881 fs/gfs2/inode.c     (Bob Peterson        2014-01-06 17:16:01 -0500 1926) 		goto out;
62e96cf819881 fs/gfs2/inode.c     (Bob Peterson        2014-01-06 17:16:01 -0500 1927) 
b8fbf471edb3d fs/gfs2/inode.c     (Abhi Das            2015-03-18 12:03:41 -0500 1928) 	ap.target = gfs2_get_inode_blocks(&ip->i_inode);
b8fbf471edb3d fs/gfs2/inode.c     (Abhi Das            2015-03-18 12:03:41 -0500 1929) 
6b24c0d279eac fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 21:56:13 -0800 1930) 	if (!uid_eq(ouid, NO_UID_QUOTA_CHANGE) ||
6b24c0d279eac fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 21:56:13 -0800 1931) 	    !gid_eq(ogid, NO_GID_QUOTA_CHANGE)) {
b8fbf471edb3d fs/gfs2/inode.c     (Abhi Das            2015-03-18 12:03:41 -0500 1932) 		error = gfs2_quota_check(ip, nuid, ngid, &ap);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1933) 		if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1934) 			goto out_gunlock_q;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1935) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1936) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1937) 	error = gfs2_trans_begin(sdp, RES_DINODE + 2 * RES_QUOTA, 0);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1938) 	if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1939) 		goto out_gunlock_q;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1940) 
ab9bbda0204df fs/gfs2/inode.c     (Steven Whitehouse   2011-08-15 14:20:36 +0100 1941) 	error = gfs2_setattr_simple(inode, attr);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1942) 	if (error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1943) 		goto out_end_trans;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1944) 
6b24c0d279eac fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 21:56:13 -0800 1945) 	if (!uid_eq(ouid, NO_UID_QUOTA_CHANGE) ||
6b24c0d279eac fs/gfs2/inode.c     (Eric W. Biederman   2013-01-31 21:56:13 -0800 1946) 	    !gid_eq(ogid, NO_GID_QUOTA_CHANGE)) {
39a725803beef fs/gfs2/inode.c     (Abhi Das            2015-06-02 11:02:24 -0500 1947) 		gfs2_quota_change(ip, -(s64)ap.target, ouid, ogid);
b8fbf471edb3d fs/gfs2/inode.c     (Abhi Das            2015-03-18 12:03:41 -0500 1948) 		gfs2_quota_change(ip, ap.target, nuid, ngid);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1949) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1950) 
a91ea69ffd3f8 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-09-04 12:04:26 -0400 1951) out_end_trans:
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1952) 	gfs2_trans_end(sdp);
a91ea69ffd3f8 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-09-04 12:04:26 -0400 1953) out_gunlock_q:
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1954) 	gfs2_quota_unlock(ip);
62e96cf819881 fs/gfs2/inode.c     (Bob Peterson        2014-01-06 17:16:01 -0500 1955) out:
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 1956) 	gfs2_qa_put(ip);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1957) 	return error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1958) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1959) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1960) /**
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1961)  * gfs2_setattr - Change attributes on an inode
c551f66c5dfef fs/gfs2/inode.c     (Lee Jones           2021-03-30 17:44:29 +0100 1962)  * @mnt_userns: User namespace of the mount the inode was found from
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1963)  * @dentry: The dentry which is changing
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1964)  * @attr: The structure describing the change
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1965)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1966)  * The VFS layer wants to change one or more of an inodes attributes.  Write
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1967)  * that change out to disk.
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1968)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1969)  * Returns: errno
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1970)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1971) 
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1972) static int gfs2_setattr(struct user_namespace *mnt_userns,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 1973) 			struct dentry *dentry, struct iattr *attr)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1974) {
2b0143b5c986b fs/gfs2/inode.c     (David Howells       2015-03-17 22:25:59 +0000 1975) 	struct inode *inode = d_inode(dentry);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 1976) 	struct gfs2_inode *ip = GFS2_I(inode);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1977) 	struct gfs2_holder i_gh;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1978) 	int error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1979) 
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 1980) 	error = gfs2_qa_get(ip);
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100 1981) 	if (error)
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100 1982) 		return error;
0a305e496059a fs/gfs2/inode.c     (Bob Peterson        2012-06-06 11:17:59 +0100 1983) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1984) 	error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1985) 	if (error)
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 1986) 		goto out;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1987) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1988) 	error = -EPERM;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1989) 	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 1990) 		goto error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1991) 
2f221d6f7b881 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:26 +0100 1992) 	error = setattr_prepare(&init_user_ns, dentry, attr);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1993) 	if (error)
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 1994) 		goto error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1995) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1996) 	if (attr->ia_valid & ATTR_SIZE)
ff8f33c8b30d7 fs/gfs2/ops_inode.c (Steven Whitehouse   2010-08-11 09:37:53 +0100 1997) 		error = gfs2_setattr_size(inode, attr->ia_size);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1998) 	else if (attr->ia_valid & (ATTR_UID | ATTR_GID))
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 1999) 		error = setattr_chown(inode, attr);
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800 2000) 	else {
ab9bbda0204df fs/gfs2/inode.c     (Steven Whitehouse   2011-08-15 14:20:36 +0100 2001) 		error = gfs2_setattr_simple(inode, attr);
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800 2002) 		if (!error && attr->ia_valid & ATTR_MODE)
e65ce2a50cf6a fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:27 +0100 2003) 			error = posix_acl_chmod(&init_user_ns, inode,
e65ce2a50cf6a fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:27 +0100 2004) 						inode->i_mode);
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800 2005) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2006) 
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 2007) error:
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2008) 	if (!error)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2009) 		mark_inode_dirty(inode);
ab9bbda0204df fs/gfs2/inode.c     (Steven Whitehouse   2011-08-15 14:20:36 +0100 2010) 	gfs2_glock_dq_uninit(&i_gh);
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 2011) out:
2fba46a04c383 fs/gfs2/inode.c     (Bob Peterson        2020-02-27 12:47:53 -0600 2012) 	gfs2_qa_put(ip);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2013) 	return error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2014) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2015) 
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2016) /**
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2017)  * gfs2_getattr - Read out an inode's attributes
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 2018)  * @mnt_userns:	user namespace of the mount the inode was found from
a528d35e8bfcc fs/gfs2/inode.c     (David Howells       2017-01-31 16:46:22 +0000 2019)  * @path: Object to query
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2020)  * @stat: The inode's stats
a528d35e8bfcc fs/gfs2/inode.c     (David Howells       2017-01-31 16:46:22 +0000 2021)  * @request_mask: Mask of STATX_xxx flags indicating the caller's interests
a528d35e8bfcc fs/gfs2/inode.c     (David Howells       2017-01-31 16:46:22 +0000 2022)  * @flags: AT_STATX_xxx setting
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2023)  *
dcf3dd852f554 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 10:12:05 -0500 2024)  * This may be called from the VFS directly, or from within GFS2 with the
dcf3dd852f554 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 10:12:05 -0500 2025)  * inode locked, so we look to see if the glock is already locked and only
dcf3dd852f554 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 10:12:05 -0500 2026)  * lock the glock if its not already been done. Note that its the NFS
dcf3dd852f554 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 10:12:05 -0500 2027)  * readdirplus operation which causes this to be called (from filldir)
dcf3dd852f554 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 10:12:05 -0500 2028)  * with the glock already held.
dcf3dd852f554 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 10:12:05 -0500 2029)  *
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2030)  * Returns: errno
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2031)  */
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2032) 
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 2033) static int gfs2_getattr(struct user_namespace *mnt_userns,
549c7297717c3 fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:43 +0100 2034) 			const struct path *path, struct kstat *stat,
a528d35e8bfcc fs/gfs2/inode.c     (David Howells       2017-01-31 16:46:22 +0000 2035) 			u32 request_mask, unsigned int flags)
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2036) {
a528d35e8bfcc fs/gfs2/inode.c     (David Howells       2017-01-31 16:46:22 +0000 2037) 	struct inode *inode = d_inode(path->dentry);
feaa7bba026c1 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-06-14 15:32:57 -0400 2038) 	struct gfs2_inode *ip = GFS2_I(inode);
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2039) 	struct gfs2_holder gh;
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2040) 	u32 gfsflags;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2041) 	int error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2042) 
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500 2043) 	gfs2_holder_mark_uninitialized(&gh);
7afd88d9166a7 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-02-22 16:07:18 +0000 2044) 	if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) {
2e60d7683c8d2 fs/gfs2/inode.c     (Benjamin Marzinski  2014-11-13 20:42:04 -0600 2045) 		error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
2e60d7683c8d2 fs/gfs2/inode.c     (Benjamin Marzinski  2014-11-13 20:42:04 -0600 2046) 		if (error)
2e60d7683c8d2 fs/gfs2/inode.c     (Benjamin Marzinski  2014-11-13 20:42:04 -0600 2047) 			return error;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2048) 	}
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2049) 
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2050) 	gfsflags = ip->i_diskflags;
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2051) 	if (gfsflags & GFS2_DIF_APPENDONLY)
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2052) 		stat->attributes |= STATX_ATTR_APPEND;
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2053) 	if (gfsflags & GFS2_DIF_IMMUTABLE)
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2054) 		stat->attributes |= STATX_ATTR_IMMUTABLE;
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2055) 
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2056) 	stat->attributes_mask |= (STATX_ATTR_APPEND |
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2057) 				  STATX_ATTR_COMPRESSED |
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2058) 				  STATX_ATTR_ENCRYPTED |
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2059) 				  STATX_ATTR_IMMUTABLE |
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2060) 				  STATX_ATTR_NODUMP);
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2061) 
0d56a4518d5ea fs/gfs2/inode.c     (Christian Brauner   2021-01-21 14:19:30 +0100 2062) 	generic_fillattr(&init_user_ns, inode, stat);
b2623c2fe6eb1 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-10-09 17:55:58 +0200 2063) 
6df9f9a253c7d fs/gfs2/inode.c     (Andreas Gruenbacher 2016-06-17 07:31:27 -0500 2064) 	if (gfs2_holder_initialized(&gh))
dcf3dd852f554 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 10:12:05 -0500 2065) 		gfs2_glock_dq_uninit(&gh);
dcf3dd852f554 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 10:12:05 -0500 2066) 
dcf3dd852f554 fs/gfs2/ops_inode.c (Steven Whitehouse   2006-11-27 10:12:05 -0500 2067) 	return 0;
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2068) }
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2069) 
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2070) static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2071) 		       u64 start, u64 len)
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2072) {
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2073) 	struct gfs2_inode *ip = GFS2_I(inode);
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2074) 	struct gfs2_holder gh;
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2075) 	int ret;
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2076) 
aac1a55b450c6 fs/gfs2/inode.c     (Bob Peterson        2017-02-16 21:13:54 +0100 2077) 	inode_lock_shared(inode);
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2078) 
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2079) 	ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2080) 	if (ret)
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2081) 		goto out;
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2082) 
aac1a55b450c6 fs/gfs2/inode.c     (Bob Peterson        2017-02-16 21:13:54 +0100 2083) 	ret = iomap_fiemap(inode, fieinfo, start, len, &gfs2_iomap_ops);
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2084) 
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2085) 	gfs2_glock_dq_uninit(&gh);
aac1a55b450c6 fs/gfs2/inode.c     (Bob Peterson        2017-02-16 21:13:54 +0100 2086) 
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2087) out:
aac1a55b450c6 fs/gfs2/inode.c     (Bob Peterson        2017-02-16 21:13:54 +0100 2088) 	inode_unlock_shared(inode);
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2089) 	return ret;
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2090) }
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2091) 
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2092) loff_t gfs2_seek_data(struct file *file, loff_t offset)
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2093) {
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2094) 	struct inode *inode = file->f_mapping->host;
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2095) 	struct gfs2_inode *ip = GFS2_I(inode);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2096) 	struct gfs2_holder gh;
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2097) 	loff_t ret;
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2098) 
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2099) 	inode_lock_shared(inode);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2100) 	ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2101) 	if (!ret)
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2102) 		ret = iomap_seek_data(inode, offset, &gfs2_iomap_ops);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2103) 	gfs2_glock_dq_uninit(&gh);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2104) 	inode_unlock_shared(inode);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2105) 
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2106) 	if (ret < 0)
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2107) 		return ret;
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2108) 	return vfs_setpos(file, ret, inode->i_sb->s_maxbytes);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2109) }
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2110) 
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2111) loff_t gfs2_seek_hole(struct file *file, loff_t offset)
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2112) {
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2113) 	struct inode *inode = file->f_mapping->host;
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2114) 	struct gfs2_inode *ip = GFS2_I(inode);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2115) 	struct gfs2_holder gh;
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2116) 	loff_t ret;
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2117) 
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2118) 	inode_lock_shared(inode);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2119) 	ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2120) 	if (!ret)
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2121) 		ret = iomap_seek_hole(inode, offset, &gfs2_iomap_ops);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2122) 	gfs2_glock_dq_uninit(&gh);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2123) 	inode_unlock_shared(inode);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2124) 
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2125) 	if (ret < 0)
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2126) 		return ret;
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2127) 	return vfs_setpos(file, ret, inode->i_sb->s_maxbytes);
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2128) }
3a27411cb4bc3 fs/gfs2/inode.c     (Andreas Gruenbacher 2017-03-15 19:12:59 +0100 2129) 
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2130) static int gfs2_update_time(struct inode *inode, struct timespec64 *time,
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2131) 			    int flags)
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2132) {
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2133) 	struct gfs2_inode *ip = GFS2_I(inode);
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2134) 	struct gfs2_glock *gl = ip->i_gl;
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2135) 	struct gfs2_holder *gh;
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2136) 	int error;
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2137) 
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2138) 	gh = gfs2_glock_is_locked_by_me(gl);
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2139) 	if (gh && !gfs2_glock_is_held_excl(gl)) {
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2140) 		gfs2_glock_dq(gh);
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2141) 		gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, gh);
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2142) 		error = gfs2_glock_nq(gh);
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2143) 		if (error)
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2144) 			return error;
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2145) 	}
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2146) 	return generic_update_time(inode, time, flags);
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2147) }
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2148) 
e3a77eebfa256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 21:14:15 +0100 2149) static const struct inode_operations gfs2_file_iops = {
e6305c43eda10 fs/gfs2/ops_inode.c (Al Viro             2008-07-15 21:03:57 -0400 2150) 	.permission = gfs2_permission,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2151) 	.setattr = gfs2_setattr,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2152) 	.getattr = gfs2_getattr,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2153) 	.listxattr = gfs2_listxattr,
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2154) 	.fiemap = gfs2_fiemap,
4e34e719e457f fs/gfs2/inode.c     (Christoph Hellwig   2011-07-23 17:37:31 +0200 2155) 	.get_acl = gfs2_get_acl,
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800 2156) 	.set_acl = gfs2_set_acl,
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2157) 	.update_time = gfs2_update_time,
88b631cbfbeb4 fs/gfs2/inode.c     (Miklos Szeredi      2021-04-07 14:36:43 +0200 2158) 	.fileattr_get = gfs2_fileattr_get,
88b631cbfbeb4 fs/gfs2/inode.c     (Miklos Szeredi      2021-04-07 14:36:43 +0200 2159) 	.fileattr_set = gfs2_fileattr_set,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2160) };
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2161) 
e3a77eebfa256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 21:14:15 +0100 2162) static const struct inode_operations gfs2_dir_iops = {
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2163) 	.create = gfs2_create,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2164) 	.lookup = gfs2_lookup,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2165) 	.link = gfs2_link,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2166) 	.unlink = gfs2_unlink,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2167) 	.symlink = gfs2_symlink,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2168) 	.mkdir = gfs2_mkdir,
855d23ce2665c fs/gfs2/ops_inode.c (Steven Whitehouse   2011-05-09 16:42:37 +0100 2169) 	.rmdir = gfs2_unlink,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2170) 	.mknod = gfs2_mknod,
2773bf00aeb9b fs/gfs2/inode.c     (Miklos Szeredi      2016-09-27 11:03:58 +0200 2171) 	.rename = gfs2_rename2,
e6305c43eda10 fs/gfs2/ops_inode.c (Al Viro             2008-07-15 21:03:57 -0400 2172) 	.permission = gfs2_permission,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2173) 	.setattr = gfs2_setattr,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2174) 	.getattr = gfs2_getattr,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2175) 	.listxattr = gfs2_listxattr,
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2176) 	.fiemap = gfs2_fiemap,
4e34e719e457f fs/gfs2/inode.c     (Christoph Hellwig   2011-07-23 17:37:31 +0200 2177) 	.get_acl = gfs2_get_acl,
e01580bf9e4d0 fs/gfs2/inode.c     (Christoph Hellwig   2013-12-20 05:16:52 -0800 2178) 	.set_acl = gfs2_set_acl,
82e938bd5382b fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 23:37:18 +0100 2179) 	.update_time = gfs2_update_time,
6d4ade986f9c8 fs/gfs2/inode.c     (Steven Whitehouse   2013-06-14 11:17:15 +0100 2180) 	.atomic_open = gfs2_atomic_open,
88b631cbfbeb4 fs/gfs2/inode.c     (Miklos Szeredi      2021-04-07 14:36:43 +0200 2181) 	.fileattr_get = gfs2_fileattr_get,
88b631cbfbeb4 fs/gfs2/inode.c     (Miklos Szeredi      2021-04-07 14:36:43 +0200 2182) 	.fileattr_set = gfs2_fileattr_set,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2183) };
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2184) 
e3a77eebfa256 fs/gfs2/inode.c     (Andreas Gruenbacher 2020-11-25 21:14:15 +0100 2185) static const struct inode_operations gfs2_symlink_iops = {
6b2553918d8b4 fs/gfs2/inode.c     (Al Viro             2015-11-17 10:20:54 -0500 2186) 	.get_link = gfs2_get_link,
e6305c43eda10 fs/gfs2/ops_inode.c (Al Viro             2008-07-15 21:03:57 -0400 2187) 	.permission = gfs2_permission,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2188) 	.setattr = gfs2_setattr,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2189) 	.getattr = gfs2_getattr,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2190) 	.listxattr = gfs2_listxattr,
e9079cce20178 fs/gfs2/ops_inode.c (Steven Whitehouse   2008-10-14 14:43:29 +0100 2191) 	.fiemap = gfs2_fiemap,
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2192) };
b3b94faa5fe59 fs/gfs2/ops_inode.c (David Teigland      2006-01-16 16:50:04 +0000 2193)