Browse Source

Merge tag 'xfs-4.15-fixes-5' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull xfs fixes from Darrick Wong:
 "Here are a few more bug fixes & cleanups for 4.15-rc4:

   - clean up duplicate includes

   - remove ancient 'no-alloc' crap code that occasionally caused hard
     fs shutdowns due to lack of proper space reservations

   - fix regression in FIEMAP behavior when reporting xattr extents"

* tag 'xfs-4.15-fixes-5' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  xfs: make iomap_begin functions trim iomaps consistently
  xfs: remove "no-allocation" reservations for file creations
  fs: xfs: remove duplicate includes
Linus Torvalds 7 years ago
parent
commit
7c5cac1bc7

+ 3 - 7
fs/xfs/libxfs/xfs_ialloc.c

@@ -920,8 +920,7 @@ STATIC xfs_agnumber_t
 xfs_ialloc_ag_select(
 xfs_ialloc_ag_select(
 	xfs_trans_t	*tp,		/* transaction pointer */
 	xfs_trans_t	*tp,		/* transaction pointer */
 	xfs_ino_t	parent,		/* parent directory inode number */
 	xfs_ino_t	parent,		/* parent directory inode number */
-	umode_t		mode,		/* bits set to indicate file type */
-	int		okalloc)	/* ok to allocate more space */
+	umode_t		mode)		/* bits set to indicate file type */
 {
 {
 	xfs_agnumber_t	agcount;	/* number of ag's in the filesystem */
 	xfs_agnumber_t	agcount;	/* number of ag's in the filesystem */
 	xfs_agnumber_t	agno;		/* current ag number */
 	xfs_agnumber_t	agno;		/* current ag number */
@@ -978,9 +977,6 @@ xfs_ialloc_ag_select(
 			return agno;
 			return agno;
 		}
 		}
 
 
-		if (!okalloc)
-			goto nextag;
-
 		if (!pag->pagf_init) {
 		if (!pag->pagf_init) {
 			error = xfs_alloc_pagf_init(mp, tp, agno, flags);
 			error = xfs_alloc_pagf_init(mp, tp, agno, flags);
 			if (error)
 			if (error)
@@ -1680,7 +1676,6 @@ xfs_dialloc(
 	struct xfs_trans	*tp,
 	struct xfs_trans	*tp,
 	xfs_ino_t		parent,
 	xfs_ino_t		parent,
 	umode_t			mode,
 	umode_t			mode,
-	int			okalloc,
 	struct xfs_buf		**IO_agbp,
 	struct xfs_buf		**IO_agbp,
 	xfs_ino_t		*inop)
 	xfs_ino_t		*inop)
 {
 {
@@ -1692,6 +1687,7 @@ xfs_dialloc(
 	int			noroom = 0;
 	int			noroom = 0;
 	xfs_agnumber_t		start_agno;
 	xfs_agnumber_t		start_agno;
 	struct xfs_perag	*pag;
 	struct xfs_perag	*pag;
+	int			okalloc = 1;
 
 
 	if (*IO_agbp) {
 	if (*IO_agbp) {
 		/*
 		/*
@@ -1707,7 +1703,7 @@ xfs_dialloc(
 	 * We do not have an agbp, so select an initial allocation
 	 * We do not have an agbp, so select an initial allocation
 	 * group for inode allocation.
 	 * group for inode allocation.
 	 */
 	 */
-	start_agno = xfs_ialloc_ag_select(tp, parent, mode, okalloc);
+	start_agno = xfs_ialloc_ag_select(tp, parent, mode);
 	if (start_agno == NULLAGNUMBER) {
 	if (start_agno == NULLAGNUMBER) {
 		*inop = NULLFSINO;
 		*inop = NULLFSINO;
 		return 0;
 		return 0;

+ 0 - 1
fs/xfs/libxfs/xfs_ialloc.h

@@ -81,7 +81,6 @@ xfs_dialloc(
 	struct xfs_trans *tp,		/* transaction pointer */
 	struct xfs_trans *tp,		/* transaction pointer */
 	xfs_ino_t	parent,		/* parent inode (directory) */
 	xfs_ino_t	parent,		/* parent inode (directory) */
 	umode_t		mode,		/* mode bits for new inode */
 	umode_t		mode,		/* mode bits for new inode */
-	int		okalloc,	/* ok to allocate more space */
 	struct xfs_buf	**agbp,		/* buf for a.g. inode header */
 	struct xfs_buf	**agbp,		/* buf for a.g. inode header */
 	xfs_ino_t	*inop);		/* inode number allocated */
 	xfs_ino_t	*inop);		/* inode number allocated */
 
 

+ 0 - 1
fs/xfs/scrub/scrub.c

@@ -46,7 +46,6 @@
 #include "scrub/scrub.h"
 #include "scrub/scrub.h"
 #include "scrub/common.h"
 #include "scrub/common.h"
 #include "scrub/trace.h"
 #include "scrub/trace.h"
-#include "scrub/scrub.h"
 #include "scrub/btree.h"
 #include "scrub/btree.h"
 
 
 /*
 /*

+ 0 - 1
fs/xfs/scrub/trace.c

@@ -26,7 +26,6 @@
 #include "xfs_mount.h"
 #include "xfs_mount.h"
 #include "xfs_defer.h"
 #include "xfs_defer.h"
 #include "xfs_da_format.h"
 #include "xfs_da_format.h"
-#include "xfs_defer.h"
 #include "xfs_inode.h"
 #include "xfs_inode.h"
 #include "xfs_btree.h"
 #include "xfs_btree.h"
 #include "xfs_trans.h"
 #include "xfs_trans.h"

+ 7 - 26
fs/xfs/xfs_inode.c

@@ -749,7 +749,6 @@ xfs_ialloc(
 	xfs_nlink_t	nlink,
 	xfs_nlink_t	nlink,
 	dev_t		rdev,
 	dev_t		rdev,
 	prid_t		prid,
 	prid_t		prid,
-	int		okalloc,
 	xfs_buf_t	**ialloc_context,
 	xfs_buf_t	**ialloc_context,
 	xfs_inode_t	**ipp)
 	xfs_inode_t	**ipp)
 {
 {
@@ -765,7 +764,7 @@ xfs_ialloc(
 	 * Call the space management code to pick
 	 * Call the space management code to pick
 	 * the on-disk inode to be allocated.
 	 * the on-disk inode to be allocated.
 	 */
 	 */
-	error = xfs_dialloc(tp, pip ? pip->i_ino : 0, mode, okalloc,
+	error = xfs_dialloc(tp, pip ? pip->i_ino : 0, mode,
 			    ialloc_context, &ino);
 			    ialloc_context, &ino);
 	if (error)
 	if (error)
 		return error;
 		return error;
@@ -957,7 +956,6 @@ xfs_dir_ialloc(
 	xfs_nlink_t	nlink,
 	xfs_nlink_t	nlink,
 	dev_t		rdev,
 	dev_t		rdev,
 	prid_t		prid,		/* project id */
 	prid_t		prid,		/* project id */
-	int		okalloc,	/* ok to allocate new space */
 	xfs_inode_t	**ipp,		/* pointer to inode; it will be
 	xfs_inode_t	**ipp,		/* pointer to inode; it will be
 					   locked. */
 					   locked. */
 	int		*committed)
 	int		*committed)
@@ -988,8 +986,8 @@ xfs_dir_ialloc(
 	 * transaction commit so that no other process can steal
 	 * transaction commit so that no other process can steal
 	 * the inode(s) that we've just allocated.
 	 * the inode(s) that we've just allocated.
 	 */
 	 */
-	code = xfs_ialloc(tp, dp, mode, nlink, rdev, prid, okalloc,
-			  &ialloc_context, &ip);
+	code = xfs_ialloc(tp, dp, mode, nlink, rdev, prid, &ialloc_context,
+			&ip);
 
 
 	/*
 	/*
 	 * Return an error if we were unable to allocate a new inode.
 	 * Return an error if we were unable to allocate a new inode.
@@ -1061,7 +1059,7 @@ xfs_dir_ialloc(
 		 * this call should always succeed.
 		 * this call should always succeed.
 		 */
 		 */
 		code = xfs_ialloc(tp, dp, mode, nlink, rdev, prid,
 		code = xfs_ialloc(tp, dp, mode, nlink, rdev, prid,
-				  okalloc, &ialloc_context, &ip);
+				  &ialloc_context, &ip);
 
 
 		/*
 		/*
 		 * If we get an error at this point, return to the caller
 		 * If we get an error at this point, return to the caller
@@ -1182,11 +1180,6 @@ xfs_create(
 		xfs_flush_inodes(mp);
 		xfs_flush_inodes(mp);
 		error = xfs_trans_alloc(mp, tres, resblks, 0, 0, &tp);
 		error = xfs_trans_alloc(mp, tres, resblks, 0, 0, &tp);
 	}
 	}
-	if (error == -ENOSPC) {
-		/* No space at all so try a "no-allocation" reservation */
-		resblks = 0;
-		error = xfs_trans_alloc(mp, tres, 0, 0, 0, &tp);
-	}
 	if (error)
 	if (error)
 		goto out_release_inode;
 		goto out_release_inode;
 
 
@@ -1203,19 +1196,13 @@ xfs_create(
 	if (error)
 	if (error)
 		goto out_trans_cancel;
 		goto out_trans_cancel;
 
 
-	if (!resblks) {
-		error = xfs_dir_canenter(tp, dp, name);
-		if (error)
-			goto out_trans_cancel;
-	}
-
 	/*
 	/*
 	 * A newly created regular or special file just has one directory
 	 * A newly created regular or special file just has one directory
 	 * entry pointing to them, but a directory also the "." entry
 	 * entry pointing to them, but a directory also the "." entry
 	 * pointing to itself.
 	 * pointing to itself.
 	 */
 	 */
-	error = xfs_dir_ialloc(&tp, dp, mode, is_dir ? 2 : 1, rdev,
-			       prid, resblks > 0, &ip, NULL);
+	error = xfs_dir_ialloc(&tp, dp, mode, is_dir ? 2 : 1, rdev, prid, &ip,
+			NULL);
 	if (error)
 	if (error)
 		goto out_trans_cancel;
 		goto out_trans_cancel;
 
 
@@ -1340,11 +1327,6 @@ xfs_create_tmpfile(
 	tres = &M_RES(mp)->tr_create_tmpfile;
 	tres = &M_RES(mp)->tr_create_tmpfile;
 
 
 	error = xfs_trans_alloc(mp, tres, resblks, 0, 0, &tp);
 	error = xfs_trans_alloc(mp, tres, resblks, 0, 0, &tp);
-	if (error == -ENOSPC) {
-		/* No space at all so try a "no-allocation" reservation */
-		resblks = 0;
-		error = xfs_trans_alloc(mp, tres, 0, 0, 0, &tp);
-	}
 	if (error)
 	if (error)
 		goto out_release_inode;
 		goto out_release_inode;
 
 
@@ -1353,8 +1335,7 @@ xfs_create_tmpfile(
 	if (error)
 	if (error)
 		goto out_trans_cancel;
 		goto out_trans_cancel;
 
 
-	error = xfs_dir_ialloc(&tp, dp, mode, 1, 0,
-				prid, resblks > 0, &ip, NULL);
+	error = xfs_dir_ialloc(&tp, dp, mode, 1, 0, prid, &ip, NULL);
 	if (error)
 	if (error)
 		goto out_trans_cancel;
 		goto out_trans_cancel;
 
 

+ 1 - 1
fs/xfs/xfs_inode.h

@@ -428,7 +428,7 @@ xfs_extlen_t	xfs_get_extsz_hint(struct xfs_inode *ip);
 xfs_extlen_t	xfs_get_cowextsz_hint(struct xfs_inode *ip);
 xfs_extlen_t	xfs_get_cowextsz_hint(struct xfs_inode *ip);
 
 
 int		xfs_dir_ialloc(struct xfs_trans **, struct xfs_inode *, umode_t,
 int		xfs_dir_ialloc(struct xfs_trans **, struct xfs_inode *, umode_t,
-			       xfs_nlink_t, dev_t, prid_t, int,
+			       xfs_nlink_t, dev_t, prid_t,
 			       struct xfs_inode **, int *);
 			       struct xfs_inode **, int *);
 
 
 /* from xfs_file.c */
 /* from xfs_file.c */

+ 1 - 1
fs/xfs/xfs_iomap.c

@@ -1213,7 +1213,7 @@ xfs_xattr_iomap_begin(
 
 
 	ASSERT(ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL);
 	ASSERT(ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL);
 	error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, &imap,
 	error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, &imap,
-			       &nimaps, XFS_BMAPI_ENTIRE | XFS_BMAPI_ATTRFORK);
+			       &nimaps, XFS_BMAPI_ATTRFORK);
 out_unlock:
 out_unlock:
 	xfs_iunlock(ip, lockmode);
 	xfs_iunlock(ip, lockmode);
 
 

+ 2 - 2
fs/xfs/xfs_qm.c

@@ -793,8 +793,8 @@ xfs_qm_qino_alloc(
 		return error;
 		return error;
 
 
 	if (need_alloc) {
 	if (need_alloc) {
-		error = xfs_dir_ialloc(&tp, NULL, S_IFREG, 1, 0, 0, 1, ip,
-								&committed);
+		error = xfs_dir_ialloc(&tp, NULL, S_IFREG, 1, 0, 0, ip,
+				&committed);
 		if (error) {
 		if (error) {
 			xfs_trans_cancel(tp);
 			xfs_trans_cancel(tp);
 			return error;
 			return error;

+ 0 - 2
fs/xfs/xfs_reflink.c

@@ -49,8 +49,6 @@
 #include "xfs_alloc.h"
 #include "xfs_alloc.h"
 #include "xfs_quota_defs.h"
 #include "xfs_quota_defs.h"
 #include "xfs_quota.h"
 #include "xfs_quota.h"
-#include "xfs_btree.h"
-#include "xfs_bmap_btree.h"
 #include "xfs_reflink.h"
 #include "xfs_reflink.h"
 #include "xfs_iomap.h"
 #include "xfs_iomap.h"
 #include "xfs_rmap_btree.h"
 #include "xfs_rmap_btree.h"

+ 1 - 14
fs/xfs/xfs_symlink.c

@@ -232,11 +232,6 @@ xfs_symlink(
 	resblks = XFS_SYMLINK_SPACE_RES(mp, link_name->len, fs_blocks);
 	resblks = XFS_SYMLINK_SPACE_RES(mp, link_name->len, fs_blocks);
 
 
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_symlink, resblks, 0, 0, &tp);
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_symlink, resblks, 0, 0, &tp);
-	if (error == -ENOSPC && fs_blocks == 0) {
-		resblks = 0;
-		error = xfs_trans_alloc(mp, &M_RES(mp)->tr_symlink, 0, 0, 0,
-				&tp);
-	}
 	if (error)
 	if (error)
 		goto out_release_inode;
 		goto out_release_inode;
 
 
@@ -259,14 +254,6 @@ xfs_symlink(
 	if (error)
 	if (error)
 		goto out_trans_cancel;
 		goto out_trans_cancel;
 
 
-	/*
-	 * Check for ability to enter directory entry, if no space reserved.
-	 */
-	if (!resblks) {
-		error = xfs_dir_canenter(tp, dp, link_name);
-		if (error)
-			goto out_trans_cancel;
-	}
 	/*
 	/*
 	 * Initialize the bmap freelist prior to calling either
 	 * Initialize the bmap freelist prior to calling either
 	 * bmapi or the directory create code.
 	 * bmapi or the directory create code.
@@ -277,7 +264,7 @@ xfs_symlink(
 	 * Allocate an inode for the symlink.
 	 * Allocate an inode for the symlink.
 	 */
 	 */
 	error = xfs_dir_ialloc(&tp, dp, S_IFLNK | (mode & ~S_IFMT), 1, 0,
 	error = xfs_dir_ialloc(&tp, dp, S_IFLNK | (mode & ~S_IFMT), 1, 0,
-			       prid, resblks > 0, &ip, NULL);
+			       prid, &ip, NULL);
 	if (error)
 	if (error)
 		goto out_trans_cancel;
 		goto out_trans_cancel;
 
 

+ 0 - 1
fs/xfs/xfs_trace.c

@@ -24,7 +24,6 @@
 #include "xfs_mount.h"
 #include "xfs_mount.h"
 #include "xfs_defer.h"
 #include "xfs_defer.h"
 #include "xfs_da_format.h"
 #include "xfs_da_format.h"
-#include "xfs_defer.h"
 #include "xfs_inode.h"
 #include "xfs_inode.h"
 #include "xfs_btree.h"
 #include "xfs_btree.h"
 #include "xfs_da_btree.h"
 #include "xfs_da_btree.h"