]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - libxfs/xfs_dquot_buf.c
xfs: convert to SPDX license tags
[thirdparty/xfsprogs-dev.git] / libxfs / xfs_dquot_buf.c
index 725158f95683c3ce845f2ff04eeca46ef32b5048..5e31938bb16672f4fe5c49562f6d0867bc60b404 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, 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
  */
 #include "libxfs_priv.h"
 #include "xfs_fs.h"
@@ -150,7 +138,8 @@ xfs_dqblk_repair(
 STATIC bool
 xfs_dquot_buf_verify_crc(
        struct xfs_mount        *mp,
-       struct xfs_buf          *bp)
+       struct xfs_buf          *bp,
+       bool                    readahead)
 {
        struct xfs_dqblk        *d = (struct xfs_dqblk *)bp->b_addr;
        int                     ndquots;
@@ -171,8 +160,12 @@ xfs_dquot_buf_verify_crc(
 
        for (i = 0; i < ndquots; i++, d++) {
                if (!xfs_verify_cksum((char *)d, sizeof(struct xfs_dqblk),
-                                XFS_DQUOT_CRC_OFF))
+                                XFS_DQUOT_CRC_OFF)) {
+                       if (!readahead)
+                               xfs_buf_verifier_error(bp, -EFSBADCRC, __func__,
+                                       d, sizeof(*d), __this_address);
                        return false;
+               }
        }
        return true;
 }
@@ -180,7 +173,8 @@ xfs_dquot_buf_verify_crc(
 STATIC xfs_failaddr_t
 xfs_dquot_buf_verify(
        struct xfs_mount        *mp,
-       struct xfs_buf          *bp)
+       struct xfs_buf          *bp,
+       bool                    readahead)
 {
        struct xfs_dqblk        *dqb = bp->b_addr;
        xfs_failaddr_t          fa;
@@ -214,8 +208,13 @@ xfs_dquot_buf_verify(
                        id = be32_to_cpu(ddq->d_id);
 
                fa = xfs_dqblk_verify(mp, &dqb[i], id + i, 0);
-               if (fa)
+               if (fa) {
+                       if (!readahead)
+                               xfs_buf_verifier_error(bp, -EFSCORRUPTED,
+                                       __func__, &dqb[i],
+                                       sizeof(struct xfs_dqblk), fa);
                        return fa;
+               }
        }
 
        return NULL;
@@ -227,7 +226,7 @@ xfs_dquot_buf_verify_struct(
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
 
-       return xfs_dquot_buf_verify(mp, bp);
+       return xfs_dquot_buf_verify(mp, bp, false);
 }
 
 static void
@@ -235,15 +234,10 @@ xfs_dquot_buf_read_verify(
        struct xfs_buf          *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
-       xfs_failaddr_t          fa;
 
-       if (!xfs_dquot_buf_verify_crc(mp, bp))
-               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
-       else {
-               fa = xfs_dquot_buf_verify(mp, bp);
-               if (fa)
-                       xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
-       }
+       if (!xfs_dquot_buf_verify_crc(mp, bp, false))
+               return;
+       xfs_dquot_buf_verify(mp, bp, false);
 }
 
 /*
@@ -258,8 +252,8 @@ xfs_dquot_buf_readahead_verify(
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
 
-       if (!xfs_dquot_buf_verify_crc(mp, bp) ||
-           xfs_dquot_buf_verify(mp, bp) != NULL) {
+       if (!xfs_dquot_buf_verify_crc(mp, bp, true) ||
+           xfs_dquot_buf_verify(mp, bp, true) != NULL) {
                xfs_buf_ioerror(bp, -EIO);
                bp->b_flags &= ~XBF_DONE;
        }
@@ -275,11 +269,8 @@ xfs_dquot_buf_write_verify(
        struct xfs_buf          *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
-       xfs_failaddr_t          fa;
 
-       fa = xfs_dquot_buf_verify(mp, bp);
-       if (fa)
-               xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
+       xfs_dquot_buf_verify(mp, bp, false);
 }
 
 const struct xfs_buf_ops xfs_dquot_buf_ops = {