Date: Mon, 7 Feb 2022 09:50:53 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 8fcc0d7b3939 - stable/13 - ufs: Use IS_SNAPSHOT() Message-ID: <202202070950.2179orbv059031@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8fcc0d7b393904702bef5cbe1b760454b02ce0fb commit 8fcc0d7b393904702bef5cbe1b760454b02ce0fb Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-01-20 13:17:59 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-02-07 09:38:50 +0000 ufs: Use IS_SNAPSHOT() (cherry picked from commit 0cdc6033087ac28640fa750a4dc4676107d4f364) --- sys/ufs/ufs/ufs_bmap.c | 14 ++++++-------- sys/ufs/ufs/ufs_lookup.c | 5 ++--- sys/ufs/ufs/ufs_vnops.c | 10 +++++----- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/sys/ufs/ufs/ufs_bmap.c b/sys/ufs/ufs/ufs_bmap.c index b60c93fb9105..5b9a16782cf7 100644 --- a/sys/ufs/ufs/ufs_bmap.c +++ b/sys/ufs/ufs/ufs_bmap.c @@ -217,14 +217,12 @@ ufs_bmaparray(vp, bn, bnp, nbp, runp, runb) * return a request for a zeroed out buffer if attempts * are made to read a BLK_NOCOPY or BLK_SNAP block. */ - if ((ip->i_flags & SF_SNAPSHOT) && DIP(ip, i_db[bn]) > 0 && + if (IS_SNAPSHOT(ip) && DIP(ip, i_db[bn]) > 0 && DIP(ip, i_db[bn]) < ump->um_seqinc) { *bnp = -1; } else if (*bnp == 0) { - if (ip->i_flags & SF_SNAPSHOT) - *bnp = blkptrtodb(ump, bn * ump->um_seqinc); - else - *bnp = -1; + *bnp = IS_SNAPSHOT(ip) ? blkptrtodb(ump, + bn * ump->um_seqinc) : -1; } else if (runp) { ufs2_daddr_t bnb = bn; for (++bn; bn < UFS_NDADDR && *runp < maxrun && @@ -320,13 +318,13 @@ ufs_bmaparray(vp, bn, bnp, nbp, runp, runb) * return a request for a zeroed out buffer if attempts are made * to read a BLK_NOCOPY or BLK_SNAP block. */ - if ((ip->i_flags & SF_SNAPSHOT) && daddr > 0 && daddr < ump->um_seqinc){ + if (IS_SNAPSHOT(ip) && daddr > 0 && daddr < ump->um_seqinc){ *bnp = -1; return (0); } *bnp = blkptrtodb(ump, daddr); if (*bnp == 0) { - if (ip->i_flags & SF_SNAPSHOT) + if (IS_SNAPSHOT(ip)) *bnp = blkptrtodb(ump, bn * ump->um_seqinc); else *bnp = -1; @@ -367,7 +365,7 @@ ufs_bmap_seekdata(vp, offp) mp = vp->v_mount; ump = VFSTOUFS(mp); - if (vp->v_type != VREG || (ip->i_flags & SF_SNAPSHOT) != 0) + if (vp->v_type != VREG || IS_SNAPSHOT(ip)) return (EINVAL); if (*offp < 0 || *offp >= ip->i_size) return (ENXIO); diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index fc78c017e2c6..bf21c4f57e12 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -1245,8 +1245,7 @@ out: * drop its snapshot reference so that it will be reclaimed * when last open reference goes away. */ - if (ip != NULL && (ip->i_flags & SF_SNAPSHOT) != 0 && - ip->i_effnlink == 0) + if (ip != NULL && IS_SNAPSHOT(ip) && ip->i_effnlink == 0) UFS_SNAPGONE(ip); return (error); } @@ -1320,7 +1319,7 @@ ufs_dirrewrite(dp, oip, newinum, newtype, isrmdir) * drop its snapshot reference so that it will be reclaimed * when last open reference goes away. */ - if ((oip->i_flags & SF_SNAPSHOT) != 0 && oip->i_effnlink == 0) + if (IS_SNAPSHOT(oip) && oip->i_effnlink == 0) UFS_SNAPGONE(oip); return (error); } diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index e962ef8ca48c..a1306fa18f58 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -702,7 +702,7 @@ ufs_setattr(ap) */ if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - if ((ip->i_flags & SF_SNAPSHOT) != 0) + if (IS_SNAPSHOT(ip)) return (EPERM); break; default: @@ -726,7 +726,7 @@ ufs_setattr(ap) vap->va_birthtime.tv_sec != VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - if ((ip->i_flags & SF_SNAPSHOT) != 0) + if (IS_SNAPSHOT(ip)) return (EPERM); error = vn_utimes_perm(vp, vap, cred, td); if (error != 0) @@ -754,8 +754,8 @@ ufs_setattr(ap) if (vap->va_mode != (mode_t)VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - if ((ip->i_flags & SF_SNAPSHOT) != 0 && (vap->va_mode & - (S_IXUSR | S_IWUSR | S_IXGRP | S_IWGRP | S_IXOTH | S_IWOTH))) + if (IS_SNAPSHOT(ip) && (vap->va_mode & (S_IXUSR | S_IWUSR | + S_IXGRP | S_IWGRP | S_IXOTH | S_IWOTH)) != 0) return (EPERM); error = ufs_chmod(vp, (int)vap->va_mode, cred, td); } @@ -1022,7 +1022,7 @@ ufs_remove(ap) error = ufs_dirremove(dvp, ip, ap->a_cnp->cn_flags, 0); if (ip->i_nlink <= 0) vp->v_vflag |= VV_NOSYNC; - if ((ip->i_flags & SF_SNAPSHOT) != 0) { + if (IS_SNAPSHOT(ip)) { /* * Avoid deadlock where another thread is trying to * update the inodeblock for dvp and is waiting on
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202202070950.2179orbv059031>