Deleted Added
full compact
nfs_clvnops.c (322907) nfs_clvnops.c (323142)
1/*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 19 unchanged lines hidden (view full) ---

28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * from nfs_vnops.c 8.16 (Berkeley) 5/27/95
33 */
34
35#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 19 unchanged lines hidden (view full) ---

28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * from nfs_vnops.c 8.16 (Berkeley) 5/27/95
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: stable/11/sys/fs/nfsclient/nfs_clvnops.c 322907 2017-08-25 22:39:49Z rmacklem $");
36__FBSDID("$FreeBSD: stable/11/sys/fs/nfsclient/nfs_clvnops.c 323142 2017-09-03 09:12:02Z kib $");
37
38/*
39 * vnode op calls for Sun NFS version 2, 3 and 4
40 */
41
42#include "opt_inet.h"
43
44#include <sys/param.h>

--- 472 unchanged lines hidden (view full) ---

517 /*
518 * Now, if this Open will be doing reading, re-validate/flush the
519 * cache, so that Close/Open coherency is maintained.
520 */
521 mtx_lock(&np->n_mtx);
522 if (np->n_flag & NMODIFIED) {
523 mtx_unlock(&np->n_mtx);
524 error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1);
37
38/*
39 * vnode op calls for Sun NFS version 2, 3 and 4
40 */
41
42#include "opt_inet.h"
43
44#include <sys/param.h>

--- 472 unchanged lines hidden (view full) ---

517 /*
518 * Now, if this Open will be doing reading, re-validate/flush the
519 * cache, so that Close/Open coherency is maintained.
520 */
521 mtx_lock(&np->n_mtx);
522 if (np->n_flag & NMODIFIED) {
523 mtx_unlock(&np->n_mtx);
524 error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1);
525 if (error == 0 && (vp->v_iflag & VI_DOOMED) != 0)
526 return (EBADF);
527 if (error == EINTR || error == EIO) {
528 if (NFS_ISV4(vp))
529 (void) nfsrpc_close(vp, 0, ap->a_td);
530 return (error);
531 }
532 mtx_lock(&np->n_mtx);
533 np->n_attrstamp = 0;
534 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);

--- 20 unchanged lines hidden (view full) ---

555 }
556 mtx_lock(&np->n_mtx);
557 if ((NFS_ISV4(vp) && np->n_change != vattr.va_filerev) ||
558 NFS_TIMESPEC_COMPARE(&np->n_mtime, &vattr.va_mtime)) {
559 if (vp->v_type == VDIR)
560 np->n_direofoffset = 0;
561 mtx_unlock(&np->n_mtx);
562 error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1);
525 if (error == EINTR || error == EIO) {
526 if (NFS_ISV4(vp))
527 (void) nfsrpc_close(vp, 0, ap->a_td);
528 return (error);
529 }
530 mtx_lock(&np->n_mtx);
531 np->n_attrstamp = 0;
532 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);

--- 20 unchanged lines hidden (view full) ---

553 }
554 mtx_lock(&np->n_mtx);
555 if ((NFS_ISV4(vp) && np->n_change != vattr.va_filerev) ||
556 NFS_TIMESPEC_COMPARE(&np->n_mtime, &vattr.va_mtime)) {
557 if (vp->v_type == VDIR)
558 np->n_direofoffset = 0;
559 mtx_unlock(&np->n_mtx);
560 error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1);
563 if (error == 0 && (vp->v_iflag & VI_DOOMED) != 0)
564 return (EBADF);
565 if (error == EINTR || error == EIO) {
566 if (NFS_ISV4(vp))
567 (void) nfsrpc_close(vp, 0, ap->a_td);
568 return (error);
569 }
570 mtx_lock(&np->n_mtx);
571 np->n_mtime = vattr.va_mtime;
572 if (NFS_ISV4(vp))

--- 4 unchanged lines hidden (view full) ---

