Print this page
OS-5148 ftruncate at offset should emit proper events
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
OS-3462 rename on NFSv4 filesystem induces panic
OS-3294 add support for inotify
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/nfs/nfs4_vnops.c
          +++ new/usr/src/uts/common/fs/nfs/nfs4_vnops.c
↓ open down ↓ 26 lines elided ↑ open up ↑
  27   27   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  28   28   * Use is subject to license terms.
  29   29   */
  30   30  
  31   31  /*
  32   32   *      Copyright 1983,1984,1985,1986,1987,1988,1989 AT&T.
  33   33   *      All Rights Reserved
  34   34   */
  35   35  
  36   36  /*
  37      - * Copyright (c) 2013, Joyent, Inc. All rights reserved.
       37 + * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  38   38   */
  39   39  
  40   40  #include <sys/param.h>
  41   41  #include <sys/types.h>
  42   42  #include <sys/systm.h>
  43   43  #include <sys/cred.h>
  44   44  #include <sys/time.h>
  45   45  #include <sys/vnode.h>
  46   46  #include <sys/vfs.h>
  47   47  #include <sys/vfs_opreg.h>
↓ open down ↓ 3684 lines elided ↑ open up ↑
3732 3732           * Don't call secpolicy_vnode_setattr, the client cannot
3733 3733           * use its cached attributes to make security decisions
3734 3734           * as the server may be faking mode bits or mapping uid/gid.
3735 3735           * Always just let the server to the checking.
3736 3736           * If we provide the ability to remove basic priviledges
3737 3737           * to setattr (e.g. basic without chmod) then we will
3738 3738           * need to add a check here before calling the server.
3739 3739           */
3740 3740          error = nfs4setattr(vp, vap, flags, cr, NULL);
3741 3741  
3742      -        if (error == 0 && (vap->va_mask & AT_SIZE) && vap->va_size == 0)
3743      -                vnevent_truncate(vp, ct);
     3742 +        if (error == 0 && (vap->va_mask & AT_SIZE)) {
     3743 +                if (vap->va_size == 0) {
     3744 +                        vnevent_truncate(vp, ct);
     3745 +                } else {
     3746 +                        vnevent_resize(vp, ct);
     3747 +                }
     3748 +        }
3744 3749  
3745 3750          return (error);
3746 3751  }
3747 3752  
3748 3753  /*
3749 3754   * To replace the "guarded" version 3 setattr, we use two types of compound
3750 3755   * setattr requests:
3751 3756   * 1. The "normal" setattr, used when the size of the file isn't being
3752 3757   *    changed - { Putfh <fh>; Setattr; Getattr }/
3753 3758   * 2. If the size is changed, precede Setattr with: Getattr; Verify
↓ open down ↓ 4302 lines elided ↑ open up ↑
8056 8061                          }
8057 8062                  }
8058 8063          }
8059 8064          mutex_exit(&rp->r_statelock);
8060 8065  
8061 8066          /*
8062 8067           * Notify the rename vnevents to source vnode, and to the target
8063 8068           * vnode if it already existed.
8064 8069           */
8065 8070          if (error == 0) {
8066      -                vnode_t *tvp;
     8071 +                vnode_t *tvp, *tovp;
8067 8072                  rnode4_t *trp;
     8073 +
8068 8074                  /*
8069 8075                   * Notify the vnode. Each links is represented by
8070 8076                   * a different vnode, in nfsv4.
8071 8077                   */
8072 8078                  if (nvp) {
8073 8079                          trp = VTOR4(nvp);
8074 8080                          tvp = nvp;
8075 8081                          if (IS_SHADOW(nvp, trp))
8076 8082                                  tvp = RTOV4(trp);
8077 8083                          vnevent_rename_dest(tvp, ndvp, nnm, ct);
8078 8084                  }
8079 8085  
8080      -                /*
8081      -                 * if the source and destination directory are not the
8082      -                 * same notify the destination directory.
8083      -                 */
8084      -                if (VTOR4(odvp) != VTOR4(ndvp)) {
8085      -                        trp = VTOR4(ndvp);
8086      -                        tvp = ndvp;
8087      -                        if (IS_SHADOW(ndvp, trp))
8088      -                                tvp = RTOV4(trp);
8089      -                        vnevent_rename_dest_dir(tvp, ct);
8090      -                }
8091      -
8092 8086                  trp = VTOR4(ovp);
8093      -                tvp = ovp;
     8087 +                tovp = ovp;
8094 8088                  if (IS_SHADOW(ovp, trp))
     8089 +                        tovp = RTOV4(trp);
     8090 +
     8091 +                vnevent_rename_src(tovp, odvp, onm, ct);
     8092 +
     8093 +                trp = VTOR4(ndvp);
     8094 +                tvp = ndvp;
     8095 +
     8096 +                if (IS_SHADOW(ndvp, trp))
8095 8097                          tvp = RTOV4(trp);
8096      -                vnevent_rename_src(tvp, odvp, onm, ct);
     8098 +
     8099 +                vnevent_rename_dest_dir(tvp, tovp, nnm, ct);
8097 8100          }
8098 8101  
8099 8102          if (nvp) {
8100 8103                  VN_RELE(nvp);
8101 8104          }
8102 8105          VN_RELE(ovp);
8103 8106  
8104 8107          nfs_rw_exit(&odrp->r_rwlock);
8105 8108          nfs_rw_exit(&ndrp->r_rwlock);
8106 8109  
↓ open down ↓ 2888 lines elided ↑ open up ↑
10995 10998          error = convoff(vp, bfp, 0, offset);
10996 10999          if (!error) {
10997 11000                  ASSERT(bfp->l_start >= 0);
10998 11001                  if (bfp->l_len == 0) {
10999 11002                          struct vattr va;
11000 11003  
11001 11004                          va.va_mask = AT_SIZE;
11002 11005                          va.va_size = bfp->l_start;
11003 11006                          error = nfs4setattr(vp, &va, 0, cr, NULL);
11004 11007  
11005      -                        if (error == 0 && bfp->l_start == 0)
11006      -                                vnevent_truncate(vp, ct);
     11008 +                        if (error == 0) {
     11009 +                                if (bfp->l_start == 0) {
     11010 +                                        vnevent_truncate(vp, ct);
     11011 +                                } else {
     11012 +                                        vnevent_resize(vp, ct);
     11013 +                                }
     11014 +                        }
11007 11015                  } else
11008 11016                          error = EINVAL;
11009 11017          }
11010 11018  
11011 11019          return (error);
11012 11020  }
11013 11021  
11014 11022  /* ARGSUSED */
11015 11023  int
11016 11024  nfs4_realvp(vnode_t *vp, vnode_t **vpp, caller_context_t *ct)
↓ open down ↓ 4983 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX