diff options
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_iops.c | 16 | ||||
-rw-r--r-- | fs/xfs/xfs_log_cil.c | 19 | ||||
-rw-r--r-- | fs/xfs/xfs_mount.c | 24 | ||||
-rw-r--r-- | fs/xfs/xfs_sb.c | 10 |
4 files changed, 43 insertions, 26 deletions
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index f35d5c953ff9..9ddfb8190ca1 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c | |||
@@ -705,7 +705,6 @@ xfs_setattr_size( | |||
705 | { | 705 | { |
706 | struct xfs_mount *mp = ip->i_mount; | 706 | struct xfs_mount *mp = ip->i_mount; |
707 | struct inode *inode = VFS_I(ip); | 707 | struct inode *inode = VFS_I(ip); |
708 | int mask = iattr->ia_valid; | ||
709 | xfs_off_t oldsize, newsize; | 708 | xfs_off_t oldsize, newsize; |
710 | struct xfs_trans *tp; | 709 | struct xfs_trans *tp; |
711 | int error; | 710 | int error; |
@@ -726,8 +725,8 @@ xfs_setattr_size( | |||
726 | 725 | ||
727 | ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); | 726 | ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); |
728 | ASSERT(S_ISREG(ip->i_d.di_mode)); | 727 | ASSERT(S_ISREG(ip->i_d.di_mode)); |
729 | ASSERT((mask & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET| | 728 | ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET| |
730 | ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0); | 729 | ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0); |
731 | 730 | ||
732 | oldsize = inode->i_size; | 731 | oldsize = inode->i_size; |
733 | newsize = iattr->ia_size; | 732 | newsize = iattr->ia_size; |
@@ -736,7 +735,7 @@ xfs_setattr_size( | |||
736 | * Short circuit the truncate case for zero length files. | 735 | * Short circuit the truncate case for zero length files. |
737 | */ | 736 | */ |
738 | if (newsize == 0 && oldsize == 0 && ip->i_d.di_nextents == 0) { | 737 | if (newsize == 0 && oldsize == 0 && ip->i_d.di_nextents == 0) { |
739 | if (!(mask & (ATTR_CTIME|ATTR_MTIME))) | 738 | if (!(iattr->ia_valid & (ATTR_CTIME|ATTR_MTIME))) |
740 | return 0; | 739 | return 0; |
741 | 740 | ||
742 | /* | 741 | /* |
@@ -824,10 +823,11 @@ xfs_setattr_size( | |||
824 | * these flags set. For all other operations the VFS set these flags | 823 | * these flags set. For all other operations the VFS set these flags |
825 | * explicitly if it wants a timestamp update. | 824 | * explicitly if it wants a timestamp update. |
826 | */ | 825 | */ |
827 | if (newsize != oldsize && (!(mask & (ATTR_CTIME | ATTR_MTIME)))) { | 826 | if (newsize != oldsize && |
827 | !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) { | ||
828 | iattr->ia_ctime = iattr->ia_mtime = | 828 | iattr->ia_ctime = iattr->ia_mtime = |
829 | current_fs_time(inode->i_sb); | 829 | current_fs_time(inode->i_sb); |
830 | mask |= ATTR_CTIME | ATTR_MTIME; | 830 | iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME; |
831 | } | 831 | } |
832 | 832 | ||
833 | /* | 833 | /* |
@@ -863,9 +863,9 @@ xfs_setattr_size( | |||
863 | xfs_inode_clear_eofblocks_tag(ip); | 863 | xfs_inode_clear_eofblocks_tag(ip); |
864 | } | 864 | } |
865 | 865 | ||
866 | if (mask & ATTR_MODE) | 866 | if (iattr->ia_valid & ATTR_MODE) |
867 | xfs_setattr_mode(ip, iattr); | 867 | xfs_setattr_mode(ip, iattr); |
868 | if (mask & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME)) | 868 | if (iattr->ia_valid & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME)) |
869 | xfs_setattr_time(ip, iattr); | 869 | xfs_setattr_time(ip, iattr); |
870 | 870 | ||
871 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 871 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index f034cbd958e4..b57a8e08b3d1 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c | |||
@@ -205,16 +205,25 @@ xlog_cil_insert_format_items( | |||
205 | /* | 205 | /* |
206 | * We 64-bit align the length of each iovec so that the start | 206 | * We 64-bit align the length of each iovec so that the start |
207 | * of the next one is naturally aligned. We'll need to | 207 | * of the next one is naturally aligned. We'll need to |
208 | * account for that slack space here. | 208 | * account for that slack space here. Then round nbytes up |
209 | * to 64-bit alignment so that the initial buffer alignment is | ||
210 | * easy to calculate and verify. | ||
209 | */ | 211 | */ |
210 | nbytes += niovecs * sizeof(uint64_t); | 212 | nbytes += niovecs * sizeof(uint64_t); |
213 | nbytes = round_up(nbytes, sizeof(uint64_t)); | ||
211 | 214 | ||
212 | /* grab the old item if it exists for reservation accounting */ | 215 | /* grab the old item if it exists for reservation accounting */ |
213 | old_lv = lip->li_lv; | 216 | old_lv = lip->li_lv; |
214 | 217 | ||
215 | /* calc buffer size */ | 218 | /* |
216 | buf_size = sizeof(struct xfs_log_vec) + nbytes + | 219 | * The data buffer needs to start 64-bit aligned, so round up |
217 | niovecs * sizeof(struct xfs_log_iovec); | 220 | * that space to ensure we can align it appropriately and not |
221 | * overrun the buffer. | ||
222 | */ | ||
223 | buf_size = nbytes + | ||
224 | round_up((sizeof(struct xfs_log_vec) + | ||
225 | niovecs * sizeof(struct xfs_log_iovec)), | ||
226 | sizeof(uint64_t)); | ||
218 | 227 | ||
219 | /* compare to existing item size */ | 228 | /* compare to existing item size */ |
220 | if (lip->li_lv && buf_size <= lip->li_lv->lv_size) { | 229 | if (lip->li_lv && buf_size <= lip->li_lv->lv_size) { |
@@ -251,6 +260,8 @@ xlog_cil_insert_format_items( | |||
251 | /* The allocated data region lies beyond the iovec region */ | 260 | /* The allocated data region lies beyond the iovec region */ |
252 | lv->lv_buf_len = 0; | 261 | lv->lv_buf_len = 0; |
253 | lv->lv_buf = (char *)lv + buf_size - nbytes; | 262 | lv->lv_buf = (char *)lv + buf_size - nbytes; |
263 | ASSERT(IS_ALIGNED((unsigned long)lv->lv_buf, sizeof(uint64_t))); | ||
264 | |||
254 | lip->li_ops->iop_format(lip, lv); | 265 | lip->li_ops->iop_format(lip, lv); |
255 | insert: | 266 | insert: |
256 | ASSERT(lv->lv_buf_len <= nbytes); | 267 | ASSERT(lv->lv_buf_len <= nbytes); |
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 02df7b408a26..f96c05669a9e 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -282,22 +282,29 @@ xfs_readsb( | |||
282 | struct xfs_sb *sbp = &mp->m_sb; | 282 | struct xfs_sb *sbp = &mp->m_sb; |
283 | int error; | 283 | int error; |
284 | int loud = !(flags & XFS_MFSI_QUIET); | 284 | int loud = !(flags & XFS_MFSI_QUIET); |
285 | const struct xfs_buf_ops *buf_ops; | ||
285 | 286 | ||
286 | ASSERT(mp->m_sb_bp == NULL); | 287 | ASSERT(mp->m_sb_bp == NULL); |
287 | ASSERT(mp->m_ddev_targp != NULL); | 288 | ASSERT(mp->m_ddev_targp != NULL); |
288 | 289 | ||
289 | /* | 290 | /* |
291 | * For the initial read, we must guess at the sector | ||
292 | * size based on the block device. It's enough to | ||
293 | * get the sb_sectsize out of the superblock and | ||
294 | * then reread with the proper length. | ||
295 | * We don't verify it yet, because it may not be complete. | ||
296 | */ | ||
297 | sector_size = xfs_getsize_buftarg(mp->m_ddev_targp); | ||
298 | buf_ops = NULL; | ||
299 | |||
300 | /* | ||
290 | * Allocate a (locked) buffer to hold the superblock. | 301 | * Allocate a (locked) buffer to hold the superblock. |
291 | * This will be kept around at all times to optimize | 302 | * This will be kept around at all times to optimize |
292 | * access to the superblock. | 303 | * access to the superblock. |
293 | */ | 304 | */ |
294 | sector_size = xfs_getsize_buftarg(mp->m_ddev_targp); | ||
295 | |||
296 | reread: | 305 | reread: |
297 | bp = xfs_buf_read_uncached(mp->m_ddev_targp, XFS_SB_DADDR, | 306 | bp = xfs_buf_read_uncached(mp->m_ddev_targp, XFS_SB_DADDR, |
298 | BTOBB(sector_size), 0, | 307 | BTOBB(sector_size), 0, buf_ops); |
299 | loud ? &xfs_sb_buf_ops | ||
300 | : &xfs_sb_quiet_buf_ops); | ||
301 | if (!bp) { | 308 | if (!bp) { |
302 | if (loud) | 309 | if (loud) |
303 | xfs_warn(mp, "SB buffer read failed"); | 310 | xfs_warn(mp, "SB buffer read failed"); |
@@ -328,12 +335,13 @@ reread: | |||
328 | } | 335 | } |
329 | 336 | ||
330 | /* | 337 | /* |
331 | * If device sector size is smaller than the superblock size, | 338 | * Re-read the superblock so the buffer is correctly sized, |
332 | * re-read the superblock so the buffer is correctly sized. | 339 | * and properly verified. |
333 | */ | 340 | */ |
334 | if (sector_size < sbp->sb_sectsize) { | 341 | if (buf_ops == NULL) { |
335 | xfs_buf_relse(bp); | 342 | xfs_buf_relse(bp); |
336 | sector_size = sbp->sb_sectsize; | 343 | sector_size = sbp->sb_sectsize; |
344 | buf_ops = loud ? &xfs_sb_buf_ops : &xfs_sb_quiet_buf_ops; | ||
337 | goto reread; | 345 | goto reread; |
338 | } | 346 | } |
339 | 347 | ||
diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/xfs_sb.c index 511cce9359bb..75161a2060fb 100644 --- a/fs/xfs/xfs_sb.c +++ b/fs/xfs/xfs_sb.c | |||
@@ -296,8 +296,7 @@ xfs_mount_validate_sb( | |||
296 | sbp->sb_dblocks == 0 || | 296 | sbp->sb_dblocks == 0 || |
297 | sbp->sb_dblocks > XFS_MAX_DBLOCKS(sbp) || | 297 | sbp->sb_dblocks > XFS_MAX_DBLOCKS(sbp) || |
298 | sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp))) { | 298 | sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp))) { |
299 | XFS_CORRUPTION_ERROR("SB sanity check failed", | 299 | xfs_notice(mp, "SB sanity check failed"); |
300 | XFS_ERRLEVEL_LOW, mp, sbp); | ||
301 | return XFS_ERROR(EFSCORRUPTED); | 300 | return XFS_ERROR(EFSCORRUPTED); |
302 | } | 301 | } |
303 | 302 | ||
@@ -612,10 +611,10 @@ xfs_sb_read_verify( | |||
612 | XFS_SB_VERSION_5) || | 611 | XFS_SB_VERSION_5) || |
613 | dsb->sb_crc != 0)) { | 612 | dsb->sb_crc != 0)) { |
614 | 613 | ||
615 | if (!xfs_verify_cksum(bp->b_addr, be16_to_cpu(dsb->sb_sectsize), | 614 | if (!xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), |
616 | offsetof(struct xfs_sb, sb_crc))) { | 615 | offsetof(struct xfs_sb, sb_crc))) { |
617 | /* Only fail bad secondaries on a known V5 filesystem */ | 616 | /* Only fail bad secondaries on a known V5 filesystem */ |
618 | if (bp->b_bn != XFS_SB_DADDR && | 617 | if (bp->b_bn == XFS_SB_DADDR || |
619 | xfs_sb_version_hascrc(&mp->m_sb)) { | 618 | xfs_sb_version_hascrc(&mp->m_sb)) { |
620 | error = EFSCORRUPTED; | 619 | error = EFSCORRUPTED; |
621 | goto out_error; | 620 | goto out_error; |
@@ -626,7 +625,7 @@ xfs_sb_read_verify( | |||
626 | 625 | ||
627 | out_error: | 626 | out_error: |
628 | if (error) { | 627 | if (error) { |
629 | if (error != EWRONGFS) | 628 | if (error == EFSCORRUPTED) |
630 | XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, | 629 | XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, |
631 | mp, bp->b_addr); | 630 | mp, bp->b_addr); |
632 | xfs_buf_ioerror(bp, error); | 631 | xfs_buf_ioerror(bp, error); |
@@ -645,7 +644,6 @@ xfs_sb_quiet_read_verify( | |||
645 | { | 644 | { |
646 | struct xfs_dsb *dsb = XFS_BUF_TO_SBP(bp); | 645 | struct xfs_dsb *dsb = XFS_BUF_TO_SBP(bp); |
647 | 646 | ||
648 | |||
649 | if (dsb->sb_magicnum == cpu_to_be32(XFS_SB_MAGIC)) { | 647 | if (dsb->sb_magicnum == cpu_to_be32(XFS_SB_MAGIC)) { |
650 | /* XFS filesystem, verify noisily! */ | 648 | /* XFS filesystem, verify noisily! */ |
651 | xfs_sb_read_verify(bp); | 649 | xfs_sb_read_verify(bp); |