提交 c05e14f7 编写于 作者: L Linus Torvalds

Merge tag 'xfs-for-linus-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs

Pull xfs update from Dave Chinner:
 "There's relatively little change in this update; it is mainly bug
  fixes, cleanups and more of the on-going libxfs restructuring and
  on-disk format header consolidation work.

  Details:
   - more on-disk format header consolidation
   - move some structures shared with userspace to libxfs
   - new per-mount workqueue to fix for deadlocks between nested loop
     mounted filesystems
   - various bug fixes for ENOSPC, stats, quota off and preallocation
   - a bunch of compiler warning fixes for set-but-unused variables
   - various code cleanups"

* tag 'xfs-for-linus-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs: (24 commits)
  xfs: split metadata and log buffer completion to separate workqueues
  xfs: fix set-but-unused warnings
  xfs: move type conversion functions to xfs_dir.h
  xfs: move ftype conversion functions to libxfs
  xfs: lobotomise xfs_trans_read_buf_map()
  xfs: active inodes stat is broken
  xfs: cleanup xfs_bmse_merge returns
  xfs: cleanup xfs_bmse_shift_one goto mess
  xfs: fix premature enospc on inode allocation
  xfs: overflow in xfs_iomap_eof_align_last_fsb
  xfs: fix simple_return.cocci warning in xfs_bmse_shift_one
  xfs: fix simple_return.cocci warning in xfs_file_readdir
  libxfs: fix simple_return.cocci warnings
  xfs: remove unnecessary null checks
  xfs: merge xfs_inum.h into xfs_format.h
  xfs: move most of xfs_sb.h to xfs_format.h
  xfs: merge xfs_ag.h into xfs_format.h
  xfs: move acl structures to xfs_format.h
  xfs: merge xfs_dinode.h into xfs_format.h
  xfs: catch invalid negative blknos in _xfs_buf_find()
  ...
