diff options
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 3ef145307274..ed094749851b 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -4607,13 +4607,13 @@ xfs_bmapi_delay( | |||
4607 | STATIC int | 4607 | STATIC int |
4608 | xfs_bmapi_allocate( | 4608 | xfs_bmapi_allocate( |
4609 | struct xfs_bmalloca *bma, | 4609 | struct xfs_bmalloca *bma, |
4610 | int flags, | 4610 | int flags) |
4611 | int *logflags) | ||
4612 | { | 4611 | { |
4613 | struct xfs_mount *mp = bma->ip->i_mount; | 4612 | struct xfs_mount *mp = bma->ip->i_mount; |
4614 | int whichfork = (flags & XFS_BMAPI_ATTRFORK) ? | 4613 | int whichfork = (flags & XFS_BMAPI_ATTRFORK) ? |
4615 | XFS_ATTR_FORK : XFS_DATA_FORK; | 4614 | XFS_ATTR_FORK : XFS_DATA_FORK; |
4616 | struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); | 4615 | struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); |
4616 | int tmp_logflags = 0; | ||
4617 | int error; | 4617 | int error; |
4618 | int rt; | 4618 | int rt; |
4619 | 4619 | ||
@@ -4700,14 +4700,15 @@ xfs_bmapi_allocate( | |||
4700 | if (bma->wasdel) { | 4700 | if (bma->wasdel) { |
4701 | error = xfs_bmap_add_extent_delay_real(bma->tp, bma->ip, | 4701 | error = xfs_bmap_add_extent_delay_real(bma->tp, bma->ip, |
4702 | &bma->idx, &bma->cur, &bma->got, | 4702 | &bma->idx, &bma->cur, &bma->got, |
4703 | bma->firstblock, bma->flist, logflags); | 4703 | bma->firstblock, bma->flist, &tmp_logflags); |
4704 | } else { | 4704 | } else { |
4705 | error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, | 4705 | error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, |
4706 | &bma->idx, &bma->cur, &bma->got, | 4706 | &bma->idx, &bma->cur, &bma->got, |
4707 | bma->firstblock, bma->flist, logflags, | 4707 | bma->firstblock, bma->flist, &tmp_logflags, |
4708 | whichfork); | 4708 | whichfork); |
4709 | } | 4709 | } |
4710 | 4710 | ||
4711 | bma->logflags |= tmp_logflags; | ||
4711 | if (error) | 4712 | if (error) |
4712 | return error; | 4713 | return error; |
4713 | 4714 | ||
@@ -4731,16 +4732,14 @@ xfs_bmapi_convert_unwritten( | |||
4731 | struct xfs_bmalloca *bma, | 4732 | struct xfs_bmalloca *bma, |
4732 | struct xfs_bmbt_irec *mval, | 4733 | struct xfs_bmbt_irec *mval, |
4733 | xfs_filblks_t len, | 4734 | xfs_filblks_t len, |
4734 | int flags, | 4735 | int flags) |
4735 | int *logflags) | ||
4736 | { | 4736 | { |
4737 | int whichfork = (flags & XFS_BMAPI_ATTRFORK) ? | 4737 | int whichfork = (flags & XFS_BMAPI_ATTRFORK) ? |
4738 | XFS_ATTR_FORK : XFS_DATA_FORK; | 4738 | XFS_ATTR_FORK : XFS_DATA_FORK; |
4739 | struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); | 4739 | struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); |
4740 | int tmp_logflags = 0; | ||
4740 | int error; | 4741 | int error; |
4741 | 4742 | ||
4742 | *logflags = 0; | ||
4743 | |||
4744 | /* check if we need to do unwritten->real conversion */ | 4743 | /* check if we need to do unwritten->real conversion */ |
4745 | if (mval->br_state == XFS_EXT_UNWRITTEN && | 4744 | if (mval->br_state == XFS_EXT_UNWRITTEN && |
4746 | (flags & XFS_BMAPI_PREALLOC)) | 4745 | (flags & XFS_BMAPI_PREALLOC)) |
@@ -4766,7 +4765,9 @@ xfs_bmapi_convert_unwritten( | |||
4766 | ? XFS_EXT_NORM : XFS_EXT_UNWRITTEN; | 4765 | ? XFS_EXT_NORM : XFS_EXT_UNWRITTEN; |
4767 | 4766 | ||
4768 | error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, &bma->idx, | 4767 | error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, &bma->idx, |
4769 | &bma->cur, mval, bma->firstblock, bma->flist, logflags); | 4768 | &bma->cur, mval, bma->firstblock, bma->flist, |
4769 | &tmp_logflags); | ||
4770 | bma->logflags |= tmp_logflags; | ||
4770 | if (error) | 4771 | if (error) |
4771 | return error; | 4772 | return error; |
4772 | 4773 | ||
@@ -4818,10 +4819,8 @@ xfs_bmapi_write( | |||
4818 | xfs_fileoff_t end; /* end of mapped file region */ | 4819 | xfs_fileoff_t end; /* end of mapped file region */ |
4819 | int eof; /* after the end of extents */ | 4820 | int eof; /* after the end of extents */ |
4820 | int error; /* error return */ | 4821 | int error; /* error return */ |
4821 | int logflags; /* flags for transaction logging */ | ||
4822 | int n; /* current extent index */ | 4822 | int n; /* current extent index */ |
4823 | xfs_fileoff_t obno; /* old block number (offset) */ | 4823 | xfs_fileoff_t obno; /* old block number (offset) */ |
4824 | int tmp_logflags; /* temp flags holder */ | ||
4825 | int whichfork; /* data or attr fork */ | 4824 | int whichfork; /* data or attr fork */ |
4826 | char inhole; /* current location is hole in file */ | 4825 | char inhole; /* current location is hole in file */ |
4827 | char wasdelay; /* old extent was delayed */ | 4826 | char wasdelay; /* old extent was delayed */ |
@@ -4866,11 +4865,9 @@ xfs_bmapi_write( | |||
4866 | 4865 | ||
4867 | XFS_STATS_INC(xs_blk_mapw); | 4866 | XFS_STATS_INC(xs_blk_mapw); |
4868 | 4867 | ||
4869 | logflags = 0; | ||
4870 | |||
4871 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { | 4868 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { |
4872 | error = xfs_bmap_local_to_extents(tp, ip, firstblock, total, | 4869 | error = xfs_bmap_local_to_extents(tp, ip, firstblock, total, |
4873 | &logflags, whichfork); | 4870 | &bma.logflags, whichfork); |
4874 | if (error) | 4871 | if (error) |
4875 | goto error0; | 4872 | goto error0; |
4876 | } | 4873 | } |
@@ -4918,8 +4915,7 @@ xfs_bmapi_write( | |||
4918 | bma.length = len; | 4915 | bma.length = len; |
4919 | bma.offset = bno; | 4916 | bma.offset = bno; |
4920 | 4917 | ||
4921 | error = xfs_bmapi_allocate(&bma, flags, &tmp_logflags); | 4918 | error = xfs_bmapi_allocate(&bma, flags); |
4922 | logflags |= tmp_logflags; | ||
4923 | if (error) | 4919 | if (error) |
4924 | goto error0; | 4920 | goto error0; |
4925 | if (bma.blkno == NULLFSBLOCK) | 4921 | if (bma.blkno == NULLFSBLOCK) |
@@ -4931,9 +4927,7 @@ xfs_bmapi_write( | |||
4931 | end, n, flags); | 4927 | end, n, flags); |
4932 | 4928 | ||
4933 | /* Execute unwritten extent conversion if necessary */ | 4929 | /* Execute unwritten extent conversion if necessary */ |
4934 | error = xfs_bmapi_convert_unwritten(&bma, mval, len, | 4930 | error = xfs_bmapi_convert_unwritten(&bma, mval, len, flags); |
4935 | flags, &tmp_logflags); | ||
4936 | logflags |= tmp_logflags; | ||
4937 | if (error == EAGAIN) | 4931 | if (error == EAGAIN) |
4938 | continue; | 4932 | continue; |
4939 | if (error) | 4933 | if (error) |
@@ -4965,10 +4959,12 @@ xfs_bmapi_write( | |||
4965 | */ | 4959 | */ |
4966 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE && | 4960 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE && |
4967 | XFS_IFORK_NEXTENTS(ip, whichfork) <= ifp->if_ext_max) { | 4961 | XFS_IFORK_NEXTENTS(ip, whichfork) <= ifp->if_ext_max) { |
4962 | int tmp_logflags = 0; | ||
4963 | |||
4968 | ASSERT(bma.cur); | 4964 | ASSERT(bma.cur); |
4969 | error = xfs_bmap_btree_to_extents(tp, ip, bma.cur, | 4965 | error = xfs_bmap_btree_to_extents(tp, ip, bma.cur, |
4970 | &tmp_logflags, whichfork); | 4966 | &tmp_logflags, whichfork); |
4971 | logflags |= tmp_logflags; | 4967 | bma.logflags |= tmp_logflags; |
4972 | if (error) | 4968 | if (error) |
4973 | goto error0; | 4969 | goto error0; |
4974 | } | 4970 | } |
@@ -4982,19 +4978,19 @@ error0: | |||
4982 | * Log everything. Do this after conversion, there's no point in | 4978 | * Log everything. Do this after conversion, there's no point in |
4983 | * logging the extent records if we've converted to btree format. | 4979 | * logging the extent records if we've converted to btree format. |
4984 | */ | 4980 | */ |
4985 | if ((logflags & xfs_ilog_fext(whichfork)) && | 4981 | if ((bma.logflags & xfs_ilog_fext(whichfork)) && |
4986 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) | 4982 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) |
4987 | logflags &= ~xfs_ilog_fext(whichfork); | 4983 | bma.logflags &= ~xfs_ilog_fext(whichfork); |
4988 | else if ((logflags & xfs_ilog_fbroot(whichfork)) && | 4984 | else if ((bma.logflags & xfs_ilog_fbroot(whichfork)) && |
4989 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE) | 4985 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE) |
4990 | logflags &= ~xfs_ilog_fbroot(whichfork); | 4986 | bma.logflags &= ~xfs_ilog_fbroot(whichfork); |
4991 | /* | 4987 | /* |
4992 | * Log whatever the flags say, even if error. Otherwise we might miss | 4988 | * Log whatever the flags say, even if error. Otherwise we might miss |
4993 | * detecting a case where the data is changed, there's an error, | 4989 | * detecting a case where the data is changed, there's an error, |
4994 | * and it's not logged so we don't shutdown when we should. | 4990 | * and it's not logged so we don't shutdown when we should. |
4995 | */ | 4991 | */ |
4996 | if (logflags) | 4992 | if (bma.logflags) |
4997 | xfs_trans_log_inode(tp, ip, logflags); | 4993 | xfs_trans_log_inode(tp, ip, bma.logflags); |
4998 | 4994 | ||
4999 | if (bma.cur) { | 4995 | if (bma.cur) { |
5000 | if (!error) { | 4996 | if (!error) { |