diff options
| author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-12-21 21:59:45 +0100 | 
|---|---|---|
| committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-12-21 21:59:45 +0100 | 
| commit | b00f4dc5ff022cb9cbaffd376d9454d7fa1e496f (patch) | |
| tree | 40f1b232e2f1e8ac365317a14fdcbcb331722b46 /fs/xfs/xfs_attr_leaf.c | |
| parent | 1eac8111e0763853266a171ce11214da3a347a0a (diff) | |
| parent | b9e26dfdad5a4f9cbdaacafac6998614cc9c41bc (diff) | |
| download | olio-linux-3.10-b00f4dc5ff022cb9cbaffd376d9454d7fa1e496f.tar.xz olio-linux-3.10-b00f4dc5ff022cb9cbaffd376d9454d7fa1e496f.zip  | |
Merge branch 'master' into pm-sleep
* master: (848 commits)
  SELinux: Fix RCU deref check warning in sel_netport_insert()
  binary_sysctl(): fix memory leak
  mm/vmalloc.c: remove static declaration of va from __get_vm_area_node
  ipmi_watchdog: restore settings when BMC reset
  oom: fix integer overflow of points in oom_badness
  memcg: keep root group unchanged if creation fails
  nilfs2: potential integer overflow in nilfs_ioctl_clean_segments()
  nilfs2: unbreak compat ioctl
  cpusets: stall when updating mems_allowed for mempolicy or disjoint nodemask
  evm: prevent racing during tfm allocation
  evm: key must be set once during initialization
  mmc: vub300: fix type of firmware_rom_wait_states module parameter
  Revert "mmc: enable runtime PM by default"
  mmc: sdhci: remove "state" argument from sdhci_suspend_host
  x86, dumpstack: Fix code bytes breakage due to missing KERN_CONT
  IB/qib: Correct sense on freectxts increment and decrement
  RDMA/cma: Verify private data length
  cgroups: fix a css_set not found bug in cgroup_attach_proc
  oprofile: Fix uninitialized memory access when writing to writing to oprofilefs
  Revert "xen/pv-on-hvm kexec: add xs_reset_watches to shutdown watches from old kernel"
  ...
Conflicts:
	kernel/cgroup_freezer.c
Diffstat (limited to 'fs/xfs/xfs_attr_leaf.c')
| -rw-r--r-- | fs/xfs/xfs_attr_leaf.c | 64 | 
1 files changed, 39 insertions, 25 deletions
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index d4906e7c978..c1b55e59655 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c @@ -110,6 +110,7 @@ xfs_attr_namesp_match(int arg_flags, int ondisk_flags)  /*   * Query whether the requested number of additional bytes of extended   * attribute space will be able to fit inline. + *   * Returns zero if not, else the di_forkoff fork offset to be used in the   * literal area for attribute data once the new bytes have been added.   * @@ -122,7 +123,7 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)  	int offset;  	int minforkoff;	/* lower limit on valid forkoff locations */  	int maxforkoff;	/* upper limit on valid forkoff locations */ -	int dsize;	 +	int dsize;  	xfs_mount_t *mp = dp->i_mount;  	offset = (XFS_LITINO(mp) - bytes) >> 3; /* rounded down */ @@ -136,47 +137,60 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)  		return (offset >= minforkoff) ? minforkoff : 0;  	} -	if (!(mp->m_flags & XFS_MOUNT_ATTR2)) { -		if (bytes <= XFS_IFORK_ASIZE(dp)) -			return dp->i_d.di_forkoff; +	/* +	 * If the requested numbers of bytes is smaller or equal to the +	 * current attribute fork size we can always proceed. +	 * +	 * Note that if_bytes in the data fork might actually be larger than +	 * the current data fork size is due to delalloc extents. In that +	 * case either the extent count will go down when they are converted +	 * to real extents, or the delalloc conversion will take care of the +	 * literal area rebalancing. +	 */ +	if (bytes <= XFS_IFORK_ASIZE(dp)) +		return dp->i_d.di_forkoff; + +	/* +	 * For attr2 we can try to move the forkoff if there is space in the +	 * literal area, but for the old format we are done if there is no +	 * space in the fixed attribute fork. +	 */ +	if (!(mp->m_flags & XFS_MOUNT_ATTR2))  		return 0; -	}  	dsize = dp->i_df.if_bytes; -	 +  	switch (dp->i_d.di_format) {  	case XFS_DINODE_FMT_EXTENTS: -		/*  +		/*  		 * If there is no attr fork and the data fork is extents,  -		 * determine if creating the default attr fork will result  -		 * in the extents form migrating to btree. If so, the  -		 * minimum offset only needs to be the space required for  +		 * determine if creating the default attr fork will result +		 * in the extents form migrating to btree. If so, the +		 * minimum offset only needs to be the space required for  		 * the btree root. -		 */  +		 */  		if (!dp->i_d.di_forkoff && dp->i_df.if_bytes >  		    xfs_default_attroffset(dp))  			dsize = XFS_BMDR_SPACE_CALC(MINDBTPTRS);  		break; -		  	case XFS_DINODE_FMT_BTREE:  		/* -		 * If have data btree then keep forkoff if we have one, -		 * otherwise we are adding a new attr, so then we set  -		 * minforkoff to where the btree root can finish so we have  +		 * If we have a data btree then keep forkoff if we have one, +		 * otherwise we are adding a new attr, so then we set +		 * minforkoff to where the btree root can finish so we have  		 * plenty of room for attrs  		 */  		if (dp->i_d.di_forkoff) { -			if (offset < dp->i_d.di_forkoff)  +			if (offset < dp->i_d.di_forkoff)  				return 0; -			else  -				return dp->i_d.di_forkoff; -		} else -			dsize = XFS_BMAP_BROOT_SPACE(dp->i_df.if_broot); +			return dp->i_d.di_forkoff; +		} +		dsize = XFS_BMAP_BROOT_SPACE(dp->i_df.if_broot);  		break;  	} -	 -	/*  -	 * A data fork btree root must have space for at least  + +	/* +	 * A data fork btree root must have space for at least  	 * MINDBTPTRS key/ptr pairs if the data fork is small or empty.  	 */  	minforkoff = MAX(dsize, XFS_BMDR_SPACE_CALC(MINDBTPTRS)); @@ -186,10 +200,10 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)  	maxforkoff = XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(MINABTPTRS);  	maxforkoff = maxforkoff >> 3;	/* rounded down */ -	if (offset >= minforkoff && offset < maxforkoff) -		return offset;  	if (offset >= maxforkoff)  		return maxforkoff; +	if (offset >= minforkoff) +		return offset;  	return 0;  }  |