File remove problem

Kostik Belousov kostikbel at gmail.com
Sat Dec 1 22:14:39 PST 2007


On Sat, Dec 01, 2007 at 02:07:50PM -0800, Don Lewis wrote:
> On  1 Dec, Bruce Evans wrote:
> > On Sat, 1 Dec 2007, Kostik Belousov wrote:
> 
> >> +static int
> >> +ffs_isronly(struct ufsmount *ump)
> >> +{
> >> +	struct fs *fs = ump->um_fs;
> >> +
> >> +	return (fs->fs_ronly);
> >> +}
> >> +
> > 
> > Could be ump->um_fs->fs_ronly.
> 
> That's the change that I would have made.  A #include for <ufs/ffs/fs.h>
> would have to be added, which some might argue would be a layering
> violation.  I'd prefer to avoid the extra indirection.

I would argue that the ufs already knows too much about the ffs. But,
this seems to be the first explicit reference to the ffs from the ufs
code. With your approval, see below.

diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c
index 448f436..22e29e9 100644
--- a/sys/ufs/ufs/ufs_inode.c
+++ b/sys/ufs/ufs/ufs_inode.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD: src/sys/ufs/ufs/ufs_inode.c,v 1.69 2007/06/22 13:22:37 kib E
 #ifdef UFS_GJOURNAL
 #include <ufs/ufs/gjournal.h>
 #endif
+#include <ufs/ffs/fs.h>
 
 /*
  * Last reference to an inode.  If necessary, write or delete it.
@@ -90,8 +91,7 @@ ufs_inactive(ap)
 	ufs_gjournal_close(vp);
 #endif
 	if ((ip->i_effnlink == 0 && DOINGSOFTDEP(vp)) ||
-	    (ip->i_nlink <= 0 &&
-	     (vp->v_mount->mnt_flag & MNT_RDONLY) == 0)) {
+	    (ip->i_nlink <= 0 && !VFSTOUFS(mp)->um_fs->fs_ronly)) {
 	loop:
 		if (vn_start_secondary_write(vp, &mp, V_NOWAIT) != 0) {
 			/* Cannot delete file while file system is suspended */
@@ -121,7 +121,7 @@ ufs_inactive(ap)
 	}
 	if (ip->i_effnlink == 0 && DOINGSOFTDEP(vp))
 		softdep_releasefile(ip);
-	if (ip->i_nlink <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
+	if (ip->i_nlink <= 0 && !VFSTOUFS(mp)->um_fs->fs_ronly) {
 #ifdef QUOTA
 		if (!getinoquota(ip))
 			(void)chkiq(ip, -1, NOCRED, FORCE);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20071202/86e1b1f7/attachment.pgp


More information about the freebsd-fs mailing list