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-5291 lxbrand inotify02 LTP regression
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
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/ufs/ufs_vnops.c
          +++ new/usr/src/uts/common/fs/ufs/ufs_vnops.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1984, 2010, Oracle and/or its affiliates. All rights reserved.
  24      - * Copyright 2015, Joyent, Inc.
       24 + * Copyright 2016, Joyent, Inc.
  25   25   */
  26   26  
  27   27  /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T     */
  28   28  /*        All Rights Reserved   */
  29   29  
  30   30  /*
  31   31   * Portions of this source code were derived from Berkeley 4.3 BSD
  32   32   * under license from the Regents of the University of California.
  33   33   */
  34   34  
↓ open down ↓ 2151 lines elided ↑ open up ↑
2186 2186                  if (error = ufs_iaccess(ip, IWRITE, cr, 0))
2187 2187                          goto update_inode;
2188 2188  
2189 2189                  rw_exit(&ip->i_contents);
2190 2190                  error = TRANS_ITRUNC(ip, vap->va_size, 0, cr);
2191 2191                  if (error) {
2192 2192                          rw_enter(&ip->i_contents, RW_WRITER);
2193 2193                          goto update_inode;
2194 2194                  }
2195 2195  
2196      -                if (error == 0 && vap->va_size)
2197      -                        vnevent_truncate(vp, ct);
     2196 +                if (error == 0) {
     2197 +                        if (vap->va_size) {
     2198 +                                vnevent_truncate(vp, ct);
     2199 +                        } else {
     2200 +                                vnevent_resize(vp, ct);
     2201 +                        }
     2202 +                }
2198 2203          }
2199 2204  
2200 2205          if (ulp) {
2201 2206                  trans_size = (int)TOP_SETATTR_SIZE(ip);
2202 2207                  TRANS_BEGIN_CSYNC(ufsvfsp, issync, TOP_SETATTR, trans_size);
2203 2208                  ++dotrans;
2204 2209          }
2205 2210  
2206 2211          /*
2207 2212           * Acquire i_rwlock after TRANS_BEGIN_CSYNC() if this is a directory.
↓ open down ↓ 1511 lines elided ↑ open up ↑
3719 3724           * still reflects sip, and returns an error if it doesn't.
3720 3725           * If the entry has changed just forget about it.  Release
3721 3726           * the source inode.
3722 3727           */
3723 3728          if ((error = ufs_dirremove(sdp, snm, sip, (struct vnode *)0,
3724 3729              DR_RENAME, cr)) == ENOENT)
3725 3730                  error = 0;
3726 3731  
3727 3732          if (error == 0) {
3728 3733                  vnevent_rename_src(ITOV(sip), sdvp, snm, ct);
3729      -                /*
3730      -                 * Notify the target directory of the rename event
3731      -                 * if source and target directories are not the same.
3732      -                 */
3733      -                if (sdvp != tdvp)
3734      -                        vnevent_rename_dest_dir(tdvp, ct);
     3734 +                vnevent_rename_dest_dir(tdvp, ITOV(sip), tnm, ct);
3735 3735          }
3736 3736  
3737 3737  errout:
3738 3738          if (slot.fbp)
3739 3739                  fbrelse(slot.fbp, S_OTHER);
3740 3740  
3741 3741          rw_exit(&tdp->i_rwlock);
3742 3742          if (sdp != tdp) {
3743 3743                  rw_exit(&sdp->i_rwlock);
3744 3744          }
↓ open down ↓ 726 lines elided ↑ open up ↑
4471 4471          int error;
4472 4472  
4473 4473          if ((error = convoff(vp, bfp, 0, offset)) == 0) {
4474 4474                  if (cmd == F_FREESP) {
4475 4475                          error = ufs_lockfs_begin(ufsvfsp, &ulp,
4476 4476                              ULOCKFS_SPACE_MASK);
4477 4477                          if (error)
4478 4478                                  return (error);
4479 4479                          error = ufs_freesp(vp, bfp, flag, cr);
4480 4480  
4481      -                        if (error == 0 && bfp->l_start == 0)
4482      -                                vnevent_truncate(vp, ct);
     4481 +                        if (error == 0) {
     4482 +                                if (bfp->l_start == 0) {
     4483 +                                        vnevent_truncate(vp, ct);
     4484 +                                } else {
     4485 +                                        vnevent_resize(vp, ct);
     4486 +                                }
     4487 +                        }
4483 4488                  } else if (cmd == F_ALLOCSP) {
4484 4489                          error = ufs_lockfs_begin(ufsvfsp, &ulp,
4485 4490                              ULOCKFS_FALLOCATE_MASK);
4486 4491                          if (error)
4487 4492                                  return (error);
4488 4493                          error = ufs_allocsp(vp, bfp, cr);
4489 4494                  } else
4490 4495                          return (EINVAL); /* Command not handled here */
4491 4496  
4492 4497                  if (ulp)
↓ open down ↓ 2172 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX