Date: Thu, 5 Nov 2009 10:38:35 GMT From: Aditya Sarawgi <truncs@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 170221 for review Message-ID: <200911051038.nA5AcZbE000160@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/chv.cgi?CH=170221 Change 170221 by truncs@aditya on 2009/11/05 10:38:02 Apply locks to ext2_itimes. Sync with r198940 Map on core EXT2_NODUMP t UF_NODUMP Use APPEND, IMMUTABLE instead of SF_APPEND, SF_IMMUTABLE since APPEND and IMMUTABLE masks bits of UF_APPEND and UF_IMMUTABLE. Affected files ... .. //depot/projects/soc2009/soc_ext2fs/src/sys/fs/ext2fs/ext2_inode_cnv.c#4 edit .. //depot/projects/soc2009/soc_ext2fs/src/sys/fs/ext2fs/ext2_vnops.c#4 edit Differences ... ==== //depot/projects/soc2009/soc_ext2fs/src/sys/fs/ext2fs/ext2_inode_cnv.c#4 (text+ko) ==== @@ -86,6 +86,7 @@ ip->i_flags = 0; ip->i_flags |= (ei->e2di_flags & EXT2_APPEND) ? SF_APPEND : 0; ip->i_flags |= (ei->e2di_flags & EXT2_IMMUTABLE) ? SF_IMMUTABLE : 0; + ip->i_flags |= (ei->e2di_flags & EXT2_NODUMP) ? UF_NODUMP : 0; ip->i_blocks = ei->e2di_nblock; ip->i_gen = ei->e2di_gen; ip->i_uid = ei->e2di_uid; @@ -124,6 +125,7 @@ ei->e2di_flags = 0; ei->e2di_flags |= (ip->i_flags & SF_APPEND) ? EXT2_APPEND: 0; ei->e2di_flags |= (ip->i_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE: 0; + ei->e2di_flags |= (ip->i_flags & UF_NODUMP) ? EXT2_NODUMP: 0; ei->e2di_nblock = ip->i_blocks; ei->e2di_gen = ip->i_gen; ei->e2di_uid = ip->i_uid; ==== //depot/projects/soc2009/soc_ext2fs/src/sys/fs/ext2fs/ext2_vnops.c#4 (text+ko) ==== @@ -177,13 +177,14 @@ 0, DIRBLKSIZ - 12, 2, EXT2_FT_UNKNOWN, ".." }; -void -ext2_itimes(vp) - struct vnode *vp; +static void +ext2_itimes_locked(struct vnode *vp) { struct inode *ip; struct timespec ts; + ASSERT_VI_LOCKED(vp, __func__); + ip = VTOI(vp); if ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) == 0) return; @@ -210,6 +211,15 @@ ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); } +void +ext2_itimes(struct vnode *vp) +{ + + VI_LOCK(vp); + ext2_itimes_locked(vp); + VI_UNLOCK(vp); +} + /* * Create a regular file */ @@ -248,7 +258,7 @@ /* * Files marked append-only must be opened for appending. */ - if ((VTOI(ap->a_vp)->i_flags & SF_APPEND) && + if ((VTOI(ap->a_vp)->i_flags & APPEND) && (ap->a_mode & (FWRITE | O_APPEND)) == FWRITE) return (EPERM); @@ -392,11 +402,9 @@ if (vap->va_flags != VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - /* - * Deny setting of UF flags - */ - if(vap->va_flags & UF_SETTABLE) - return(EOPNOTSUPP); + /* Disallow flags not supported by ext2fs. */ + if(vap->va_flags & ~(SF_APPEND | SF_IMMUTABLE | UF_NODUMP)) + return(EOPNOTSUPP); /* * Callers may only modify the file flags on objects they * have VADMIN rights for. @@ -425,10 +433,10 @@ ip->i_flags &= SF_SETTABLE; } ip->i_flag |= IN_CHANGE; - if (vap->va_flags & (SF_IMMUTABLE | SF_APPEND)) + if (vap->va_flags & (IMMUTABLE | APPEND)) return (0); } - if (ip->i_flags & (SF_IMMUTABLE | SF_APPEND)) + if (ip->i_flags & (IMMUTABLE | APPEND)) return (EPERM); /* * Go through the fields and update iff not VNOVAL. @@ -677,8 +685,8 @@ int error; ip = VTOI(vp); - if ((ip->i_flags & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) || - (VTOI(dvp)->i_flags & SF_APPEND)) { + if ((ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND)) || + (VTOI(dvp)->i_flags & APPEND)) { error = EPERM; goto out; } @@ -721,7 +729,7 @@ error = EMLINK; goto out; } - if (ip->i_flags & (SF_IMMUTABLE | SF_APPEND)) { + if (ip->i_flags & (IMMUTABLE | APPEND)) { error = EPERM; goto out; } @@ -740,7 +748,27 @@ /* * Rename system call. - * See comments in sys/ufs/ufs/ufs_vnops.c + * rename("foo", "bar"); + * is essentially + * unlink("bar"); + * link("foo", "bar"); + * unlink("foo"); + * but ``atomically''. Can't do full commit without saving state in the + * inode on disk which isn't feasible at this time. Best we can do is + * always guarantee the target exists. + * + * Basic algorithm is: + * + * 1) Bump link count on source while we're linking it to the + * target. This also ensure the inode won't be deleted out + * from underneath us while we work (it may be truncated by + * a concurrent `trunc' or `open' for creation). + * 2) Link source to destination. If destination already exists, + * delete it first. + * 3) Unlink source reference to inode if still around. If a + * directory was moved and the parent of the destination + * is different from the source, patch the ".." entry in the + * directory. */ static int ext2_rename(ap) @@ -788,8 +816,8 @@ return (error); } - if (tvp && ((VTOI(tvp)->i_flags & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) || - (VTOI(tdvp)->i_flags & SF_APPEND))) { + if (tvp && ((VTOI(tvp)->i_flags & (NOUNLINK | IMMUTABLE | APPEND)) || + (VTOI(tdvp)->i_flags & APPEND))) { error = EPERM; goto abortit; } @@ -813,8 +841,8 @@ error = EMLINK; goto abortit; } - if ((ip->i_flags & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) - || (dp->i_flags & SF_APPEND)) { + if ((ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND)) + || (dp->i_flags & APPEND)) { VOP_UNLOCK(fvp, 0); error = EPERM; goto abortit; @@ -1269,8 +1297,8 @@ error = ENOTEMPTY; goto out; } - if ((dp->i_flags & SF_APPEND) - || (ip->i_flags & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND))) { + if ((dp->i_flags & APPEND) + || (ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND))) { error = EPERM; goto out; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911051038.nA5AcZbE000160>