577 /*
578 * If the object has >= 1 O_DIRECT active opens, we disable caching.
579 */
580 if (newnfs_directio_enable && (fmode & O_DIRECT) &&
581 (vp->v_type == VREG)) {
582 if (np->n_directio_opens == 0) {
583 mtx_unlock(&np->n_mtx);
584 error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1);
561 if (error == EINTR || error == EIO) {
562 if (NFS_ISV4(vp))
563 (void) nfsrpc_close(vp, 0, ap->a_td);
564 return (error);
565 }
566 mtx_lock(&np->n_mtx);
567 np->n_mtime = vattr.va_mtime;
568 if (NFS_ISV4(vp))

--- 4 unchanged lines hidden (view full) ---

573 /*
574 * If the object has >= 1 O_DIRECT active opens, we disable caching.
575 */
576 if (newnfs_directio_enable && (fmode & O_DIRECT) &&
577 (vp->v_type == VREG)) {
578 if (np->n_directio_opens == 0) {
579 mtx_unlock(&np->n_mtx);
580 error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1);
585 if (error == 0 && (vp->v_iflag & VI_DOOMED) != 0)
586 return (EBADF);
587 if (error) {
588 if (NFS_ISV4(vp))
589 (void) nfsrpc_close(vp, 0, ap->a_td);
590 return (error);
591 }
592 mtx_lock(&np->n_mtx);
593 np->n_flag |= NNONCACHE;
594 }

--- 124 unchanged lines hidden (view full) ---

719 /*
720 * as above w.r.t races when clearing
721 * NMODIFIED.
722 * np->n_flag &= ~NMODIFIED;
723 */
724 }
725 } else {
726 error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1);
581 if (error) {
582 if (NFS_ISV4(vp))
583 (void) nfsrpc_close(vp, 0, ap->a_td);
584 return (error);
585 }
586 mtx_lock(&np->n_mtx);
587 np->n_flag |= NNONCACHE;
588 }

--- 124 unchanged lines hidden (view full) ---

713 /*
714 * as above w.r.t races when clearing
715 * NMODIFIED.
716 * np->n_flag &= ~NMODIFIED;
717 */
718 }
719 } else {
720 error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1);
727 if (error == 0 && (vp->v_iflag & VI_DOOMED) != 0)
728 return (EBADF);
729 }
730 mtx_lock(&np->n_mtx);
731 }
732 /*
733 * Invalidate the attribute cache in all cases.
734 * An open is going to fetch fresh attrs any way, other procs
735 * on this node that have file open will be forced to do an
736 * otw attr fetch, but this is safe.

--- 202 unchanged lines hidden (view full) ---

939 error = ncl_meta_setsize(vp, ap->a_cred, td,
940 vap->va_size);
941 mtx_lock(&np->n_mtx);
942 if (np->n_flag & NMODIFIED) {
943 tsize = np->n_size;
944 mtx_unlock(&np->n_mtx);
945 error = ncl_vinvalbuf(vp, vap->va_size == 0 ?
946 0 : V_SAVE, td, 1);
721 }
722 mtx_lock(&np->n_mtx);
723 }
724 /*
725 * Invalidate the attribute cache in all cases.
726 * An open is going to fetch fresh attrs any way, other procs
727 * on this node that have file open will be forced to do an
728 * otw attr fetch, but this is safe.

--- 202 unchanged lines hidden (view full) ---

931 error = ncl_meta_setsize(vp, ap->a_cred, td,
932 vap->va_size);
933 mtx_lock(&np->n_mtx);
934 if (np->n_flag & NMODIFIED) {
935 tsize = np->n_size;
936 mtx_unlock(&np->n_mtx);
937 error = ncl_vinvalbuf(vp, vap->va_size == 0 ?
938 0 : V_SAVE, td, 1);
947 if (error == 0 && (vp->v_iflag & VI_DOOMED) != 0)
948 error = EBADF;
949 if (error != 0) {
939 if (error != 0) {
950 vnode_pager_setsize(vp, tsize);
951 return (error);
952 }
953 /*
954 * Call nfscl_delegmodtime() to set the modify time
955 * locally, as required.
956 */
957 nfscl_delegmodtime(vp);

--- 10 unchanged lines hidden (view full) ---