/*
* Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __XFS_AG_H__
#define __XFS_AG_H__
/*
* Allocation group header
* This is divided into three structures, placed in sequential 512-byte
* buffers after a copy of the superblock (also in a 512-byte buffer).
*/
struct xfs_buf;
struct xfs_mount;
struct xfs_trans;
#define XFS_AGF_MAGIC 0x58414746 /* 'XAGF' */
#define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */
#define XFS_AGFL_MAGIC 0x5841464c /* 'XAFL' */
#define XFS_AGF_VERSION 1
#define XFS_AGI_VERSION 1
#define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION)
#define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION)
/*
* Btree number 0 is bno, 1 is cnt. This value gives the size of the
* arrays below.
*/
#define XFS_BTNUM_AGF ((int)XFS_BTNUM_CNTi + 1)
/*
* The second word of agf_levels in the first a.g. overlaps the EFS
* superblock's magic number. Since the magic numbers valid for EFS
* are > 64k, our value cannot be confused for an EFS superblock's.
*/
typedef struct xfs_agf {
/*
* Common allocation group header information
*/
__be32 agf_magicnum; /* magic number == XFS_AGF_MAGIC */
__be32 agf_versionnum; /* header version == XFS_AGF_VERSION */
__be32 agf_seqno; /* sequence # starting from 0 */
__be32 agf_length; /* size in blocks of a.g. */
/*
* Freespace information
*/
__be32 agf_roots[XFS_BTNUM_AGF]; /* root blocks */
__be32 agf_spare0; /* spare field */
__be32 agf_levels[XFS_BTNUM_AGF]; /* btree levels */
__be32 agf_spare1; /* spare field */
__be32 agf_flfirst; /* first freelist block's index */
__be32 agf_fllast; /* last freelist block's index */
__be32 agf_flcount; /* count of blocks in freelist */
__be32 agf_freeblks; /* total free blocks */
__be32 agf_longest; /* longest free space */
__be32 agf_btreeblks; /* # of blocks held in AGF btrees */
uuid_t agf_uuid; /* uuid of filesystem */
/*
* reserve some contiguous space for future logged fields before we add
* the unlogged fields. This makes the range logging via flags and
* structure offsets much simpler.
*/
__be64 agf_spare64[16];
/* unlogged fields, written during buffer writeback. */
__be64 agf_lsn; /* last write sequence */
__be32 agf_crc; /* crc of agf sector */
__be32 agf_spare2;
/* structure must be padded to 64 bit alignment */
} xfs_agf_t;
#define XFS_AGF_CRC_OFF offsetof(struct xfs_agf, agf_crc)
#define XFS_AGF_MAGICNUM 0x00000001
#define XFS_AGF_VERSIONNUM 0x00000002
#define XFS_AGF_SEQNO 0x00000004
#define XFS_AGF_LENGTH 0x00000008
#define XFS_AGF_ROOTS 0x00000010
#define XFS_AGF_LEVELS 0x00000020
#define XFS_AGF_FLFIRST 0x00000040
#define XFS_AGF_FLLAST 0x00000080
#define XFS_AGF_FLCOUNT 0x00000100
#define XFS_AGF_FREEBLKS 0x00000200
#define XFS_AGF_LONGEST 0x00000400
#define XFS_AGF_BTREEBLKS 0x00000800
#define XFS_AGF_UUID 0x00001000
#define XFS_AGF_NUM_BITS 13
#define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1)
#define XFS_AGF_FLAGS \
{ XFS_AGF_MAGICNUM, "MAGICNUM" }, \
{ XFS_AGF_VERSIONNUM, "VERSIONNUM" }, \
{ XFS_AGF_SEQNO, "SEQNO" }, \
{ XFS_AGF_LENGTH, "LENGTH" }, \
{ XFS_AGF_ROOTS, "ROOTS" }, \
{ XFS_AGF_LEVELS, "LEVELS" }, \
{ XFS_AGF_FLFIRST, "FLFIRST" }, \
{ XFS_AGF_FLLAST, "FLLAST" }, \
{ XFS_AGF_FLCOUNT, "FLCOUNT" }, \
{ XFS_AGF_FREEBLKS, "FREEBLKS" }, \
{ XFS_AGF_LONGEST, "LONGEST" }, \
{ XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \
{ XFS_AGF_UUID, "UUID" }
/* disk block (xfs_daddr_t) in the AG */
#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))
#define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp))
#define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)((bp)->b_addr))
extern int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp,
xfs_agnumber_t agno, int flags, struct xfs_buf **bpp);
/*
* Size of the unlinked inode hash table in the agi.
*/
#define XFS_AGI_UNLINKED_BUCKETS 64
typedef struct xfs_agi {
/*
* Common allocation group header information
*/
__be32 agi_magicnum; /* magic number == XFS_AGI_MAGIC */
__be32 agi_versionnum; /* header version == XFS_AGI_VERSION */
__be32 agi_seqno; /* sequence # starting from 0 */
__be32 agi_length; /* size in blocks of a.g. */
/*
* Inode information
* Inodes are mapped by interpreting the inode number, so no
* mapping data is needed here.
*/
__be32 agi_count; /* count of allocated inodes */
__be32 agi_root; /* root of inode btree */
__be32 agi_level; /* levels in inode btree */
__be32 agi_freecount; /* number of free inodes */
__be32 agi_newino; /* new inode just allocated */
__be32 agi_dirino; /* last directory inode chunk */
/*
* Hash table of inodes which have been unlinked but are
* still being referenced.
*/
__be32 agi_unlinked[XFS_AGI_UNLINKED_BUCKETS];
/*
* This marks the end of logging region 1 and start of logging region 2.
*/
uuid_t agi_uuid; /* uuid of filesystem */
__be32 agi_crc; /* crc of agi sector */
__be32 agi_pad32;
__be64 agi_lsn; /* last write sequence */
__be32 agi_free_root; /* root of the free inode btree */
__be32 agi_free_level;/* levels in free inode btree */
/* structure must be padded to 64 bit alignment */
} xfs_agi_t;
#define XFS_AGI_CRC_OFF offsetof(struct xfs_agi, agi_crc)
#define XFS_AGI_MAGICNUM (1 << 0)
#define XFS_AGI_VERSIONNUM (1 << 1)
#define XFS_AGI_SEQNO (1 << 2)
#define XFS_AGI_LENGTH (1 << 3)
#define XFS_AGI_COUNT (1 << 4)
#define XFS_AGI_ROOT (1 << 5)
#define XFS_AGI_LEVEL (1 << 6)
#define XFS_AGI_FREECOUNT (1 << 7)
#define XFS_AGI_NEWINO (1 << 8)
#define XFS_AGI_DIRINO (1 << 9)
#define XFS_AGI_UNLINKED (1 << 10)
#define XFS_AGI_NUM_BITS_R1 11 /* end of the 1st agi logging region */
#define XFS_AGI_ALL_BITS_R1 ((1 << XFS_AGI_NUM_BITS_R1) - 1)
#define XFS_AGI_FREE_ROOT (1 << 11)
#define XFS_AGI_FREE_LEVEL (1 << 12)
#define XFS_AGI_NUM_BITS_R2 13
/* disk block (xfs_daddr_t) in the AG */
#define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log))
#define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp))
#define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)((bp)->b_addr))
extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
xfs_agnumber_t agno, struct xfs_buf **bpp);
/*
* The third a.g. block contains the a.g. freelist, an array
* of block pointers to blocks owned by the allocation btree code.
*/
#define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log))
#define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp))
#define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)((bp)->b_addr))
#define XFS_BUF_TO_AGFL_BNO(mp, bp) \
(xfs_sb_version_hascrc(&((mp)->m_sb)) ? \
&(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \
(__be32 *)(bp)->b_addr)
/*
* Size of the AGFL. For CRC-enabled filesystes we steal a couple of
* slots in the beginning of the block for a proper header with the
* location information and CRC.
*/
#define XFS_AGFL_SIZE(mp) \
(((mp)->m_sb.sb_sectsize - \
(xfs_sb_version_hascrc(&((mp)->m_sb)) ? \
sizeof(struct xfs_agfl) : 0)) / \
sizeof(xfs_agblock_t))
typedef struct xfs_agfl {
__be32 agfl_magicnum;
__be32 agfl_seqno;
uuid_t agfl_uuid;
__be64 agfl_lsn;
__be32 agfl_crc;
__be32 agfl_bno[]; /* actually XFS_AGFL_SIZE(mp) */
} xfs_agfl_t;
#define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc)
/*
* tags for inode radix tree
*/
#define XFS_ICI_NO_TAG (-1) /* special flag for an untagged lookup
in xfs_inode_ag_iterator */
#define XFS_ICI_RECLAIM_TAG 0 /* inode is to be reclaimed */
#define XFS_ICI_EOFBLOCKS_TAG 1 /* inode has blocks beyond EOF */
#define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels)
#define XFS_MIN_FREELIST_RAW(bl,cl,mp) \
(MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + MIN(cl + 1, XFS_AG_MAXLEVELS(mp)))
#define XFS_MIN_FREELIST(a,mp) \
(XFS_MIN_FREELIST_RAW( \
be32_to_cpu((a)->agf_levels[XFS_BTNUM_BNOi]), \
be32_to_cpu((a)->agf_levels[XFS_BTNUM_CNTi]), mp))
#define XFS_MIN_FREELIST_PAG(pag,mp) \
(XFS_MIN_FREELIST_RAW( \
(unsigned int)(pag)->pagf_levels[XFS_BTNUM_BNOi], \
(unsigned int)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp))
#define XFS_AGB_TO_FSB(mp,agno,agbno) \
(((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno))
#define XFS_FSB_TO_AGNO(mp,fsbno) \
((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog))
#define XFS_FSB_TO_AGBNO(mp,fsbno) \
((xfs_agblock_t)((fsbno) & xfs_mask32lo((mp)->m_sb.sb_agblklog)))
#define XFS_AGB_TO_DADDR(mp,agno,agbno) \
((xfs_daddr_t)XFS_FSB_TO_BB(mp, \
(xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno)))
#define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d))
/*
* For checking for bad ranges of xfs_daddr_t's, covering multiple
* allocation groups or a single xfs_daddr_t that's a superblock copy.
*/
#define XFS_AG_CHECK_DADDR(mp,d,len) \
((len) == 1 ? \
ASSERT((d) == XFS_SB_DADDR || \
xfs_daddr_to_agbno(mp, d) != XFS_SB_DADDR) : \
ASSERT(xfs_daddr_to_agno(mp, d) == \
xfs_daddr_to_agno(mp, (d) + (len) - 1)))
#endif /* __XFS_AG_H__ */
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_btree.h" #include "xfs_btree.h"
......
...@@ -231,4 +231,7 @@ xfs_alloc_get_rec( ...@@ -231,4 +231,7 @@ xfs_alloc_get_rec(
xfs_extlen_t *len, /* output: length of extent */ xfs_extlen_t *len, /* output: length of extent */
int *stat); /* output: success/failure */ int *stat); /* output: success/failure */
int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp,
xfs_agnumber_t agno, int flags, struct xfs_buf **bpp);
#endif /* __XFS_ALLOC_H__ */ #endif /* __XFS_ALLOC_H__ */
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_btree.h" #include "xfs_btree.h"
#include "xfs_alloc_btree.h" #include "xfs_alloc_btree.h"
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -42,7 +40,6 @@ ...@@ -42,7 +40,6 @@
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_trans_space.h" #include "xfs_trans_space.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_dinode.h"
/* /*
* xfs_attr.c * xfs_attr.c
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -41,7 +40,6 @@ ...@@ -41,7 +40,6 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_cksum.h" #include "xfs_cksum.h"
#include "xfs_dinode.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
......
...@@ -22,9 +22,7 @@ ...@@ -22,9 +22,7 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_inum.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -46,7 +44,6 @@ ...@@ -46,7 +44,6 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_symlink.h" #include "xfs_symlink.h"
#include "xfs_attr_leaf.h" #include "xfs_attr_leaf.h"
#include "xfs_dinode.h"
#include "xfs_filestream.h" #include "xfs_filestream.h"
...@@ -5450,13 +5447,11 @@ xfs_bmse_merge( ...@@ -5450,13 +5447,11 @@ xfs_bmse_merge(
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
int *logflags) /* output */ int *logflags) /* output */
{ {
struct xfs_ifork *ifp;
struct xfs_bmbt_irec got; struct xfs_bmbt_irec got;
struct xfs_bmbt_irec left; struct xfs_bmbt_irec left;
xfs_filblks_t blockcount; xfs_filblks_t blockcount;
int error, i; int error, i;
ifp = XFS_IFORK_PTR(ip, whichfork);
xfs_bmbt_get_all(gotp, &got); xfs_bmbt_get_all(gotp, &got);
xfs_bmbt_get_all(leftp, &left); xfs_bmbt_get_all(leftp, &left);
blockcount = left.br_blockcount + got.br_blockcount; blockcount = left.br_blockcount + got.br_blockcount;
...@@ -5489,32 +5484,25 @@ xfs_bmse_merge( ...@@ -5489,32 +5484,25 @@ xfs_bmse_merge(
error = xfs_bmbt_lookup_eq(cur, got.br_startoff, got.br_startblock, error = xfs_bmbt_lookup_eq(cur, got.br_startoff, got.br_startblock,
got.br_blockcount, &i); got.br_blockcount, &i);
if (error) if (error)
goto out_error; return error;
XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); XFS_WANT_CORRUPTED_RETURN(i == 1);
error = xfs_btree_delete(cur, &i); error = xfs_btree_delete(cur, &i);
if (error) if (error)
goto out_error; return error;
XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); XFS_WANT_CORRUPTED_RETURN(i == 1);
/* lookup and update size of the previous extent */ /* lookup and update size of the previous extent */
error = xfs_bmbt_lookup_eq(cur, left.br_startoff, left.br_startblock, error = xfs_bmbt_lookup_eq(cur, left.br_startoff, left.br_startblock,
left.br_blockcount, &i); left.br_blockcount, &i);
if (error) if (error)
goto out_error; return error;
XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); XFS_WANT_CORRUPTED_RETURN(i == 1);
left.br_blockcount = blockcount; left.br_blockcount = blockcount;
error = xfs_bmbt_update(cur, left.br_startoff, left.br_startblock, return xfs_bmbt_update(cur, left.br_startoff, left.br_startblock,
left.br_blockcount, left.br_state); left.br_blockcount, left.br_state);
if (error)
goto out_error;
return 0;
out_error:
return error;
} }
/* /*
...@@ -5544,35 +5532,29 @@ xfs_bmse_shift_one( ...@@ -5544,35 +5532,29 @@ xfs_bmse_shift_one(
startoff = got.br_startoff - offset_shift_fsb; startoff = got.br_startoff - offset_shift_fsb;
/* delalloc extents should be prevented by caller */ /* delalloc extents should be prevented by caller */
XFS_WANT_CORRUPTED_GOTO(!isnullstartblock(got.br_startblock), XFS_WANT_CORRUPTED_RETURN(!isnullstartblock(got.br_startblock));
out_error);
/* /*
* If this is the first extent in the file, make sure there's enough * Check for merge if we've got an extent to the left, otherwise make
* room at the start of the file and jump right to the shift as there's * sure there's enough room at the start of the file for the shift.
* no left extent to merge.
*/ */
if (*current_ext == 0) { if (*current_ext) {
if (got.br_startoff < offset_shift_fsb) /* grab the left extent and check for a large enough hole */
return -EINVAL; leftp = xfs_iext_get_ext(ifp, *current_ext - 1);
goto shift_extent; xfs_bmbt_get_all(leftp, &left);
}
/* grab the left extent and check for a large enough hole */ if (startoff < left.br_startoff + left.br_blockcount)
leftp = xfs_iext_get_ext(ifp, *current_ext - 1); return -EINVAL;
xfs_bmbt_get_all(leftp, &left);
if (startoff < left.br_startoff + left.br_blockcount) /* check whether to merge the extent or shift it down */
if (xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) {
return xfs_bmse_merge(ip, whichfork, offset_shift_fsb,
*current_ext, gotp, leftp, cur,
logflags);
}
} else if (got.br_startoff < offset_shift_fsb)
return -EINVAL; return -EINVAL;
/* check whether to merge the extent or shift it down */
if (!xfs_bmse_can_merge(&left, &got, offset_shift_fsb))
goto shift_extent;
return xfs_bmse_merge(ip, whichfork, offset_shift_fsb, *current_ext,
gotp, leftp, cur, logflags);
shift_extent:
/* /*
* Increment the extent index for the next iteration, update the start * Increment the extent index for the next iteration, update the start
* offset of the in-core extent and update the btree if applicable. * offset of the in-core extent and update the btree if applicable.
...@@ -5589,18 +5571,11 @@ xfs_bmse_shift_one( ...@@ -5589,18 +5571,11 @@ xfs_bmse_shift_one(
got.br_blockcount, &i); got.br_blockcount, &i);
if (error) if (error)
return error; return error;
XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); XFS_WANT_CORRUPTED_RETURN(i == 1);
got.br_startoff = startoff; got.br_startoff = startoff;
error = xfs_bmbt_update(cur, got.br_startoff, got.br_startblock, return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock,
got.br_blockcount, got.br_state); got.br_blockcount, got.br_state);
if (error)
return error;
return 0;
out_error:
return error;
} }
/* /*
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
...@@ -36,7 +34,6 @@ ...@@ -36,7 +34,6 @@
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_cksum.h" #include "xfs_cksum.h"
#include "xfs_dinode.h"
/* /*
* Determine the extent state. * Determine the extent state.
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -514,7 +512,6 @@ xfs_da3_root_split( ...@@ -514,7 +512,6 @@ xfs_da3_root_split(
struct xfs_buf *bp; struct xfs_buf *bp;
struct xfs_inode *dp; struct xfs_inode *dp;
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_mount *mp;
struct xfs_dir2_leaf *leaf; struct xfs_dir2_leaf *leaf;
xfs_dablk_t blkno; xfs_dablk_t blkno;
int level; int level;
...@@ -534,7 +531,6 @@ xfs_da3_root_split( ...@@ -534,7 +531,6 @@ xfs_da3_root_split(
dp = args->dp; dp = args->dp;
tp = args->trans; tp = args->trans;
mp = state->mp;
error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, args->whichfork); error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, args->whichfork);
if (error) if (error)
return error; return error;
...@@ -2342,14 +2338,12 @@ xfs_da_shrink_inode( ...@@ -2342,14 +2338,12 @@ xfs_da_shrink_inode(
xfs_inode_t *dp; xfs_inode_t *dp;
int done, error, w, count; int done, error, w, count;
xfs_trans_t *tp; xfs_trans_t *tp;
xfs_mount_t *mp;
trace_xfs_da_shrink_inode(args); trace_xfs_da_shrink_inode(args);
dp = args->dp; dp = args->dp;
w = args->whichfork; w = args->whichfork;
tp = args->trans; tp = args->trans;
mp = dp->i_mount;
count = args->geo->fsbcount; count = args->geo->fsbcount;
for (;;) { for (;;) {
/* /*
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
......
/*
* Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __XFS_DINODE_H__
#define __XFS_DINODE_H__
#define XFS_DINODE_MAGIC 0x494e /* 'IN' */
#define XFS_DINODE_GOOD_VERSION(v) ((v) >= 1 && (v) <= 3)
typedef struct xfs_timestamp {
__be32 t_sec; /* timestamp seconds */
__be32 t_nsec; /* timestamp nanoseconds */
} xfs_timestamp_t;
/*
* On-disk inode structure.
*
* This is just the header or "dinode core", the inode is expanded to fill a
* variable size the leftover area split into a data and an attribute fork.
* The format of the data and attribute fork depends on the format of the
* inode as indicated by di_format and di_aformat. To access the data and
* attribute use the XFS_DFORK_DPTR, XFS_DFORK_APTR, and XFS_DFORK_PTR macros
* below.
*
* There is a very similar struct icdinode in xfs_inode which matches the
* layout of the first 96 bytes of this structure, but is kept in native
* format instead of big endian.
*
* Note: di_flushiter is only used by v1/2 inodes - it's effectively a zeroed
* padding field for v3 inodes.
*/
typedef struct xfs_dinode {
__be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */
__be16 di_mode; /* mode and type of file */
__u8 di_version; /* inode version */
__u8 di_format; /* format of di_c data */
__be16 di_onlink; /* old number of links to file */
__be32 di_uid; /* owner's user id */
__be32 di_gid; /* owner's group id */
__be32 di_nlink; /* number of links to file */
__be16 di_projid_lo; /* lower part of owner's project id */
__be16 di_projid_hi; /* higher part owner's project id */
__u8 di_pad[6]; /* unused, zeroed space */
__be16 di_flushiter; /* incremented on flush */
xfs_timestamp_t di_atime; /* time last accessed */
xfs_timestamp_t di_mtime; /* time last modified */
xfs_timestamp_t di_ctime; /* time created/inode modified */
__be64 di_size; /* number of bytes in file */
__be64 di_nblocks; /* # of direct & btree blocks used */
__be32 di_extsize; /* basic/minimum extent size for file */
__be32 di_nextents; /* number of extents in data fork */
__be16 di_anextents; /* number of extents in attribute fork*/
__u8 di_forkoff; /* attr fork offs, <<3 for 64b align */
__s8 di_aformat; /* format of attr fork's data */
__be32 di_dmevmask; /* DMIG event mask */
__be16 di_dmstate; /* DMIG state info */
__be16 di_flags; /* random flags, XFS_DIFLAG_... */
__be32 di_gen; /* generation number */
/* di_next_unlinked is the only non-core field in the old dinode */
__be32 di_next_unlinked;/* agi unlinked list ptr */
/* start of the extended dinode, writable fields */
__le32 di_crc; /* CRC of the inode */
__be64 di_changecount; /* number of attribute changes */
__be64 di_lsn; /* flush sequence */
__be64 di_flags2; /* more random flags */
__u8 di_pad2[16]; /* more padding for future expansion */
/* fields only written to during inode creation */
xfs_timestamp_t di_crtime; /* time created */
__be64 di_ino; /* inode number */
uuid_t di_uuid; /* UUID of the filesystem */
/* structure must be padded to 64 bit alignment */
} xfs_dinode_t;
#define XFS_DINODE_CRC_OFF offsetof(struct xfs_dinode, di_crc)
#define DI_MAX_FLUSH 0xffff
/*
* Size of the core inode on disk. Version 1 and 2 inodes have
* the same size, but version 3 has grown a few additional fields.
*/
static inline uint xfs_dinode_size(int version)
{
if (version == 3)
return sizeof(struct xfs_dinode);
return offsetof(struct xfs_dinode, di_crc);
}
/*
* The 32 bit link count in the inode theoretically maxes out at UINT_MAX.
* Since the pathconf interface is signed, we use 2^31 - 1 instead.
* The old inode format had a 16 bit link count, so its maximum is USHRT_MAX.
*/
#define XFS_MAXLINK ((1U << 31) - 1U)
#define XFS_MAXLINK_1 65535U
/*
* Values for di_format
*/
typedef enum xfs_dinode_fmt {
XFS_DINODE_FMT_DEV, /* xfs_dev_t */
XFS_DINODE_FMT_LOCAL, /* bulk data */
XFS_DINODE_FMT_EXTENTS, /* struct xfs_bmbt_rec */
XFS_DINODE_FMT_BTREE, /* struct xfs_bmdr_block */
XFS_DINODE_FMT_UUID /* uuid_t */
} xfs_dinode_fmt_t;
/*
* Inode minimum and maximum sizes.
*/
#define XFS_DINODE_MIN_LOG 8
#define XFS_DINODE_MAX_LOG 11
#define XFS_DINODE_MIN_SIZE (1 << XFS_DINODE_MIN_LOG)
#define XFS_DINODE_MAX_SIZE (1 << XFS_DINODE_MAX_LOG)
/*
* Inode size for given fs.
*/
#define XFS_LITINO(mp, version) \
((int)(((mp)->m_sb.sb_inodesize) - xfs_dinode_size(version)))
/*
* Inode data & attribute fork sizes, per inode.
*/
#define XFS_DFORK_Q(dip) ((dip)->di_forkoff != 0)
#define XFS_DFORK_BOFF(dip) ((int)((dip)->di_forkoff << 3))
#define XFS_DFORK_DSIZE(dip,mp) \
(XFS_DFORK_Q(dip) ? \
XFS_DFORK_BOFF(dip) : \
XFS_LITINO(mp, (dip)->di_version))
#define XFS_DFORK_ASIZE(dip,mp) \
(XFS_DFORK_Q(dip) ? \
XFS_LITINO(mp, (dip)->di_version) - XFS_DFORK_BOFF(dip) : \
0)
#define XFS_DFORK_SIZE(dip,mp,w) \
((w) == XFS_DATA_FORK ? \
XFS_DFORK_DSIZE(dip, mp) : \
XFS_DFORK_ASIZE(dip, mp))
/*
* Return pointers to the data or attribute forks.
*/
#define XFS_DFORK_DPTR(dip) \
((char *)dip + xfs_dinode_size(dip->di_version))
#define XFS_DFORK_APTR(dip) \
(XFS_DFORK_DPTR(dip) + XFS_DFORK_BOFF(dip))
#define XFS_DFORK_PTR(dip,w) \
((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip))
#define XFS_DFORK_FORMAT(dip,w) \
((w) == XFS_DATA_FORK ? \
(dip)->di_format : \
(dip)->di_aformat)
#define XFS_DFORK_NEXTENTS(dip,w) \
((w) == XFS_DATA_FORK ? \
be32_to_cpu((dip)->di_nextents) : \
be16_to_cpu((dip)->di_anextents))
#define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)((bp)->b_addr))
/*
* For block and character special files the 32bit dev_t is stored at the
* beginning of the data fork.
*/
static inline xfs_dev_t xfs_dinode_get_rdev(struct xfs_dinode *dip)
{
return be32_to_cpu(*(__be32 *)XFS_DFORK_DPTR(dip));
}
static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev)
{
*(__be32 *)XFS_DFORK_DPTR(dip) = cpu_to_be32(rdev);
}
/*
* Values for di_flags
* There should be a one-to-one correspondence between these flags and the
* XFS_XFLAG_s.
*/
#define XFS_DIFLAG_REALTIME_BIT 0 /* file's blocks come from rt area */
#define XFS_DIFLAG_PREALLOC_BIT 1 /* file space has been preallocated */
#define XFS_DIFLAG_NEWRTBM_BIT 2 /* for rtbitmap inode, new format */
#define XFS_DIFLAG_IMMUTABLE_BIT 3 /* inode is immutable */
#define XFS_DIFLAG_APPEND_BIT 4 /* inode is append-only */
#define XFS_DIFLAG_SYNC_BIT 5 /* inode is written synchronously */
#define XFS_DIFLAG_NOATIME_BIT 6 /* do not update atime */
#define XFS_DIFLAG_NODUMP_BIT 7 /* do not dump */
#define XFS_DIFLAG_RTINHERIT_BIT 8 /* create with realtime bit set */
#define XFS_DIFLAG_PROJINHERIT_BIT 9 /* create with parents projid */
#define XFS_DIFLAG_NOSYMLINKS_BIT 10 /* disallow symlink creation */
#define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */
#define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
#define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
#define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
#define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
#define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
#define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
#define XFS_DIFLAG_IMMUTABLE (1 << XFS_DIFLAG_IMMUTABLE_BIT)
#define XFS_DIFLAG_APPEND (1 << XFS_DIFLAG_APPEND_BIT)
#define XFS_DIFLAG_SYNC (1 << XFS_DIFLAG_SYNC_BIT)
#define XFS_DIFLAG_NOATIME (1 << XFS_DIFLAG_NOATIME_BIT)
#define XFS_DIFLAG_NODUMP (1 << XFS_DIFLAG_NODUMP_BIT)
#define XFS_DIFLAG_RTINHERIT (1 << XFS_DIFLAG_RTINHERIT_BIT)
#define XFS_DIFLAG_PROJINHERIT (1 << XFS_DIFLAG_PROJINHERIT_BIT)
#define XFS_DIFLAG_NOSYMLINKS (1 << XFS_DIFLAG_NOSYMLINKS_BIT)
#define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT)
#define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
#define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
#define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
#ifdef CONFIG_XFS_RT
#define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
#else
#define XFS_IS_REALTIME_INODE(ip) (0)
#endif
#define XFS_DIFLAG_ANY \
(XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \
XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
#endif /* __XFS_DINODE_H__ */
...@@ -20,9 +20,6 @@ ...@@ -20,9 +20,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_inum.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -34,10 +31,25 @@ ...@@ -34,10 +31,25 @@
#include "xfs_dir2_priv.h" #include "xfs_dir2_priv.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_dinode.h"
struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR }; struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR };
/*
* @mode, if set, indicates that the type field needs to be set up.
* This uses the transformation from file mode to DT_* as defined in linux/fs.h
* for file type specification. This will be propagated into the directory
* structure if appropriate for the given operation and filesystem config.
*/
const unsigned char xfs_mode_to_ftype[S_IFMT >> S_SHIFT] = {
[0] = XFS_DIR3_FT_UNKNOWN,
[S_IFREG >> S_SHIFT] = XFS_DIR3_FT_REG_FILE,
[S_IFDIR >> S_SHIFT] = XFS_DIR3_FT_DIR,
[S_IFCHR >> S_SHIFT] = XFS_DIR3_FT_CHRDEV,
[S_IFBLK >> S_SHIFT] = XFS_DIR3_FT_BLKDEV,
[S_IFIFO >> S_SHIFT] = XFS_DIR3_FT_FIFO,
[S_IFSOCK >> S_SHIFT] = XFS_DIR3_FT_SOCK,
[S_IFLNK >> S_SHIFT] = XFS_DIR3_FT_SYMLINK,
};
/* /*
* ASCII case-insensitive (ie. A-Z) support for directories that was * ASCII case-insensitive (ie. A-Z) support for directories that was
......
...@@ -31,6 +31,12 @@ struct xfs_dir2_data_unused; ...@@ -31,6 +31,12 @@ struct xfs_dir2_data_unused;
extern struct xfs_name xfs_name_dotdot; extern struct xfs_name xfs_name_dotdot;
/*
* directory filetype conversion tables.
*/
#define S_SHIFT 12
extern const unsigned char xfs_mode_to_ftype[];
/* /*
* directory operations vector for encode/decode routines * directory operations vector for encode/decode routines
*/ */
...@@ -177,4 +183,138 @@ extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops; ...@@ -177,4 +183,138 @@ extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops;
extern const struct xfs_buf_ops xfs_dir3_free_buf_ops; extern const struct xfs_buf_ops xfs_dir3_free_buf_ops;
extern const struct xfs_buf_ops xfs_dir3_data_buf_ops; extern const struct xfs_buf_ops xfs_dir3_data_buf_ops;
/*
* Directory offset/block conversion functions.
*
* DB blocks here are logical directory block numbers, not filesystem blocks.
*/
/*
* Convert dataptr to byte in file space
*/
static inline xfs_dir2_off_t
xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp)
{
return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG;
}
/*
* Convert byte in file space to dataptr. It had better be aligned.
*/
static inline xfs_dir2_dataptr_t
xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by)
{
return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG);
}
/*
* Convert byte in space to (DB) block
*/
static inline xfs_dir2_db_t
xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
{
return (xfs_dir2_db_t)(by >> geo->blklog);
}
/*
* Convert dataptr to a block number
*/
static inline xfs_dir2_db_t
xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
{
return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp));
}
/*
* Convert byte in space to offset in a block
*/
static inline xfs_dir2_data_aoff_t
xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
{
return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1));
}
/*
* Convert dataptr to a byte offset in a block
*/
static inline xfs_dir2_data_aoff_t
xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
{
return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp));
}
/*
* Convert block and offset to byte in space
*/
static inline xfs_dir2_off_t
xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
xfs_dir2_data_aoff_t o)
{
return ((xfs_dir2_off_t)db << geo->blklog) + o;
}
/*
* Convert block (DB) to block (dablk)
*/
static inline xfs_dablk_t
xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
{
return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog));
}
/*
* Convert byte in space to (DA) block
*/
static inline xfs_dablk_t
xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
{
return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by));
}
/*
* Convert block and offset to dataptr
*/
static inline xfs_dir2_dataptr_t
xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
xfs_dir2_data_aoff_t o)
{
return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o));
}
/*
* Convert block (dablk) to block (DB)
*/
static inline xfs_dir2_db_t
xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da)
{
return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog));
}
/*
* Convert block (dablk) to byte offset in space
*/
static inline xfs_dir2_off_t
xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da)
{
return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0);
}
/*
* Directory tail pointer accessor functions. Based on block geometry.
*/
static inline struct xfs_dir2_block_tail *
xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr)
{
return ((struct xfs_dir2_block_tail *)
((char *)hdr + geo->blksize)) - 1;
}
static inline struct xfs_dir2_leaf_tail *
xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp)
{
return (struct xfs_dir2_leaf_tail *)
((char *)lp + geo->blksize -
sizeof(struct xfs_dir2_leaf_tail));
}
#endif /* __XFS_DIR2_H__ */ #endif /* __XFS_DIR2_H__ */
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -36,7 +34,6 @@ ...@@ -36,7 +34,6 @@
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_cksum.h" #include "xfs_cksum.h"
#include "xfs_dinode.h"
/* /*
* Local function prototypes. * Local function prototypes.
...@@ -353,7 +350,6 @@ xfs_dir2_block_addname( ...@@ -353,7 +350,6 @@ xfs_dir2_block_addname(
int low; /* low index for binary srch */ int low; /* low index for binary srch */
int lowstale; /* low stale index */ int lowstale; /* low stale index */
int mid=0; /* midpoint for binary srch */ int mid=0; /* midpoint for binary srch */
xfs_mount_t *mp; /* filesystem mount point */
int needlog; /* need to log header */ int needlog; /* need to log header */
int needscan; /* need to rescan freespace */ int needscan; /* need to rescan freespace */
__be16 *tagp; /* pointer to tag value */ __be16 *tagp; /* pointer to tag value */
...@@ -363,7 +359,6 @@ xfs_dir2_block_addname( ...@@ -363,7 +359,6 @@ xfs_dir2_block_addname(
dp = args->dp; dp = args->dp;
tp = args->trans; tp = args->trans;
mp = dp->i_mount;
/* Read the (one and only) directory block into bp. */ /* Read the (one and only) directory block into bp. */
error = xfs_dir3_block_read(tp, dp, &bp); error = xfs_dir3_block_read(tp, dp, &bp);
...@@ -618,7 +613,6 @@ xfs_dir2_block_lookup( ...@@ -618,7 +613,6 @@ xfs_dir2_block_lookup(
xfs_inode_t *dp; /* incore inode */ xfs_inode_t *dp; /* incore inode */
int ent; /* entry index */ int ent; /* entry index */
int error; /* error return value */ int error; /* error return value */
xfs_mount_t *mp; /* filesystem mount point */
trace_xfs_dir2_block_lookup(args); trace_xfs_dir2_block_lookup(args);
...@@ -629,7 +623,6 @@ xfs_dir2_block_lookup( ...@@ -629,7 +623,6 @@ xfs_dir2_block_lookup(
if ((error = xfs_dir2_block_lookup_int(args, &bp, &ent))) if ((error = xfs_dir2_block_lookup_int(args, &bp, &ent)))
return error; return error;
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
hdr = bp->b_addr; hdr = bp->b_addr;
xfs_dir3_data_check(dp, bp); xfs_dir3_data_check(dp, bp);
btp = xfs_dir2_block_tail_p(args->geo, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
...@@ -770,7 +763,6 @@ xfs_dir2_block_removename( ...@@ -770,7 +763,6 @@ xfs_dir2_block_removename(
xfs_inode_t *dp; /* incore inode */ xfs_inode_t *dp; /* incore inode */
int ent; /* block leaf entry index */ int ent; /* block leaf entry index */
int error; /* error return value */ int error; /* error return value */
xfs_mount_t *mp; /* filesystem mount point */
int needlog; /* need to log block header */ int needlog; /* need to log block header */
int needscan; /* need to fixup bestfree */ int needscan; /* need to fixup bestfree */
xfs_dir2_sf_hdr_t sfh; /* shortform header */ xfs_dir2_sf_hdr_t sfh; /* shortform header */
...@@ -788,7 +780,6 @@ xfs_dir2_block_removename( ...@@ -788,7 +780,6 @@ xfs_dir2_block_removename(
} }
dp = args->dp; dp = args->dp;
tp = args->trans; tp = args->trans;
mp = dp->i_mount;
hdr = bp->b_addr; hdr = bp->b_addr;
btp = xfs_dir2_block_tail_p(args->geo, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
...@@ -852,7 +843,6 @@ xfs_dir2_block_replace( ...@@ -852,7 +843,6 @@ xfs_dir2_block_replace(
xfs_inode_t *dp; /* incore inode */ xfs_inode_t *dp; /* incore inode */
int ent; /* leaf entry index */ int ent; /* leaf entry index */
int error; /* error return value */ int error; /* error return value */
xfs_mount_t *mp; /* filesystem mount point */
trace_xfs_dir2_block_replace(args); trace_xfs_dir2_block_replace(args);
...@@ -864,7 +854,6 @@ xfs_dir2_block_replace( ...@@ -864,7 +854,6 @@ xfs_dir2_block_replace(
return error; return error;
} }
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
hdr = bp->b_addr; hdr = bp->b_addr;
btp = xfs_dir2_block_tail_p(args->geo, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -384,7 +382,6 @@ xfs_dir2_block_to_leaf( ...@@ -384,7 +382,6 @@ xfs_dir2_block_to_leaf(
xfs_dir2_db_t ldb; /* leaf block's bno */ xfs_dir2_db_t ldb; /* leaf block's bno */
xfs_dir2_leaf_t *leaf; /* leaf structure */ xfs_dir2_leaf_t *leaf; /* leaf structure */
xfs_dir2_leaf_tail_t *ltp; /* leaf's tail */ xfs_dir2_leaf_tail_t *ltp; /* leaf's tail */
xfs_mount_t *mp; /* filesystem mount point */
int needlog; /* need to log block header */ int needlog; /* need to log block header */
int needscan; /* need to rescan bestfree */ int needscan; /* need to rescan bestfree */
xfs_trans_t *tp; /* transaction pointer */ xfs_trans_t *tp; /* transaction pointer */
...@@ -395,7 +392,6 @@ xfs_dir2_block_to_leaf( ...@@ -395,7 +392,6 @@ xfs_dir2_block_to_leaf(
trace_xfs_dir2_block_to_leaf(args); trace_xfs_dir2_block_to_leaf(args);
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
tp = args->trans; tp = args->trans;
/* /*
* Add the leaf block to the inode. * Add the leaf block to the inode.
...@@ -626,7 +622,6 @@ xfs_dir2_leaf_addname( ...@@ -626,7 +622,6 @@ xfs_dir2_leaf_addname(
int lfloghigh; /* high leaf logging index */ int lfloghigh; /* high leaf logging index */
int lowstale; /* index of prev stale leaf */ int lowstale; /* index of prev stale leaf */
xfs_dir2_leaf_tail_t *ltp; /* leaf tail pointer */ xfs_dir2_leaf_tail_t *ltp; /* leaf tail pointer */
xfs_mount_t *mp; /* filesystem mount point */
int needbytes; /* leaf block bytes needed */ int needbytes; /* leaf block bytes needed */
int needlog; /* need to log data header */ int needlog; /* need to log data header */
int needscan; /* need to rescan data free */ int needscan; /* need to rescan data free */
...@@ -641,7 +636,6 @@ xfs_dir2_leaf_addname( ...@@ -641,7 +636,6 @@ xfs_dir2_leaf_addname(
dp = args->dp; dp = args->dp;
tp = args->trans; tp = args->trans;
mp = dp->i_mount;
error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp); error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp);
if (error) if (error)
...@@ -1356,11 +1350,9 @@ xfs_dir2_leaf_removename( ...@@ -1356,11 +1350,9 @@ xfs_dir2_leaf_removename(
xfs_dir2_leaf_t *leaf; /* leaf structure */ xfs_dir2_leaf_t *leaf; /* leaf structure */
xfs_dir2_leaf_entry_t *lep; /* leaf entry */ xfs_dir2_leaf_entry_t *lep; /* leaf entry */
xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
xfs_mount_t *mp; /* filesystem mount point */
int needlog; /* need to log data header */ int needlog; /* need to log data header */
int needscan; /* need to rescan data frees */ int needscan; /* need to rescan data frees */
xfs_dir2_data_off_t oldbest; /* old value of best free */ xfs_dir2_data_off_t oldbest; /* old value of best free */
xfs_trans_t *tp; /* transaction pointer */
struct xfs_dir2_data_free *bf; /* bestfree table */ struct xfs_dir2_data_free *bf; /* bestfree table */
struct xfs_dir2_leaf_entry *ents; struct xfs_dir2_leaf_entry *ents;
struct xfs_dir3_icleaf_hdr leafhdr; struct xfs_dir3_icleaf_hdr leafhdr;
...@@ -1374,8 +1366,6 @@ xfs_dir2_leaf_removename( ...@@ -1374,8 +1366,6 @@ xfs_dir2_leaf_removename(
return error; return error;
} }
dp = args->dp; dp = args->dp;
tp = args->trans;
mp = dp->i_mount;
leaf = lbp->b_addr; leaf = lbp->b_addr;
hdr = dbp->b_addr; hdr = dbp->b_addr;
xfs_dir3_data_check(dp, dbp); xfs_dir3_data_check(dp, dbp);
...@@ -1607,11 +1597,9 @@ xfs_dir2_leaf_trim_data( ...@@ -1607,11 +1597,9 @@ xfs_dir2_leaf_trim_data(
int error; /* error return value */ int error; /* error return value */
xfs_dir2_leaf_t *leaf; /* leaf structure */ xfs_dir2_leaf_t *leaf; /* leaf structure */
xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
xfs_mount_t *mp; /* filesystem mount point */
xfs_trans_t *tp; /* transaction pointer */ xfs_trans_t *tp; /* transaction pointer */
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
tp = args->trans; tp = args->trans;
/* /*
* Read the offending data block. We need its buffer. * Read the offending data block. We need its buffer.
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -297,7 +295,6 @@ xfs_dir2_leaf_to_node( ...@@ -297,7 +295,6 @@ xfs_dir2_leaf_to_node(
int i; /* leaf freespace index */ int i; /* leaf freespace index */
xfs_dir2_leaf_t *leaf; /* leaf structure */ xfs_dir2_leaf_t *leaf; /* leaf structure */
xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
xfs_mount_t *mp; /* filesystem mount point */
int n; /* count of live freespc ents */ int n; /* count of live freespc ents */
xfs_dir2_data_off_t off; /* freespace entry value */ xfs_dir2_data_off_t off; /* freespace entry value */
__be16 *to; /* pointer to freespace entry */ __be16 *to; /* pointer to freespace entry */
...@@ -307,7 +304,6 @@ xfs_dir2_leaf_to_node( ...@@ -307,7 +304,6 @@ xfs_dir2_leaf_to_node(
trace_xfs_dir2_leaf_to_node(args); trace_xfs_dir2_leaf_to_node(args);
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
tp = args->trans; tp = args->trans;
/* /*
* Add a freespace block to the directory. * Add a freespace block to the directory.
...@@ -387,16 +383,12 @@ xfs_dir2_leafn_add( ...@@ -387,16 +383,12 @@ xfs_dir2_leafn_add(
int lfloghigh; /* high leaf entry logging */ int lfloghigh; /* high leaf entry logging */
int lfloglow; /* low leaf entry logging */ int lfloglow; /* low leaf entry logging */
int lowstale; /* previous stale entry */ int lowstale; /* previous stale entry */
xfs_mount_t *mp; /* filesystem mount point */
xfs_trans_t *tp; /* transaction pointer */
struct xfs_dir3_icleaf_hdr leafhdr; struct xfs_dir3_icleaf_hdr leafhdr;
struct xfs_dir2_leaf_entry *ents; struct xfs_dir2_leaf_entry *ents;
trace_xfs_dir2_leafn_add(args, index); trace_xfs_dir2_leafn_add(args, index);
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
tp = args->trans;
leaf = bp->b_addr; leaf = bp->b_addr;
dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
ents = dp->d_ops->leaf_ents_p(leaf); ents = dp->d_ops->leaf_ents_p(leaf);
...@@ -1170,7 +1162,6 @@ xfs_dir2_leafn_remove( ...@@ -1170,7 +1162,6 @@ xfs_dir2_leafn_remove(
xfs_dir2_leaf_entry_t *lep; /* leaf entry */ xfs_dir2_leaf_entry_t *lep; /* leaf entry */
int longest; /* longest data free entry */ int longest; /* longest data free entry */
int off; /* data block entry offset */ int off; /* data block entry offset */
xfs_mount_t *mp; /* filesystem mount point */
int needlog; /* need to log data header */ int needlog; /* need to log data header */
int needscan; /* need to rescan data frees */ int needscan; /* need to rescan data frees */
xfs_trans_t *tp; /* transaction pointer */ xfs_trans_t *tp; /* transaction pointer */
...@@ -1182,7 +1173,6 @@ xfs_dir2_leafn_remove( ...@@ -1182,7 +1173,6 @@ xfs_dir2_leafn_remove(
dp = args->dp; dp = args->dp;
tp = args->trans; tp = args->trans;
mp = dp->i_mount;
leaf = bp->b_addr; leaf = bp->b_addr;
dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
ents = dp->d_ops->leaf_ents_p(leaf); ents = dp->d_ops->leaf_ents_p(leaf);
...@@ -1323,7 +1313,6 @@ xfs_dir2_leafn_split( ...@@ -1323,7 +1313,6 @@ xfs_dir2_leafn_split(
xfs_da_args_t *args; /* operation arguments */ xfs_da_args_t *args; /* operation arguments */
xfs_dablk_t blkno; /* new leaf block number */ xfs_dablk_t blkno; /* new leaf block number */
int error; /* error return value */ int error; /* error return value */
xfs_mount_t *mp; /* filesystem mount point */
struct xfs_inode *dp; struct xfs_inode *dp;
/* /*
...@@ -1331,7 +1320,6 @@ xfs_dir2_leafn_split( ...@@ -1331,7 +1320,6 @@ xfs_dir2_leafn_split(
*/ */
args = state->args; args = state->args;
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
ASSERT(oldblk->magic == XFS_DIR2_LEAFN_MAGIC); ASSERT(oldblk->magic == XFS_DIR2_LEAFN_MAGIC);
error = xfs_da_grow_inode(args, &blkno); error = xfs_da_grow_inode(args, &blkno);
if (error) { if (error) {
...@@ -2231,12 +2219,10 @@ xfs_dir2_node_trim_free( ...@@ -2231,12 +2219,10 @@ xfs_dir2_node_trim_free(
xfs_inode_t *dp; /* incore directory inode */ xfs_inode_t *dp; /* incore directory inode */
int error; /* error return code */ int error; /* error return code */
xfs_dir2_free_t *free; /* freespace structure */ xfs_dir2_free_t *free; /* freespace structure */
xfs_mount_t *mp; /* filesystem mount point */
xfs_trans_t *tp; /* transaction pointer */ xfs_trans_t *tp; /* transaction pointer */
struct xfs_dir3_icfree_hdr freehdr; struct xfs_dir3_icfree_hdr freehdr;
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
tp = args->trans; tp = args->trans;
/* /*
* Read the freespace block. * Read the freespace block.
......
...@@ -20,140 +20,6 @@ ...@@ -20,140 +20,6 @@
struct dir_context; struct dir_context;
/*
* Directory offset/block conversion functions.
*
* DB blocks here are logical directory block numbers, not filesystem blocks.
*/
/*
* Convert dataptr to byte in file space
*/
static inline xfs_dir2_off_t
xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp)
{
return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG;
}
/*
* Convert byte in file space to dataptr. It had better be aligned.
*/
static inline xfs_dir2_dataptr_t
xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by)
{
return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG);
}
/*
* Convert byte in space to (DB) block
*/
static inline xfs_dir2_db_t
xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
{
return (xfs_dir2_db_t)(by >> geo->blklog);
}
/*
* Convert dataptr to a block number
*/
static inline xfs_dir2_db_t
xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
{
return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp));
}
/*
* Convert byte in space to offset in a block
*/
static inline xfs_dir2_data_aoff_t
xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
{
return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1));
}
/*
* Convert dataptr to a byte offset in a block
*/
static inline xfs_dir2_data_aoff_t
xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
{
return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp));
}
/*
* Convert block and offset to byte in space
*/
static inline xfs_dir2_off_t
xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
xfs_dir2_data_aoff_t o)
{
return ((xfs_dir2_off_t)db << geo->blklog) + o;
}
/*
* Convert block (DB) to block (dablk)
*/
static inline xfs_dablk_t
xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
{
return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog));
}
/*
* Convert byte in space to (DA) block
*/
static inline xfs_dablk_t
xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
{
return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by));
}
/*
* Convert block and offset to dataptr
*/
static inline xfs_dir2_dataptr_t
xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
xfs_dir2_data_aoff_t o)
{
return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o));
}
/*
* Convert block (dablk) to block (DB)
*/
static inline xfs_dir2_db_t
xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da)
{
return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog));
}
/*
* Convert block (dablk) to byte offset in space
*/
static inline xfs_dir2_off_t
xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da)
{
return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0);
}
/*
* Directory tail pointer accessor functions. Based on block geometry.
*/
static inline struct xfs_dir2_block_tail *
xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr)
{
return ((struct xfs_dir2_block_tail *)
((char *)hdr + geo->blksize)) - 1;
}
static inline struct xfs_dir2_leaf_tail *
xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp)
{
return (struct xfs_dir2_leaf_tail *)
((char *)lp + geo->blksize -
sizeof(struct xfs_dir2_leaf_tail));
}
/* xfs_dir2.c */ /* xfs_dir2.c */
extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
...@@ -161,12 +27,6 @@ extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, ...@@ -161,12 +27,6 @@ extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
extern int xfs_dir_cilookup_result(struct xfs_da_args *args, extern int xfs_dir_cilookup_result(struct xfs_da_args *args,
const unsigned char *name, int len); const unsigned char *name, int len);
#define S_SHIFT 12
extern const unsigned char xfs_mode_to_ftype[];
extern unsigned char xfs_dir3_get_dtype(struct xfs_mount *mp,
__uint8_t filetype);
/* xfs_dir2_block.c */ /* xfs_dir2_block.c */
extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp, extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp,
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -32,7 +30,6 @@ ...@@ -32,7 +30,6 @@
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_dir2_priv.h" #include "xfs_dir2_priv.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_dinode.h"
/* /*
* Prototypes for internal functions. * Prototypes for internal functions.
...@@ -455,13 +452,11 @@ xfs_dir2_sf_addname_hard( ...@@ -455,13 +452,11 @@ xfs_dir2_sf_addname_hard(
xfs_dir2_sf_hdr_t *oldsfp; /* original shortform dir */ xfs_dir2_sf_hdr_t *oldsfp; /* original shortform dir */
xfs_dir2_sf_entry_t *sfep; /* entry in new dir */ xfs_dir2_sf_entry_t *sfep; /* entry in new dir */
xfs_dir2_sf_hdr_t *sfp; /* new shortform dir */ xfs_dir2_sf_hdr_t *sfp; /* new shortform dir */
struct xfs_mount *mp;
/* /*
* Copy the old directory to the stack buffer. * Copy the old directory to the stack buffer.
*/ */
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
old_isize = (int)dp->i_d.di_size; old_isize = (int)dp->i_d.di_size;
...@@ -542,7 +537,6 @@ xfs_dir2_sf_addname_pick( ...@@ -542,7 +537,6 @@ xfs_dir2_sf_addname_pick(
xfs_inode_t *dp; /* incore directory inode */ xfs_inode_t *dp; /* incore directory inode */
int holefit; /* found hole it will fit in */ int holefit; /* found hole it will fit in */
int i; /* entry number */ int i; /* entry number */
xfs_mount_t *mp; /* filesystem mount point */
xfs_dir2_data_aoff_t offset; /* data block offset */ xfs_dir2_data_aoff_t offset; /* data block offset */
xfs_dir2_sf_entry_t *sfep; /* shortform entry */ xfs_dir2_sf_entry_t *sfep; /* shortform entry */
xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
...@@ -550,7 +544,6 @@ xfs_dir2_sf_addname_pick( ...@@ -550,7 +544,6 @@ xfs_dir2_sf_addname_pick(
int used; /* data bytes used */ int used; /* data bytes used */
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
size = dp->d_ops->data_entsize(args->namelen); size = dp->d_ops->data_entsize(args->namelen);
...@@ -616,10 +609,8 @@ xfs_dir2_sf_check( ...@@ -616,10 +609,8 @@ xfs_dir2_sf_check(
int offset; /* data offset */ int offset; /* data offset */
xfs_dir2_sf_entry_t *sfep; /* shortform dir entry */ xfs_dir2_sf_entry_t *sfep; /* shortform dir entry */
xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
struct xfs_mount *mp;
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
offset = dp->d_ops->data_first_offset; offset = dp->d_ops->data_first_offset;
...@@ -1016,12 +1007,10 @@ xfs_dir2_sf_toino4( ...@@ -1016,12 +1007,10 @@ xfs_dir2_sf_toino4(
int oldsize; /* old inode size */ int oldsize; /* old inode size */
xfs_dir2_sf_entry_t *sfep; /* new sf entry */ xfs_dir2_sf_entry_t *sfep; /* new sf entry */
xfs_dir2_sf_hdr_t *sfp; /* new sf directory */ xfs_dir2_sf_hdr_t *sfp; /* new sf directory */
struct xfs_mount *mp;
trace_xfs_dir2_sf_toino4(args); trace_xfs_dir2_sf_toino4(args);
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
/* /*
* Copy the old directory to the buffer. * Copy the old directory to the buffer.
...@@ -1094,12 +1083,10 @@ xfs_dir2_sf_toino8( ...@@ -1094,12 +1083,10 @@ xfs_dir2_sf_toino8(
int oldsize; /* old inode size */ int oldsize; /* old inode size */
xfs_dir2_sf_entry_t *sfep; /* new sf entry */ xfs_dir2_sf_entry_t *sfep; /* new sf entry */
xfs_dir2_sf_hdr_t *sfp; /* new sf directory */ xfs_dir2_sf_hdr_t *sfp; /* new sf directory */
struct xfs_mount *mp;
trace_xfs_dir2_sf_toino8(args); trace_xfs_dir2_sf_toino8(args);
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
/* /*
* Copy the old directory to the buffer. * Copy the old directory to the buffer.
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_quota.h" #include "xfs_quota.h"
......
此差异已折叠。
...@@ -22,9 +22,7 @@ ...@@ -22,9 +22,7 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_inum.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_btree.h" #include "xfs_btree.h"
...@@ -39,7 +37,6 @@ ...@@ -39,7 +37,6 @@
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_icreate_item.h" #include "xfs_icreate_item.h"
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_dinode.h"
#include "xfs_trace.h" #include "xfs_trace.h"
...@@ -48,12 +45,12 @@ ...@@ -48,12 +45,12 @@
*/ */
static inline int static inline int
xfs_ialloc_cluster_alignment( xfs_ialloc_cluster_alignment(
xfs_alloc_arg_t *args) struct xfs_mount *mp)
{ {
if (xfs_sb_version_hasalign(&args->mp->m_sb) && if (xfs_sb_version_hasalign(&mp->m_sb) &&
args->mp->m_sb.sb_inoalignmt >= mp->m_sb.sb_inoalignmt >=
XFS_B_TO_FSBT(args->mp, args->mp->m_inode_cluster_size)) XFS_B_TO_FSBT(mp, mp->m_inode_cluster_size))
return args->mp->m_sb.sb_inoalignmt; return mp->m_sb.sb_inoalignmt;
return 1; return 1;
} }
...@@ -412,7 +409,7 @@ xfs_ialloc_ag_alloc( ...@@ -412,7 +409,7 @@ xfs_ialloc_ag_alloc(
* but not to use them in the actual exact allocation. * but not to use them in the actual exact allocation.
*/ */
args.alignment = 1; args.alignment = 1;
args.minalignslop = xfs_ialloc_cluster_alignment(&args) - 1; args.minalignslop = xfs_ialloc_cluster_alignment(args.mp) - 1;
/* Allow space for the inode btree to split. */ /* Allow space for the inode btree to split. */
args.minleft = args.mp->m_in_maxlevels - 1; args.minleft = args.mp->m_in_maxlevels - 1;
...@@ -448,7 +445,7 @@ xfs_ialloc_ag_alloc( ...@@ -448,7 +445,7 @@ xfs_ialloc_ag_alloc(
args.alignment = args.mp->m_dalign; args.alignment = args.mp->m_dalign;
isaligned = 1; isaligned = 1;
} else } else
args.alignment = xfs_ialloc_cluster_alignment(&args); args.alignment = xfs_ialloc_cluster_alignment(args.mp);
/* /*
* Need to figure out where to allocate the inode blocks. * Need to figure out where to allocate the inode blocks.
* Ideally they should be spaced out through the a.g. * Ideally they should be spaced out through the a.g.
...@@ -477,7 +474,7 @@ xfs_ialloc_ag_alloc( ...@@ -477,7 +474,7 @@ xfs_ialloc_ag_alloc(
args.type = XFS_ALLOCTYPE_NEAR_BNO; args.type = XFS_ALLOCTYPE_NEAR_BNO;
args.agbno = be32_to_cpu(agi->agi_root); args.agbno = be32_to_cpu(agi->agi_root);
args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno);
args.alignment = xfs_ialloc_cluster_alignment(&args); args.alignment = xfs_ialloc_cluster_alignment(args.mp);
if ((error = xfs_alloc_vextent(&args))) if ((error = xfs_alloc_vextent(&args)))
return error; return error;
} }
...@@ -632,10 +629,24 @@ xfs_ialloc_ag_select( ...@@ -632,10 +629,24 @@ xfs_ialloc_ag_select(
} }
/* /*
* Is there enough free space for the file plus a block of * Check that there is enough free space for the file plus a
* inodes? (if we need to allocate some)? * chunk of inodes if we need to allocate some. If this is the
* first pass across the AGs, take into account the potential
* space needed for alignment of inode chunks when checking the
* longest contiguous free space in the AG - this prevents us
* from getting ENOSPC because we have free space larger than
* m_ialloc_blks but alignment constraints prevent us from using
* it.
*
* If we can't find an AG with space for full alignment slack to
* be taken into account, we must be near ENOSPC in all AGs.
* Hence we don't include alignment for the second pass and so
* if we fail allocation due to alignment issues then it is most
* likely a real ENOSPC condition.
*/ */
ineed = mp->m_ialloc_blks; ineed = mp->m_ialloc_blks;
if (flags && ineed > 1)
ineed += xfs_ialloc_cluster_alignment(mp);
longest = pag->pagf_longest; longest = pag->pagf_longest;
if (!longest) if (!longest)
longest = pag->pagf_flcount > 0; longest = pag->pagf_flcount > 0;
...@@ -1137,11 +1148,7 @@ xfs_dialloc_ag_update_inobt( ...@@ -1137,11 +1148,7 @@ xfs_dialloc_ag_update_inobt(
XFS_WANT_CORRUPTED_RETURN((rec.ir_free == frec->ir_free) && XFS_WANT_CORRUPTED_RETURN((rec.ir_free == frec->ir_free) &&
(rec.ir_freecount == frec->ir_freecount)); (rec.ir_freecount == frec->ir_freecount));
error = xfs_inobt_update(cur, &rec); return xfs_inobt_update(cur, &rec);
if (error)
return error;
return 0;
} }
/* /*
......
...@@ -160,4 +160,8 @@ int xfs_ialloc_inode_init(struct xfs_mount *mp, struct xfs_trans *tp, ...@@ -160,4 +160,8 @@ int xfs_ialloc_inode_init(struct xfs_mount *mp, struct xfs_trans *tp,
xfs_agnumber_t agno, xfs_agblock_t agbno, xfs_agnumber_t agno, xfs_agblock_t agbno,
xfs_agblock_t length, unsigned int gen); xfs_agblock_t length, unsigned int gen);
int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
xfs_agnumber_t agno, struct xfs_buf **bpp);
#endif /* __XFS_IALLOC_H__ */ #endif /* __XFS_IALLOC_H__ */
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_btree.h" #include "xfs_btree.h"
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_error.h" #include "xfs_error.h"
...@@ -30,7 +28,6 @@ ...@@ -30,7 +28,6 @@
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_ialloc.h" #include "xfs_ialloc.h"
#include "xfs_dinode.h"
/* /*
* Check that none of the inode's in the buffer have a next * Check that none of the inode's in the buffer have a next
......
...@@ -22,9 +22,6 @@ ...@@ -22,9 +22,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_inum.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
...@@ -34,7 +31,6 @@ ...@@ -34,7 +31,6 @@
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_attr_sf.h" #include "xfs_attr_sf.h"
#include "xfs_dinode.h"
kmem_zone_t *xfs_ifork_zone; kmem_zone_t *xfs_ifork_zone;
......
/*
* Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __XFS_INUM_H__
#define __XFS_INUM_H__
/*
* Inode number format:
* low inopblog bits - offset in block
* next agblklog bits - block number in ag
* next agno_log bits - ag number
* high agno_log-agblklog-inopblog bits - 0
*/
struct xfs_mount;
#define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1)
#define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog
#define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog
#define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log
#define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log
#define XFS_INO_BITS(mp) \
XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp)
#define XFS_INO_TO_AGNO(mp,i) \
((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp)))
#define XFS_INO_TO_AGINO(mp,i) \
((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp)))
#define XFS_INO_TO_AGBNO(mp,i) \
(((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \
XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp)))
#define XFS_INO_TO_OFFSET(mp,i) \
((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
#define XFS_INO_TO_FSB(mp,i) \
XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i))
#define XFS_AGINO_TO_INO(mp,a,i) \
(((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i))
#define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp))
#define XFS_AGINO_TO_OFFSET(mp,i) \
((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
#define XFS_OFFBNO_TO_AGINO(mp,b,o) \
((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o)))
#define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL))
#define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL))
#endif /* __XFS_INUM_H__ */
...@@ -361,7 +361,7 @@ typedef struct xfs_ictimestamp { ...@@ -361,7 +361,7 @@ typedef struct xfs_ictimestamp {
/* /*
* NOTE: This structure must be kept identical to struct xfs_dinode * NOTE: This structure must be kept identical to struct xfs_dinode
* in xfs_dinode.h except for the endianness annotations. * except for the endianness annotations.
*/ */
typedef struct xfs_icdinode { typedef struct xfs_icdinode {
__uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_ag.h"
#include "xfs_sb.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_trans_space.h" #include "xfs_trans_space.h"
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
...@@ -36,7 +34,6 @@ ...@@ -36,7 +34,6 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_buf.h" #include "xfs_buf.h"
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_dinode.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_ialloc.h" #include "xfs_ialloc.h"
...@@ -33,7 +32,6 @@ ...@@ -33,7 +32,6 @@
#include "xfs_cksum.h" #include "xfs_cksum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_dinode.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h" #include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
......
此差异已折叠。
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_shared.h" #include "xfs_shared.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_ag.h"
#include "xfs_sb.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_inode.h" #include "xfs_inode.h"
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_ag.h"
#include "xfs_sb.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_acl.h" #include "xfs_acl.h"
......
...@@ -22,42 +22,6 @@ struct inode; ...@@ -22,42 +22,6 @@ struct inode;
struct posix_acl; struct posix_acl;
struct xfs_inode; struct xfs_inode;
#define XFS_ACL_NOT_PRESENT (-1)
/* On-disk XFS access control list structure */
struct xfs_acl_entry {
__be32 ae_tag;
__be32 ae_id;
__be16 ae_perm;
__be16 ae_pad; /* fill the implicit hole in the structure */
};
struct xfs_acl {
__be32 acl_cnt;
struct xfs_acl_entry acl_entry[0];
};
/*
* The number of ACL entries allowed is defined by the on-disk format.
* For v4 superblocks, that is limited to 25 entries. For v5 superblocks, it is
* limited only by the maximum size of the xattr that stores the information.
*/
#define XFS_ACL_MAX_ENTRIES(mp) \
(xfs_sb_version_hascrc(&mp->m_sb) \
? (XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \
sizeof(struct xfs_acl_entry) \
: 25)
#define XFS_ACL_MAX_SIZE(mp) \
(sizeof(struct xfs_acl) + \
sizeof(struct xfs_acl_entry) * XFS_ACL_MAX_ENTRIES((mp)))
/* On-disk XFS extended attribute names */
#define SGI_ACL_FILE (unsigned char *)"SGI_ACL_FILE"
#define SGI_ACL_DEFAULT (unsigned char *)"SGI_ACL_DEFAULT"
#define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1)
#define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)
#ifdef CONFIG_XFS_POSIX_ACL #ifdef CONFIG_XFS_POSIX_ACL
extern struct posix_acl *xfs_get_acl(struct inode *inode, int type); extern struct posix_acl *xfs_get_acl(struct inode *inode, int type);
extern int xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); extern int xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
...@@ -33,7 +31,6 @@ ...@@ -33,7 +31,6 @@
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_bmap_util.h" #include "xfs_bmap_util.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_dinode.h"
#include <linux/aio.h> #include <linux/aio.h>
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/mpage.h> #include <linux/mpage.h>
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -39,7 +37,6 @@ ...@@ -39,7 +37,6 @@
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_dinode.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
/* /*
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -39,7 +37,6 @@ ...@@ -39,7 +37,6 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_cksum.h" #include "xfs_cksum.h"
#include "xfs_dinode.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
STATIC int STATIC int
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_inode.h" #include "xfs_inode.h"
...@@ -42,7 +40,6 @@ ...@@ -42,7 +40,6 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_dinode.h"
/* Kernel only BMAP related definitions and functions */ /* Kernel only BMAP related definitions and functions */
......
...@@ -34,18 +34,16 @@ ...@@ -34,18 +34,16 @@
#include <linux/backing-dev.h> #include <linux/backing-dev.h>
#include <linux/freezer.h> #include <linux/freezer.h>
#include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_log.h" #include "xfs_log.h"
static kmem_zone_t *xfs_buf_zone; static kmem_zone_t *xfs_buf_zone;
static struct workqueue_struct *xfslogd_workqueue;
#ifdef XFS_BUF_LOCK_TRACKING #ifdef XFS_BUF_LOCK_TRACKING
# define XB_SET_OWNER(bp) ((bp)->b_last_holder = current->pid) # define XB_SET_OWNER(bp) ((bp)->b_last_holder = current->pid)
# define XB_CLEAR_OWNER(bp) ((bp)->b_last_holder = -1) # define XB_CLEAR_OWNER(bp) ((bp)->b_last_holder = -1)
...@@ -463,7 +461,7 @@ _xfs_buf_find( ...@@ -463,7 +461,7 @@ _xfs_buf_find(
* have to check that the buffer falls within the filesystem bounds. * have to check that the buffer falls within the filesystem bounds.
*/ */
eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks); eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks);
if (blkno >= eofs) { if (blkno < 0 || blkno >= eofs) {
/* /*
* XXX (dgc): we should really be returning -EFSCORRUPTED here, * XXX (dgc): we should really be returning -EFSCORRUPTED here,
* but none of the higher level infrastructure supports * but none of the higher level infrastructure supports
...@@ -1043,7 +1041,7 @@ xfs_buf_ioend_work( ...@@ -1043,7 +1041,7 @@ xfs_buf_ioend_work(
struct work_struct *work) struct work_struct *work)
{ {
struct xfs_buf *bp = struct xfs_buf *bp =
container_of(work, xfs_buf_t, b_iodone_work); container_of(work, xfs_buf_t, b_ioend_work);
xfs_buf_ioend(bp); xfs_buf_ioend(bp);
} }
...@@ -1052,8 +1050,8 @@ void ...@@ -1052,8 +1050,8 @@ void
xfs_buf_ioend_async( xfs_buf_ioend_async(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
INIT_WORK(&bp->b_iodone_work, xfs_buf_ioend_work); INIT_WORK(&bp->b_ioend_work, xfs_buf_ioend_work);
queue_work(xfslogd_workqueue, &bp->b_iodone_work); queue_work(bp->b_ioend_wq, &bp->b_ioend_work);
} }
void void
...@@ -1222,6 +1220,13 @@ _xfs_buf_ioapply( ...@@ -1222,6 +1220,13 @@ _xfs_buf_ioapply(
*/ */
bp->b_error = 0; bp->b_error = 0;
/*
* Initialize the I/O completion workqueue if we haven't yet or the
* submitter has not opted to specify a custom one.
*/
if (!bp->b_ioend_wq)
bp->b_ioend_wq = bp->b_target->bt_mount->m_buf_workqueue;
if (bp->b_flags & XBF_WRITE) { if (bp->b_flags & XBF_WRITE) {
if (bp->b_flags & XBF_SYNCIO) if (bp->b_flags & XBF_SYNCIO)
rw = WRITE_SYNC; rw = WRITE_SYNC;
...@@ -1882,15 +1887,8 @@ xfs_buf_init(void) ...@@ -1882,15 +1887,8 @@ xfs_buf_init(void)
if (!xfs_buf_zone) if (!xfs_buf_zone)
goto out; goto out;
xfslogd_workqueue = alloc_workqueue("xfslogd",
WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_FREEZABLE, 1);
if (!xfslogd_workqueue)
goto out_free_buf_zone;
return 0; return 0;
out_free_buf_zone:
kmem_zone_destroy(xfs_buf_zone);
out: out:
return -ENOMEM; return -ENOMEM;
} }
...@@ -1898,6 +1896,5 @@ xfs_buf_init(void) ...@@ -1898,6 +1896,5 @@ xfs_buf_init(void)
void void
xfs_buf_terminate(void) xfs_buf_terminate(void)
{ {
destroy_workqueue(xfslogd_workqueue);
kmem_zone_destroy(xfs_buf_zone); kmem_zone_destroy(xfs_buf_zone);
} }
...@@ -164,7 +164,8 @@ typedef struct xfs_buf { ...@@ -164,7 +164,8 @@ typedef struct xfs_buf {
struct xfs_perag *b_pag; /* contains rbtree root */ struct xfs_perag *b_pag; /* contains rbtree root */
xfs_buftarg_t *b_target; /* buffer target (device) */ xfs_buftarg_t *b_target; /* buffer target (device) */
void *b_addr; /* virtual address of buffer */ void *b_addr; /* virtual address of buffer */
struct work_struct b_iodone_work; struct work_struct b_ioend_work;
struct workqueue_struct *b_ioend_wq; /* I/O completion wq */
xfs_buf_iodone_t b_iodone; /* I/O completion function */ xfs_buf_iodone_t b_iodone; /* I/O completion function */
struct completion b_iowait; /* queue for I/O waiters */ struct completion b_iowait; /* queue for I/O waiters */
void *b_fspriv; void *b_fspriv;
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -34,7 +32,6 @@ ...@@ -34,7 +32,6 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_dinode.h"
/* /*
* Directory file type support functions * Directory file type support functions
...@@ -44,7 +41,7 @@ static unsigned char xfs_dir3_filetype_table[] = { ...@@ -44,7 +41,7 @@ static unsigned char xfs_dir3_filetype_table[] = {
DT_FIFO, DT_SOCK, DT_LNK, DT_WHT, DT_FIFO, DT_SOCK, DT_LNK, DT_WHT,
}; };
unsigned char static unsigned char
xfs_dir3_get_dtype( xfs_dir3_get_dtype(
struct xfs_mount *mp, struct xfs_mount *mp,
__uint8_t filetype) __uint8_t filetype)
...@@ -57,22 +54,6 @@ xfs_dir3_get_dtype( ...@@ -57,22 +54,6 @@ xfs_dir3_get_dtype(
return xfs_dir3_filetype_table[filetype]; return xfs_dir3_filetype_table[filetype];
} }
/*
* @mode, if set, indicates that the type field needs to be set up.
* This uses the transformation from file mode to DT_* as defined in linux/fs.h
* for file type specification. This will be propagated into the directory
* structure if appropriate for the given operation and filesystem config.
*/
const unsigned char xfs_mode_to_ftype[S_IFMT >> S_SHIFT] = {
[0] = XFS_DIR3_FT_UNKNOWN,
[S_IFREG >> S_SHIFT] = XFS_DIR3_FT_REG_FILE,
[S_IFDIR >> S_SHIFT] = XFS_DIR3_FT_DIR,
[S_IFCHR >> S_SHIFT] = XFS_DIR3_FT_CHRDEV,
[S_IFBLK >> S_SHIFT] = XFS_DIR3_FT_BLKDEV,
[S_IFIFO >> S_SHIFT] = XFS_DIR3_FT_FIFO,
[S_IFSOCK >> S_SHIFT] = XFS_DIR3_FT_SOCK,
[S_IFLNK >> S_SHIFT] = XFS_DIR3_FT_SYMLINK,
};
STATIC int STATIC int
xfs_dir2_sf_getdents( xfs_dir2_sf_getdents(
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_inode.h" #include "xfs_inode.h"
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_shared.h" #include "xfs_shared.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_quota.h" #include "xfs_quota.h"
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_error.h" #include "xfs_error.h"
......
...@@ -19,10 +19,9 @@ ...@@ -19,10 +19,9 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_export.h" #include "xfs_export.h"
#include "xfs_inode.h" #include "xfs_inode.h"
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "xfs_shared.h" #include "xfs_shared.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
#include "xfs_extent_busy.h" #include "xfs_extent_busy.h"
......
...@@ -17,10 +17,9 @@ ...@@ -17,10 +17,9 @@
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_trans_priv.h" #include "xfs_trans_priv.h"
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -37,7 +35,6 @@ ...@@ -37,7 +35,6 @@
#include "xfs_ioctl.h" #include "xfs_ioctl.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_dinode.h"
#include "xfs_icache.h" #include "xfs_icache.h"
#include <linux/aio.h> #include <linux/aio.h>
...@@ -933,7 +930,6 @@ xfs_file_readdir( ...@@ -933,7 +930,6 @@ xfs_file_readdir(
{ {
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
xfs_inode_t *ip = XFS_I(inode); xfs_inode_t *ip = XFS_I(inode);
int error;
size_t bufsize; size_t bufsize;
/* /*
...@@ -950,10 +946,7 @@ xfs_file_readdir( ...@@ -950,10 +946,7 @@ xfs_file_readdir(
*/ */
bufsize = (size_t)min_t(loff_t, 32768, ip->i_d.di_size); bufsize = (size_t)min_t(loff_t, 32768, ip->i_d.di_size);
error = xfs_readdir(ip, ctx, bufsize); return xfs_readdir(ip, ctx, bufsize);
if (error)
return error;
return 0;
} }
STATIC int STATIC int
......
...@@ -20,16 +20,13 @@ ...@@ -20,16 +20,13 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_ag.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inum.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_bmap_util.h" #include "xfs_bmap_util.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
#include "xfs_mru_cache.h" #include "xfs_mru_cache.h"
#include "xfs_dinode.h"
#include "xfs_filestream.h" #include "xfs_filestream.h"
#include "xfs_trace.h" #include "xfs_trace.h"
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -40,7 +39,6 @@ ...@@ -40,7 +39,6 @@
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_dinode.h"
#include "xfs_filestream.h" #include "xfs_filestream.h"
/* /*
......
...@@ -20,9 +20,7 @@ ...@@ -20,9 +20,7 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_inum.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_error.h" #include "xfs_error.h"
...@@ -65,6 +63,7 @@ xfs_inode_alloc( ...@@ -65,6 +63,7 @@ xfs_inode_alloc(
return NULL; return NULL;
} }
XFS_STATS_INC(vn_active);
ASSERT(atomic_read(&ip->i_pincount) == 0); ASSERT(atomic_read(&ip->i_pincount) == 0);
ASSERT(!spin_is_locked(&ip->i_flags_lock)); ASSERT(!spin_is_locked(&ip->i_flags_lock));
ASSERT(!xfs_isiflocked(ip)); ASSERT(!xfs_isiflocked(ip));
...@@ -130,6 +129,7 @@ xfs_inode_free( ...@@ -130,6 +129,7 @@ xfs_inode_free(
/* asserts to verify all state is correct here */ /* asserts to verify all state is correct here */
ASSERT(atomic_read(&ip->i_pincount) == 0); ASSERT(atomic_read(&ip->i_pincount) == 0);
ASSERT(!xfs_isiflocked(ip)); ASSERT(!xfs_isiflocked(ip));
XFS_STATS_DEC(vn_active);
call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback); call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback);
} }
......
...@@ -33,6 +33,14 @@ struct xfs_eofblocks { ...@@ -33,6 +33,14 @@ struct xfs_eofblocks {
#define SYNC_WAIT 0x0001 /* wait for i/o to complete */ #define SYNC_WAIT 0x0001 /* wait for i/o to complete */
#define SYNC_TRYLOCK 0x0002 /* only try to lock inodes */ #define SYNC_TRYLOCK 0x0002 /* only try to lock inodes */
/*
* tags for inode radix tree
*/
#define XFS_ICI_NO_TAG (-1) /* special flag for an untagged lookup
in xfs_inode_ag_iterator */
#define XFS_ICI_RECLAIM_TAG 0 /* inode is to be reclaimed */
#define XFS_ICI_EOFBLOCKS_TAG 1 /* inode has blocks beyond EOF */
/* /*
* Flags for xfs_iget() * Flags for xfs_iget()
*/ */
......
...@@ -18,11 +18,10 @@ ...@@ -18,11 +18,10 @@
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_shared.h" #include "xfs_shared.h"
#include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_trans_priv.h" #include "xfs_trans_priv.h"
......
...@@ -23,9 +23,7 @@ ...@@ -23,9 +23,7 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_inum.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
...@@ -1082,7 +1080,7 @@ xfs_create( ...@@ -1082,7 +1080,7 @@ xfs_create(
struct xfs_dquot *udqp = NULL; struct xfs_dquot *udqp = NULL;
struct xfs_dquot *gdqp = NULL; struct xfs_dquot *gdqp = NULL;
struct xfs_dquot *pdqp = NULL; struct xfs_dquot *pdqp = NULL;
struct xfs_trans_res tres; struct xfs_trans_res *tres;
uint resblks; uint resblks;
trace_xfs_create(dp, name); trace_xfs_create(dp, name);
...@@ -1105,13 +1103,11 @@ xfs_create( ...@@ -1105,13 +1103,11 @@ xfs_create(
if (is_dir) { if (is_dir) {
rdev = 0; rdev = 0;
resblks = XFS_MKDIR_SPACE_RES(mp, name->len); resblks = XFS_MKDIR_SPACE_RES(mp, name->len);
tres.tr_logres = M_RES(mp)->tr_mkdir.tr_logres; tres = &M_RES(mp)->tr_mkdir;
tres.tr_logcount = XFS_MKDIR_LOG_COUNT;
tp = xfs_trans_alloc(mp, XFS_TRANS_MKDIR); tp = xfs_trans_alloc(mp, XFS_TRANS_MKDIR);
} else { } else {
resblks = XFS_CREATE_SPACE_RES(mp, name->len); resblks = XFS_CREATE_SPACE_RES(mp, name->len);
tres.tr_logres = M_RES(mp)->tr_create.tr_logres; tres = &M_RES(mp)->tr_create;
tres.tr_logcount = XFS_CREATE_LOG_COUNT;
tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE); tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE);
} }
...@@ -1123,17 +1119,16 @@ xfs_create( ...@@ -1123,17 +1119,16 @@ xfs_create(
* the case we'll drop the one we have and get a more * the case we'll drop the one we have and get a more
* appropriate transaction later. * appropriate transaction later.
*/ */
tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; error = xfs_trans_reserve(tp, tres, resblks, 0);
error = xfs_trans_reserve(tp, &tres, resblks, 0);
if (error == -ENOSPC) { if (error == -ENOSPC) {
/* flush outstanding delalloc blocks and retry */ /* flush outstanding delalloc blocks and retry */
xfs_flush_inodes(mp); xfs_flush_inodes(mp);
error = xfs_trans_reserve(tp, &tres, resblks, 0); error = xfs_trans_reserve(tp, tres, resblks, 0);
} }
if (error == -ENOSPC) { if (error == -ENOSPC) {
/* No space at all so try a "no-allocation" reservation */ /* No space at all so try a "no-allocation" reservation */
resblks = 0; resblks = 0;
error = xfs_trans_reserve(tp, &tres, 0, 0); error = xfs_trans_reserve(tp, tres, 0, 0);
} }
if (error) { if (error) {
cancel_flags = 0; cancel_flags = 0;
...@@ -2488,9 +2483,7 @@ xfs_remove( ...@@ -2488,9 +2483,7 @@ xfs_remove(
xfs_fsblock_t first_block; xfs_fsblock_t first_block;
int cancel_flags; int cancel_flags;
int committed; int committed;
int link_zero;
uint resblks; uint resblks;
uint log_count;
trace_xfs_remove(dp, name); trace_xfs_remove(dp, name);
...@@ -2505,13 +2498,10 @@ xfs_remove( ...@@ -2505,13 +2498,10 @@ xfs_remove(
if (error) if (error)
goto std_return; goto std_return;
if (is_dir) { if (is_dir)
tp = xfs_trans_alloc(mp, XFS_TRANS_RMDIR); tp = xfs_trans_alloc(mp, XFS_TRANS_RMDIR);
log_count = XFS_DEFAULT_LOG_COUNT; else
} else {
tp = xfs_trans_alloc(mp, XFS_TRANS_REMOVE); tp = xfs_trans_alloc(mp, XFS_TRANS_REMOVE);
log_count = XFS_REMOVE_LOG_COUNT;
}
cancel_flags = XFS_TRANS_RELEASE_LOG_RES; cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
/* /*
...@@ -2579,9 +2569,6 @@ xfs_remove( ...@@ -2579,9 +2569,6 @@ xfs_remove(
if (error) if (error)
goto out_trans_cancel; goto out_trans_cancel;
/* Determine if this is the last link while the inode is locked */
link_zero = (ip->i_d.di_nlink == 0);
xfs_bmap_init(&free_list, &first_block); xfs_bmap_init(&free_list, &first_block);
error = xfs_dir_removename(tp, dp, name, ip->i_ino, error = xfs_dir_removename(tp, dp, name, ip->i_ino,
&first_block, &free_list, resblks); &first_block, &free_list, resblks);
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "xfs_inode_buf.h" #include "xfs_inode_buf.h"
#include "xfs_inode_fork.h" #include "xfs_inode_fork.h"
#include "xfs_dinode.h"
/* /*
* Kernel only inode definitions * Kernel only inode definitions
...@@ -324,7 +323,6 @@ static inline int xfs_isiflocked(struct xfs_inode *ip) ...@@ -324,7 +323,6 @@ static inline int xfs_isiflocked(struct xfs_inode *ip)
(((pip)->i_mount->m_flags & XFS_MOUNT_GRPID) || \ (((pip)->i_mount->m_flags & XFS_MOUNT_GRPID) || \
((pip)->i_d.di_mode & S_ISGID)) ((pip)->i_d.di_mode & S_ISGID))
int xfs_release(struct xfs_inode *ip); int xfs_release(struct xfs_inode *ip);
void xfs_inactive(struct xfs_inode *ip); void xfs_inactive(struct xfs_inode *ip);
int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name, int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name,
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
...@@ -29,7 +27,6 @@ ...@@ -29,7 +27,6 @@
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_trans_priv.h" #include "xfs_trans_priv.h"
#include "xfs_dinode.h"
#include "xfs_log.h" #include "xfs_log.h"
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_ioctl.h" #include "xfs_ioctl.h"
...@@ -40,7 +38,6 @@ ...@@ -40,7 +38,6 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_symlink.h" #include "xfs_symlink.h"
#include "xfs_dinode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include <linux/capability.h> #include <linux/capability.h>
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_itable.h" #include "xfs_itable.h"
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_btree.h" #include "xfs_btree.h"
...@@ -38,7 +36,6 @@ ...@@ -38,7 +36,6 @@
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_dquot_item.h" #include "xfs_dquot_item.h"
#include "xfs_dquot.h" #include "xfs_dquot.h"
#include "xfs_dinode.h"
#define XFS_WRITEIO_ALIGN(mp,off) (((off) >> mp->m_writeio_log) \ #define XFS_WRITEIO_ALIGN(mp,off) (((off) >> mp->m_writeio_log) \
...@@ -52,7 +49,6 @@ xfs_iomap_eof_align_last_fsb( ...@@ -52,7 +49,6 @@ xfs_iomap_eof_align_last_fsb(
xfs_extlen_t extsize, xfs_extlen_t extsize,
xfs_fileoff_t *last_fsb) xfs_fileoff_t *last_fsb)
{ {
xfs_fileoff_t new_last_fsb = 0;
xfs_extlen_t align = 0; xfs_extlen_t align = 0;
int eof, error; int eof, error;
...@@ -70,8 +66,8 @@ xfs_iomap_eof_align_last_fsb( ...@@ -70,8 +66,8 @@ xfs_iomap_eof_align_last_fsb(
else if (mp->m_dalign) else if (mp->m_dalign)
align = mp->m_dalign; align = mp->m_dalign;
if (align && XFS_ISIZE(ip) >= XFS_FSB_TO_B(mp, align)) if (align && XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, align))
new_last_fsb = roundup_64(*last_fsb, align); align = 0;
} }
/* /*
...@@ -79,14 +75,14 @@ xfs_iomap_eof_align_last_fsb( ...@@ -79,14 +75,14 @@ xfs_iomap_eof_align_last_fsb(
* (when file on a real-time subvolume or has di_extsize hint). * (when file on a real-time subvolume or has di_extsize hint).
*/ */
if (extsize) { if (extsize) {
if (new_last_fsb) if (align)
align = roundup_64(new_last_fsb, extsize); align = roundup_64(align, extsize);
else else
align = extsize; align = extsize;
new_last_fsb = roundup_64(*last_fsb, align);
} }
if (new_last_fsb) { if (align) {
xfs_fileoff_t new_last_fsb = roundup_64(*last_fsb, align);
error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof); error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof);
if (error) if (error)
return error; return error;
...@@ -264,7 +260,6 @@ xfs_iomap_eof_want_preallocate( ...@@ -264,7 +260,6 @@ xfs_iomap_eof_want_preallocate(
{ {
xfs_fileoff_t start_fsb; xfs_fileoff_t start_fsb;
xfs_filblks_t count_fsb; xfs_filblks_t count_fsb;
xfs_fsblock_t firstblock;
int n, error, imaps; int n, error, imaps;
int found_delalloc = 0; int found_delalloc = 0;
...@@ -289,7 +284,6 @@ xfs_iomap_eof_want_preallocate( ...@@ -289,7 +284,6 @@ xfs_iomap_eof_want_preallocate(
count_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); count_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
while (count_fsb > 0) { while (count_fsb > 0) {
imaps = nimaps; imaps = nimaps;
firstblock = NULLFSBLOCK;
error = xfs_bmapi_read(ip, start_fsb, count_fsb, imap, &imaps, error = xfs_bmapi_read(ip, start_fsb, count_fsb, imap, &imaps,
0); 0);
if (error) if (error)
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_inode.h" #include "xfs_inode.h"
...@@ -37,8 +35,7 @@ ...@@ -37,8 +35,7 @@
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_symlink.h" #include "xfs_symlink.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
#include "xfs_dir2_priv.h" #include "xfs_dir2.h"
#include "xfs_dinode.h"
#include "xfs_trans_space.h" #include "xfs_trans_space.h"
#include <linux/capability.h> #include <linux/capability.h>
......
...@@ -21,9 +21,6 @@ ...@@ -21,9 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_inum.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_btree.h" #include "xfs_btree.h"
...@@ -33,7 +30,6 @@ ...@@ -33,7 +30,6 @@
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_dinode.h"
STATIC int STATIC int
xfs_internal_inum( xfs_internal_inum(
...@@ -352,7 +348,6 @@ xfs_bulkstat( ...@@ -352,7 +348,6 @@ xfs_bulkstat(
int *done) /* 1 if there are more stats to get */ int *done) /* 1 if there are more stats to get */
{ {
xfs_buf_t *agbp; /* agi header buffer */ xfs_buf_t *agbp; /* agi header buffer */
xfs_agi_t *agi; /* agi header data */
xfs_agino_t agino; /* inode # in allocation group */ xfs_agino_t agino; /* inode # in allocation group */
xfs_agnumber_t agno; /* allocation group number */ xfs_agnumber_t agno; /* allocation group number */
xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */ xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */
...@@ -403,7 +398,6 @@ xfs_bulkstat( ...@@ -403,7 +398,6 @@ xfs_bulkstat(
error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp);
if (error) if (error)
break; break;
agi = XFS_BUF_TO_AGI(agbp);
/* /*
* Allocate and initialize a btree cursor for ialloc btree. * Allocate and initialize a btree cursor for ialloc btree.
*/ */
......
...@@ -384,4 +384,10 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) ...@@ -384,4 +384,10 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y)
#endif /* XFS_WARN */ #endif /* XFS_WARN */
#endif /* DEBUG */ #endif /* DEBUG */
#ifdef CONFIG_XFS_RT
#define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
#else
#define XFS_IS_REALTIME_INODE(ip) (0)
#endif
#endif /* __XFS_LINUX__ */ #endif /* __XFS_LINUX__ */
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_trans.h" #include "xfs_trans.h"
...@@ -1031,7 +1029,7 @@ xfs_log_need_covered(xfs_mount_t *mp) ...@@ -1031,7 +1029,7 @@ xfs_log_need_covered(xfs_mount_t *mp)
struct xlog *log = mp->m_log; struct xlog *log = mp->m_log;
int needed = 0; int needed = 0;
if (!xfs_fs_writable(mp)) if (!xfs_fs_writable(mp, SB_FREEZE_WRITE))
return 0; return 0;
if (!xlog_cil_empty(log)) if (!xlog_cil_empty(log))
...@@ -1808,6 +1806,8 @@ xlog_sync( ...@@ -1808,6 +1806,8 @@ xlog_sync(
XFS_BUF_ZEROFLAGS(bp); XFS_BUF_ZEROFLAGS(bp);
XFS_BUF_ASYNC(bp); XFS_BUF_ASYNC(bp);
bp->b_flags |= XBF_SYNCIO; bp->b_flags |= XBF_SYNCIO;
/* use high priority completion wq */
bp->b_ioend_wq = log->l_mp->m_log_workqueue;
if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) { if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) {
bp->b_flags |= XBF_FUA; bp->b_flags |= XBF_FUA;
...@@ -1856,6 +1856,8 @@ xlog_sync( ...@@ -1856,6 +1856,8 @@ xlog_sync(
bp->b_flags |= XBF_SYNCIO; bp->b_flags |= XBF_SYNCIO;
if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) if (log->l_mp->m_flags & XFS_MOUNT_BARRIER)
bp->b_flags |= XBF_FUA; bp->b_flags |= XBF_FUA;
/* use high priority completion wq */
bp->b_ioend_wq = log->l_mp->m_log_workqueue;
ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1); ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1);
ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize); ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize);
......
...@@ -17,11 +17,10 @@ ...@@ -17,11 +17,10 @@
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_shared.h" #include "xfs_shared.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
......
...@@ -22,11 +22,10 @@ ...@@ -22,11 +22,10 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_inum.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_log.h" #include "xfs_log.h"
...@@ -42,7 +41,6 @@ ...@@ -42,7 +41,6 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_dinode.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
......
...@@ -17,10 +17,9 @@ ...@@ -17,10 +17,9 @@
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
/* /*
......
...@@ -22,11 +22,10 @@ ...@@ -22,11 +22,10 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_inum.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_ialloc.h" #include "xfs_ialloc.h"
...@@ -41,7 +40,6 @@ ...@@ -41,7 +40,6 @@
#include "xfs_fsops.h" #include "xfs_fsops.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_dinode.h"
#include "xfs_sysfs.h" #include "xfs_sysfs.h"
...@@ -1074,11 +1072,23 @@ xfs_unmountfs( ...@@ -1074,11 +1072,23 @@ xfs_unmountfs(
xfs_sysfs_del(&mp->m_kobj); xfs_sysfs_del(&mp->m_kobj);
} }
int /*
xfs_fs_writable(xfs_mount_t *mp) * Determine whether modifications can proceed. The caller specifies the minimum
* freeze level for which modifications should not be allowed. This allows
* certain operations to proceed while the freeze sequence is in progress, if
* necessary.
*/
bool
xfs_fs_writable(
struct xfs_mount *mp,
int level)
{ {
return !(mp->m_super->s_writers.frozen || XFS_FORCED_SHUTDOWN(mp) || ASSERT(level > SB_UNFROZEN);
(mp->m_flags & XFS_MOUNT_RDONLY)); if ((mp->m_super->s_writers.frozen >= level) ||
XFS_FORCED_SHUTDOWN(mp) || (mp->m_flags & XFS_MOUNT_RDONLY))
return false;
return true;
} }
/* /*
...@@ -1086,9 +1096,9 @@ xfs_fs_writable(xfs_mount_t *mp) ...@@ -1086,9 +1096,9 @@ xfs_fs_writable(xfs_mount_t *mp)
* *
* Sync the superblock counters to disk. * Sync the superblock counters to disk.
* *
* Note this code can be called during the process of freezing, so * Note this code can be called during the process of freezing, so we use the
* we may need to use the transaction allocator which does not * transaction allocator that does not block when the transaction subsystem is
* block when the transaction subsystem is in its frozen state. * in its frozen state.
*/ */
int int
xfs_log_sbcount(xfs_mount_t *mp) xfs_log_sbcount(xfs_mount_t *mp)
...@@ -1096,7 +1106,8 @@ xfs_log_sbcount(xfs_mount_t *mp) ...@@ -1096,7 +1106,8 @@ xfs_log_sbcount(xfs_mount_t *mp)
xfs_trans_t *tp; xfs_trans_t *tp;
int error; int error;
if (!xfs_fs_writable(mp)) /* allow this to proceed during the freeze sequence... */
if (!xfs_fs_writable(mp, SB_FREEZE_COMPLETE))
return 0; return 0;
xfs_icsb_sync_counters(mp, 0); xfs_icsb_sync_counters(mp, 0);
......
...@@ -168,6 +168,7 @@ typedef struct xfs_mount { ...@@ -168,6 +168,7 @@ typedef struct xfs_mount {
/* low free space thresholds */ /* low free space thresholds */
struct xfs_kobj m_kobj; struct xfs_kobj m_kobj;
struct workqueue_struct *m_buf_workqueue;
struct workqueue_struct *m_data_workqueue; struct workqueue_struct *m_data_workqueue;
struct workqueue_struct *m_unwritten_workqueue; struct workqueue_struct *m_unwritten_workqueue;
struct workqueue_struct *m_cil_workqueue; struct workqueue_struct *m_cil_workqueue;
...@@ -320,10 +321,7 @@ typedef struct xfs_mod_sb { ...@@ -320,10 +321,7 @@ typedef struct xfs_mod_sb {
/* /*
* Per-ag incore structure, copies of information in agf and agi, to improve the * Per-ag incore structure, copies of information in agf and agi, to improve the
* performance of allocation group selection. This is defined for the kernel * performance of allocation group selection.
* only, and hence is defined here instead of in xfs_ag.h. You need the struct
* xfs_mount to be defined to look up a xfs_perag anyway (via mp->m_perag_tree),
* so this doesn't introduce any strange header file dependencies.
*/ */
typedef struct xfs_perag { typedef struct xfs_perag {
struct xfs_mount *pag_mount; /* owner filesystem */ struct xfs_mount *pag_mount; /* owner filesystem */
...@@ -384,7 +382,7 @@ extern int xfs_mount_log_sb(xfs_mount_t *, __int64_t); ...@@ -384,7 +382,7 @@ extern int xfs_mount_log_sb(xfs_mount_t *, __int64_t);
extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
extern int xfs_readsb(xfs_mount_t *, int); extern int xfs_readsb(xfs_mount_t *, int);
extern void xfs_freesb(xfs_mount_t *); extern void xfs_freesb(xfs_mount_t *);
extern int xfs_fs_writable(xfs_mount_t *); extern bool xfs_fs_writable(struct xfs_mount *mp, int level);
extern int xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t); extern int xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t);
extern int xfs_dev_is_read_only(struct xfs_mount *, char *); extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_ialloc.h" #include "xfs_ialloc.h"
...@@ -38,7 +37,6 @@ ...@@ -38,7 +37,6 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_cksum.h" #include "xfs_cksum.h"
#include "xfs_dinode.h"
/* /*
* The global quota manager. There is only one of these for the entire * The global quota manager. There is only one of these for the entire
...@@ -1749,23 +1747,21 @@ xfs_qm_vop_dqalloc( ...@@ -1749,23 +1747,21 @@ xfs_qm_vop_dqalloc(
xfs_iunlock(ip, lockflags); xfs_iunlock(ip, lockflags);
if (O_udqpp) if (O_udqpp)
*O_udqpp = uq; *O_udqpp = uq;
else if (uq) else
xfs_qm_dqrele(uq); xfs_qm_dqrele(uq);
if (O_gdqpp) if (O_gdqpp)
*O_gdqpp = gq; *O_gdqpp = gq;
else if (gq) else
xfs_qm_dqrele(gq); xfs_qm_dqrele(gq);
if (O_pdqpp) if (O_pdqpp)
*O_pdqpp = pq; *O_pdqpp = pq;
else if (pq) else
xfs_qm_dqrele(pq); xfs_qm_dqrele(pq);
return 0; return 0;
error_rele: error_rele:
if (gq) xfs_qm_dqrele(gq);
xfs_qm_dqrele(gq); xfs_qm_dqrele(uq);
if (uq)
xfs_qm_dqrele(uq);
return error; return error;
} }
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
...@@ -784,19 +783,21 @@ xfs_qm_log_quotaoff( ...@@ -784,19 +783,21 @@ xfs_qm_log_quotaoff(
{ {
xfs_trans_t *tp; xfs_trans_t *tp;
int error; int error;
xfs_qoff_logitem_t *qoffi=NULL; xfs_qoff_logitem_t *qoffi;
uint oldsbqflag=0;
*qoffstartp = NULL;
tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF); tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_quotaoff, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_quotaoff, 0, 0);
if (error) if (error) {
goto error0; xfs_trans_cancel(tp, 0);
goto out;
}
qoffi = xfs_trans_get_qoff_item(tp, NULL, flags & XFS_ALL_QUOTA_ACCT); qoffi = xfs_trans_get_qoff_item(tp, NULL, flags & XFS_ALL_QUOTA_ACCT);
xfs_trans_log_quotaoff_item(tp, qoffi); xfs_trans_log_quotaoff_item(tp, qoffi);
spin_lock(&mp->m_sb_lock); spin_lock(&mp->m_sb_lock);
oldsbqflag = mp->m_sb.sb_qflags;
mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL; mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL;
spin_unlock(&mp->m_sb_lock); spin_unlock(&mp->m_sb_lock);
...@@ -809,19 +810,11 @@ xfs_qm_log_quotaoff( ...@@ -809,19 +810,11 @@ xfs_qm_log_quotaoff(
*/ */
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp, 0);
if (error)
goto out;
error0:
if (error) {
xfs_trans_cancel(tp, 0);
/*
* No one else is modifying sb_qflags, so this is OK.
* We still hold the quotaofflock.
*/
spin_lock(&mp->m_sb_lock);
mp->m_sb.sb_qflags = oldsbqflag;
spin_unlock(&mp->m_sb_lock);
}
*qoffstartp = qoffi; *qoffstartp = qoffi;
out:
return error; return error;
} }
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_quota.h" #include "xfs_quota.h"
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
...@@ -36,7 +34,6 @@ ...@@ -36,7 +34,6 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_buf.h" #include "xfs_buf.h"
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_dinode.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
......
...@@ -21,9 +21,7 @@ ...@@ -21,9 +21,7 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_inum.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_inode.h" #include "xfs_inode.h"
...@@ -44,7 +42,6 @@ ...@@ -44,7 +42,6 @@
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_icreate_item.h" #include "xfs_icreate_item.h"
#include "xfs_dinode.h"
#include "xfs_filestream.h" #include "xfs_filestream.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_sysfs.h" #include "xfs_sysfs.h"
...@@ -796,8 +793,7 @@ xfs_open_devices( ...@@ -796,8 +793,7 @@ xfs_open_devices(
out_free_ddev_targ: out_free_ddev_targ:
xfs_free_buftarg(mp, mp->m_ddev_targp); xfs_free_buftarg(mp, mp->m_ddev_targp);
out_close_rtdev: out_close_rtdev:
if (rtdev) xfs_blkdev_put(rtdev);
xfs_blkdev_put(rtdev);
out_close_logdev: out_close_logdev:
if (logdev && logdev != ddev) if (logdev && logdev != ddev)
xfs_blkdev_put(logdev); xfs_blkdev_put(logdev);
...@@ -842,10 +838,15 @@ STATIC int ...@@ -842,10 +838,15 @@ STATIC int
xfs_init_mount_workqueues( xfs_init_mount_workqueues(
struct xfs_mount *mp) struct xfs_mount *mp)
{ {
mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s",
WQ_MEM_RECLAIM|WQ_FREEZABLE, 1, mp->m_fsname);
if (!mp->m_buf_workqueue)
goto out;
mp->m_data_workqueue = alloc_workqueue("xfs-data/%s", mp->m_data_workqueue = alloc_workqueue("xfs-data/%s",
WQ_MEM_RECLAIM|WQ_FREEZABLE, 0, mp->m_fsname); WQ_MEM_RECLAIM|WQ_FREEZABLE, 0, mp->m_fsname);
if (!mp->m_data_workqueue) if (!mp->m_data_workqueue)
goto out; goto out_destroy_buf;
mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s", mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s",
WQ_MEM_RECLAIM|WQ_FREEZABLE, 0, mp->m_fsname); WQ_MEM_RECLAIM|WQ_FREEZABLE, 0, mp->m_fsname);
...@@ -863,7 +864,7 @@ xfs_init_mount_workqueues( ...@@ -863,7 +864,7 @@ xfs_init_mount_workqueues(
goto out_destroy_cil; goto out_destroy_cil;
mp->m_log_workqueue = alloc_workqueue("xfs-log/%s", mp->m_log_workqueue = alloc_workqueue("xfs-log/%s",
WQ_FREEZABLE, 0, mp->m_fsname); WQ_FREEZABLE|WQ_HIGHPRI, 0, mp->m_fsname);
if (!mp->m_log_workqueue) if (!mp->m_log_workqueue)
goto out_destroy_reclaim; goto out_destroy_reclaim;
...@@ -884,6 +885,8 @@ xfs_init_mount_workqueues( ...@@ -884,6 +885,8 @@ xfs_init_mount_workqueues(
destroy_workqueue(mp->m_unwritten_workqueue); destroy_workqueue(mp->m_unwritten_workqueue);
out_destroy_data_iodone_queue: out_destroy_data_iodone_queue:
destroy_workqueue(mp->m_data_workqueue); destroy_workqueue(mp->m_data_workqueue);
out_destroy_buf:
destroy_workqueue(mp->m_buf_workqueue);
out: out:
return -ENOMEM; return -ENOMEM;
} }
...@@ -898,6 +901,7 @@ xfs_destroy_mount_workqueues( ...@@ -898,6 +901,7 @@ xfs_destroy_mount_workqueues(
destroy_workqueue(mp->m_cil_workqueue); destroy_workqueue(mp->m_cil_workqueue);
destroy_workqueue(mp->m_data_workqueue); destroy_workqueue(mp->m_data_workqueue);
destroy_workqueue(mp->m_unwritten_workqueue); destroy_workqueue(mp->m_unwritten_workqueue);
destroy_workqueue(mp->m_buf_workqueue);
} }
/* /*
...@@ -1000,7 +1004,6 @@ xfs_fs_evict_inode( ...@@ -1000,7 +1004,6 @@ xfs_fs_evict_inode(
clear_inode(inode); clear_inode(inode);
XFS_STATS_INC(vn_rele); XFS_STATS_INC(vn_rele);
XFS_STATS_INC(vn_remove); XFS_STATS_INC(vn_remove);
XFS_STATS_DEC(vn_active);
xfs_inactive(ip); xfs_inactive(ip);
} }
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
...@@ -42,7 +40,6 @@ ...@@ -42,7 +40,6 @@
#include "xfs_symlink.h" #include "xfs_symlink.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_dinode.h"
/* ----- Kernel only functions below ----- */ /* ----- Kernel only functions below ----- */
STATIC int STATIC int
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_inode.h" #include "xfs_inode.h"
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_extent_busy.h" #include "xfs_extent_busy.h"
......
...@@ -18,10 +18,9 @@ ...@@ -18,10 +18,9 @@
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_trans_priv.h" #include "xfs_trans_priv.h"
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
...@@ -229,13 +227,6 @@ xfs_trans_getsb(xfs_trans_t *tp, ...@@ -229,13 +227,6 @@ xfs_trans_getsb(xfs_trans_t *tp,
return bp; return bp;
} }
#ifdef DEBUG
xfs_buftarg_t *xfs_error_target;
int xfs_do_error;
int xfs_req_num;
int xfs_error_mod = 33;
#endif
/* /*
* Get and lock the buffer for the caller if it is not already * Get and lock the buffer for the caller if it is not already
* locked within the given transaction. If it has not yet been * locked within the given transaction. If it has not yet been
...@@ -257,46 +248,11 @@ xfs_trans_read_buf_map( ...@@ -257,46 +248,11 @@ xfs_trans_read_buf_map(
struct xfs_buf **bpp, struct xfs_buf **bpp,
const struct xfs_buf_ops *ops) const struct xfs_buf_ops *ops)
{ {
xfs_buf_t *bp; struct xfs_buf *bp = NULL;
xfs_buf_log_item_t *bip; struct xfs_buf_log_item *bip;
int error; int error;
*bpp = NULL; *bpp = NULL;
if (!tp) {
bp = xfs_buf_read_map(target, map, nmaps, flags, ops);
if (!bp)
return (flags & XBF_TRYLOCK) ?
-EAGAIN : -ENOMEM;
if (bp->b_error) {
error = bp->b_error;
xfs_buf_ioerror_alert(bp, __func__);
XFS_BUF_UNDONE(bp);
xfs_buf_stale(bp);
xfs_buf_relse(bp);
/* bad CRC means corrupted metadata */
if (error == -EFSBADCRC)
error = -EFSCORRUPTED;
return error;
}
#ifdef DEBUG
if (xfs_do_error) {
if (xfs_error_target == target) {
if (((xfs_req_num++) % xfs_error_mod) == 0) {
xfs_buf_relse(bp);
xfs_debug(mp, "Returning error!");
return -EIO;
}
}
}
#endif
if (XFS_FORCED_SHUTDOWN(mp))
goto shutdown_abort;
*bpp = bp;
return 0;
}
/* /*
* If we find the buffer in the cache with this transaction * If we find the buffer in the cache with this transaction
* pointer in its b_fsprivate2 field, then we know we already * pointer in its b_fsprivate2 field, then we know we already
...@@ -305,49 +261,24 @@ xfs_trans_read_buf_map( ...@@ -305,49 +261,24 @@ xfs_trans_read_buf_map(
* If the buffer is not yet read in, then we read it in, increment * If the buffer is not yet read in, then we read it in, increment
* the lock recursion count, and return it to the caller. * the lock recursion count, and return it to the caller.
*/ */
bp = xfs_trans_buf_item_match(tp, target, map, nmaps); if (tp)
if (bp != NULL) { bp = xfs_trans_buf_item_match(tp, target, map, nmaps);
if (bp) {
ASSERT(xfs_buf_islocked(bp)); ASSERT(xfs_buf_islocked(bp));
ASSERT(bp->b_transp == tp); ASSERT(bp->b_transp == tp);
ASSERT(bp->b_fspriv != NULL); ASSERT(bp->b_fspriv != NULL);
ASSERT(!bp->b_error); ASSERT(!bp->b_error);
if (!(XFS_BUF_ISDONE(bp))) { ASSERT(bp->b_flags & XBF_DONE);
trace_xfs_trans_read_buf_io(bp, _RET_IP_);
ASSERT(!XFS_BUF_ISASYNC(bp));
ASSERT(bp->b_iodone == NULL);
XFS_BUF_READ(bp);
bp->b_ops = ops;
error = xfs_buf_submit_wait(bp);
if (error) {
if (!XFS_FORCED_SHUTDOWN(mp))
xfs_buf_ioerror_alert(bp, __func__);
xfs_buf_relse(bp);
/*
* We can gracefully recover from most read
* errors. Ones we can't are those that happen
* after the transaction's already dirty.
*/
if (tp->t_flags & XFS_TRANS_DIRTY)
xfs_force_shutdown(tp->t_mountp,
SHUTDOWN_META_IO_ERROR);
/* bad CRC means corrupted metadata */
if (error == -EFSBADCRC)
error = -EFSCORRUPTED;
return error;
}
}
/* /*
* We never locked this buf ourselves, so we shouldn't * We never locked this buf ourselves, so we shouldn't
* brelse it either. Just get out. * brelse it either. Just get out.
*/ */
if (XFS_FORCED_SHUTDOWN(mp)) { if (XFS_FORCED_SHUTDOWN(mp)) {
trace_xfs_trans_read_buf_shut(bp, _RET_IP_); trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
*bpp = NULL;
return -EIO; return -EIO;
} }
bip = bp->b_fspriv; bip = bp->b_fspriv;
bip->bli_recur++; bip->bli_recur++;
...@@ -358,17 +289,29 @@ xfs_trans_read_buf_map( ...@@ -358,17 +289,29 @@ xfs_trans_read_buf_map(
} }
bp = xfs_buf_read_map(target, map, nmaps, flags, ops); bp = xfs_buf_read_map(target, map, nmaps, flags, ops);
if (bp == NULL) { if (!bp) {
*bpp = NULL; if (!(flags & XBF_TRYLOCK))
return (flags & XBF_TRYLOCK) ? return -ENOMEM;
0 : -ENOMEM; return tp ? 0 : -EAGAIN;
} }
/*
* If we've had a read error, then the contents of the buffer are
* invalid and should not be used. To ensure that a followup read tries
* to pull the buffer from disk again, we clear the XBF_DONE flag and
* mark the buffer stale. This ensures that anyone who has a current
* reference to the buffer will interpret it's contents correctly and
* future cache lookups will also treat it as an empty, uninitialised
* buffer.
*/
if (bp->b_error) { if (bp->b_error) {
error = bp->b_error; error = bp->b_error;
if (!XFS_FORCED_SHUTDOWN(mp))
xfs_buf_ioerror_alert(bp, __func__);
bp->b_flags &= ~XBF_DONE;
xfs_buf_stale(bp); xfs_buf_stale(bp);
XFS_BUF_DONE(bp);
xfs_buf_ioerror_alert(bp, __func__); if (tp && (tp->t_flags & XFS_TRANS_DIRTY))
if (tp->t_flags & XFS_TRANS_DIRTY)
xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR); xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR);
xfs_buf_relse(bp); xfs_buf_relse(bp);
...@@ -377,33 +320,19 @@ xfs_trans_read_buf_map( ...@@ -377,33 +320,19 @@ xfs_trans_read_buf_map(
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
return error; return error;
} }
#ifdef DEBUG
if (xfs_do_error && !(tp->t_flags & XFS_TRANS_DIRTY)) { if (XFS_FORCED_SHUTDOWN(mp)) {
if (xfs_error_target == target) { xfs_buf_relse(bp);
if (((xfs_req_num++) % xfs_error_mod) == 0) { trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
xfs_force_shutdown(tp->t_mountp, return -EIO;
SHUTDOWN_META_IO_ERROR);
xfs_buf_relse(bp);
xfs_debug(mp, "Returning trans error!");
return -EIO;
}
}
} }
#endif
if (XFS_FORCED_SHUTDOWN(mp))
goto shutdown_abort;
_xfs_trans_bjoin(tp, bp, 1); if (tp)
_xfs_trans_bjoin(tp, bp, 1);
trace_xfs_trans_read_buf(bp->b_fspriv); trace_xfs_trans_read_buf(bp->b_fspriv);
*bpp = bp; *bpp = bp;
return 0; return 0;
shutdown_abort:
trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
xfs_buf_relse(bp);
*bpp = NULL;
return -EIO;
} }
/* /*
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_error.h" #include "xfs_error.h"
......
...@@ -18,10 +18,9 @@ ...@@ -18,10 +18,9 @@
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_shared.h" #include "xfs_shared.h"
#include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_trans_priv.h" #include "xfs_trans_priv.h"
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include "xfs_format.h" #include "xfs_format.h"
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h" #include "xfs_da_format.h"
#include "xfs_inode.h" #include "xfs_inode.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册