nfs_clport.c (222722) | nfs_clport.c (223280) |
---|---|
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 --- 18 unchanged lines hidden (view full) --- 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 */ 33 34#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 --- 18 unchanged lines hidden (view full) --- 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clport.c 222722 2011-06-05 20:22:56Z rmacklem $"); | 35__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clport.c 223280 2011-06-18 23:02:53Z rmacklem $"); |
36 | 36 |
37#include "opt_kdtrace.h" 38 |
|
37/* 38 * generally, I don't like #includes inside .h files, but it seems to 39 * be the easiest way to handle the port. 40 */ 41#include <sys/hash.h> 42#include <fs/nfs/nfsport.h> 43#include <netinet/if_ether.h> 44#include <net/if_types.h> 45 | 39/* 40 * generally, I don't like #includes inside .h files, but it seems to 41 * be the easiest way to handle the port. 42 */ 43#include <sys/hash.h> 44#include <fs/nfs/nfsport.h> 45#include <netinet/if_ether.h> 46#include <net/if_types.h> 47 |
48#include <fs/nfsclient/nfs_kdtrace.h> 49 50#ifdef KDTRACE_HOOKS 51dtrace_nfsclient_attrcache_flush_probe_func_t 52 dtrace_nfscl_attrcache_flush_done_probe; 53uint32_t nfscl_attrcache_flush_done_id; 54 55dtrace_nfsclient_attrcache_get_hit_probe_func_t 56 dtrace_nfscl_attrcache_get_hit_probe; 57uint32_t nfscl_attrcache_get_hit_id; 58 59dtrace_nfsclient_attrcache_get_miss_probe_func_t 60 dtrace_nfscl_attrcache_get_miss_probe; 61uint32_t nfscl_attrcache_get_miss_id; 62 63dtrace_nfsclient_attrcache_load_probe_func_t 64 dtrace_nfscl_attrcache_load_done_probe; 65uint32_t nfscl_attrcache_load_done_id; 66#endif /* !KDTRACE_HOOKS */ 67 |
|
46extern u_int32_t newnfs_true, newnfs_false, newnfs_xdrneg1; 47extern struct vop_vector newnfs_vnodeops; 48extern struct vop_vector newnfs_fifoops; 49extern uma_zone_t newnfsnode_zone; 50extern struct buf_ops buf_ops_newnfs; 51extern int ncl_pbuf_freecnt; 52extern short nfsv4_cbport; 53extern int nfscl_enablecallb; --- 348 unchanged lines hidden (view full) --- 402 if (dontshrink && vap->va_size < np->n_size) { 403 /* 404 * We've been told not to shrink the file; 405 * zero np->n_attrstamp to indicate that 406 * the attributes are stale. 407 */ 408 vap->va_size = np->n_size; 409 np->n_attrstamp = 0; | 68extern u_int32_t newnfs_true, newnfs_false, newnfs_xdrneg1; 69extern struct vop_vector newnfs_vnodeops; 70extern struct vop_vector newnfs_fifoops; 71extern uma_zone_t newnfsnode_zone; 72extern struct buf_ops buf_ops_newnfs; 73extern int ncl_pbuf_freecnt; 74extern short nfsv4_cbport; 75extern int nfscl_enablecallb; --- 348 unchanged lines hidden (view full) --- 424 if (dontshrink && vap->va_size < np->n_size) { 425 /* 426 * We've been told not to shrink the file; 427 * zero np->n_attrstamp to indicate that 428 * the attributes are stale. 429 */ 430 vap->va_size = np->n_size; 431 np->n_attrstamp = 0; |
432 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp); |
|
410 } else if (np->n_flag & NMODIFIED) { 411 /* 412 * We've modified the file: Use the larger 413 * of our size, and the server's size. 414 */ 415 if (vap->va_size < np->n_size) { 416 vap->va_size = np->n_size; 417 } else { --- 16 unchanged lines hidden (view full) --- 434 * READDIR+ resp, WRITE resp received on client. 435 * However, the WRITE resp was handled before the READDIR+ resp 436 * causing the post op attrs from the write to be loaded first 437 * and the attrs from the READDIR+ to be loaded later. If this 438 * happens, we have stale attrs loaded into the attrcache. 439 * We detect this by for the mtime moving back. We invalidate the 440 * attrcache when this happens. 441 */ | 433 } else if (np->n_flag & NMODIFIED) { 434 /* 435 * We've modified the file: Use the larger 436 * of our size, and the server's size. 437 */ 438 if (vap->va_size < np->n_size) { 439 vap->va_size = np->n_size; 440 } else { --- 16 unchanged lines hidden (view full) --- 457 * READDIR+ resp, WRITE resp received on client. 458 * However, the WRITE resp was handled before the READDIR+ resp 459 * causing the post op attrs from the write to be loaded first 460 * and the attrs from the READDIR+ to be loaded later. If this 461 * happens, we have stale attrs loaded into the attrcache. 462 * We detect this by for the mtime moving back. We invalidate the 463 * attrcache when this happens. 464 */ |
442 if (timespeccmp(&mtime_save, &vap->va_mtime, >)) | 465 if (timespeccmp(&mtime_save, &vap->va_mtime, >)) { |
443 /* Size changed or mtime went backwards */ 444 np->n_attrstamp = 0; | 466 /* Size changed or mtime went backwards */ 467 np->n_attrstamp = 0; |
468 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp); 469 } |
|
445 if (vaper != NULL) { 446 NFSBCOPY((caddr_t)vap, (caddr_t)vaper, sizeof(*vap)); 447 if (np->n_flag & NCHG) { 448 if (np->n_flag & NACC) 449 vaper->va_atime = np->n_atim; 450 if (np->n_flag & NUPD) 451 vaper->va_mtime = np->n_mtim; 452 } 453 } | 470 if (vaper != NULL) { 471 NFSBCOPY((caddr_t)vap, (caddr_t)vaper, sizeof(*vap)); 472 if (np->n_flag & NCHG) { 473 if (np->n_flag & NACC) 474 vaper->va_atime = np->n_atim; 475 if (np->n_flag & NUPD) 476 vaper->va_mtime = np->n_mtim; 477 } 478 } |
479#ifdef KDTRACE_HOOKS 480 if (np->n_attrstamp != 0) 481 KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, 0); 482#endif |
|
454 NFSUNLOCKNODE(np); 455 return (0); 456} 457 458/* 459 * Fill in the client id name. For these bytes: 460 * 1 - they must be unique 461 * 2 - they should be persistent across client reboots --- 837 unchanged lines hidden --- | 483 NFSUNLOCKNODE(np); 484 return (0); 485} 486 487/* 488 * Fill in the client id name. For these bytes: 489 * 1 - they must be unique 490 * 2 - they should be persistent across client reboots --- 837 unchanged lines hidden --- |