968 mtx_unlock(&np->n_mtx);
969 }
970 } else {
971 mtx_lock(&np->n_mtx);
972 if ((vap->va_mtime.tv_sec != VNOVAL || vap->va_atime.tv_sec != VNOVAL) &&
973 (np->n_flag & NMODIFIED) && vp->v_type == VREG) {
974 mtx_unlock(&np->n_mtx);
975 error = ncl_vinvalbuf(vp, V_SAVE, td, 1);
940 vnode_pager_setsize(vp, tsize);
941 return (error);
942 }
943 /*
944 * Call nfscl_delegmodtime() to set the modify time
945 * locally, as required.
946 */
947 nfscl_delegmodtime(vp);

--- 10 unchanged lines hidden (view full) ---

958 mtx_unlock(&np->n_mtx);
959 }
960 } else {
961 mtx_lock(&np->n_mtx);
962 if ((vap->va_mtime.tv_sec != VNOVAL || vap->va_atime.tv_sec != VNOVAL) &&
963 (np->n_flag & NMODIFIED) && vp->v_type == VREG) {
964 mtx_unlock(&np->n_mtx);
965 error = ncl_vinvalbuf(vp, V_SAVE, td, 1);
976 if (error == 0 && (vp->v_iflag & VI_DOOMED) != 0)
977 return (EBADF);
978 if (error == EINTR || error == EIO)
979 return (error);
980 } else
981 mtx_unlock(&np->n_mtx);
982 }
983 error = nfs_setattrrpc(vp, vap, ap->a_cred, td);
984 if (error && vap->va_size != VNOVAL) {
985 mtx_lock(&np->n_mtx);

--- 687 unchanged lines hidden (view full) ---

1673 * another host removes the file..
1674 */
1675 cache_purge(vp);
1676 /*
1677 * throw away biocache buffers, mainly to avoid
1678 * unnecessary delayed writes later.
1679 */
1680 error = ncl_vinvalbuf(vp, 0, cnp->cn_thread, 1);
966 if (error == EINTR || error == EIO)
967 return (error);
968 } else
969 mtx_unlock(&np->n_mtx);
970 }
971 error = nfs_setattrrpc(vp, vap, ap->a_cred, td);
972 if (error && vap->va_size != VNOVAL) {
973 mtx_lock(&np->n_mtx);

--- 687 unchanged lines hidden (view full) ---

1661 * another host removes the file..
1662 */
1663 cache_purge(vp);
1664 /*
1665 * throw away biocache buffers, mainly to avoid
1666 * unnecessary delayed writes later.
1667 */
1668 error = ncl_vinvalbuf(vp, 0, cnp->cn_thread, 1);
1681 if (error == 0 && (vp->v_iflag & VI_DOOMED) != 0)
1682 error = EBADF;
1683 else if (error != EINTR && error != EIO)
1669 if (error != EINTR && error != EIO)
1684 /* Do the rpc */
1685 error = nfs_removerpc(dvp, vp, cnp->cn_nameptr,
1686 cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread);
1687 /*
1688 * Kludge City: If the first reply to the remove rpc is lost..
1689 * the reply to the retransmitted request will be ENOENT
1690 * since the file was in fact removed
1691 * Therefore, we cheat and return success.

--- 1394 unchanged lines hidden (view full) ---

3086 if ((np->n_flag & NMODIFIED) == 0) {
3087 np->n_attrstamp = 0;
3088 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
3089 ret = VOP_GETATTR(vp, &va, cred);
3090 }
3091 if ((np->n_flag & NMODIFIED) || ret ||
3092 np->n_change != va.va_filerev) {
3093 (void) ncl_vinvalbuf(vp, V_SAVE, td, 1);
1670 /* Do the rpc */
1671 error = nfs_removerpc(dvp, vp, cnp->cn_nameptr,
1672 cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread);
1673 /*
1674 * Kludge City: If the first reply to the remove rpc is lost..
1675 * the reply to the retransmitted request will be ENOENT
1676 * since the file was in fact removed
1677 * Therefore, we cheat and return success.

--- 1394 unchanged lines hidden (view full) ---

3072 if ((np->n_flag & NMODIFIED) == 0) {
3073 np->n_attrstamp = 0;
3074 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
3075 ret = VOP_GETATTR(vp, &va, cred);
3076 }
3077 if ((np->n_flag & NMODIFIED) || ret ||
3078 np->n_change != va.va_filerev) {
3079 (void) ncl_vinvalbuf(vp, V_SAVE, td, 1);
3094 if ((vp->v_iflag & VI_DOOMED) != 0) {
3095 NFSVOPUNLOCK(vp, 0);
3096 return (EBADF);
3097 }
3098 np->n_attrstamp = 0;
3099 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
3100 ret = VOP_GETATTR(vp, &va, cred);
3101 if (!ret) {
3102 np->n_mtime = va.va_mtime;
3103 np->n_change = va.va_filerev;
3104 }
3105 }

--- 454 unchanged lines hidden ---
3080 np->n_attrstamp = 0;
3081 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
3082 ret = VOP_GETATTR(vp, &va, cred);
3083 if (!ret) {
3084 np->n_mtime = va.va_mtime;
3085 np->n_change = va.va_filerev;
3086 }
3087 }

--- 454 unchanged lines hidden ---