Hello misc,

  I've reported a detailed bug two months ago. The short story - grace
period end time isn't being reset if the over_soft_quota stage is reached
by chown command. I've confirmed it on i386 5.0 through current (as of
month ago) and on amd64 5.4.
  Developers seemed to don't have time for it, so I've asked our
consultant, Ed Bartosh <bart...@gmail.com> (not subscribed to the list), to
look into this. It seems like he has fixed it. Here is the patch for 5.4
(tested on i386 only yet):

Index: ufs_vnops.c
===================================================================
RCS file: /cvs/src/sys/ufs/ufs/ufs_vnops.c,v
retrieving revision 1.107
diff -u -p -r1.107 ufs_vnops.c
--- ufs_vnops.c 11 Jun 2013 16:42:19 -0000      1.107
+++ ufs_vnops.c 1 Dec 2014 21:54:44 -0000
@@ -448,6 +448,8 @@ ufs_chown(struct vnode *vp, uid_t uid, g
        int error = 0;
        daddr_t change;
        enum ufs_quota_flags quota_flags = 0;
+       struct ucred *newcr;
+
 
        if (uid == (uid_t)VNOVAL)
                uid = DIP(ip, uid);
@@ -484,17 +486,26 @@ ufs_chown(struct vnode *vp, uid_t uid, g
        if ((error = getinoquota(ip)) != 0)
                goto error;
 
-       if ((error = ufs_quota_alloc_blocks2(ip, change, cred, 
-                quota_flags)) != 0) 
+       newcr = crget();
+       newcr->cr_uid = uid;
+       newcr->cr_gid = gid;
+
+       if ((error = ufs_quota_alloc_blocks2(ip, change, newcr, 
+                quota_flags)) != 0) {
+               crfree(newcr);
                goto error;
+       }
 
-       if ((error = ufs_quota_alloc_inode2(ip, cred ,
+       if ((error = ufs_quota_alloc_inode2(ip, newcr,
                 quota_flags)) != 0) {
-               (void)ufs_quota_free_blocks2(ip, change, cred, 
+               (void)ufs_quota_free_blocks2(ip, change, newcr, 
                    quota_flags);               
+               crfree(newcr);
                goto error;
        }
 
+       crfree(newcr);
+
        if (getinoquota(ip))
                panic("chown: lost quota");


  Please advise if you see problems with that patch (besides the fact that
it's for 5.4).

-- 
Best regards,
 Boris                          mailto:bo...@twopoint.com

Reply via email to