Deleted Added
full compact
smbfs_io.c (140220) smbfs_io.c (140223)
1/*-
2 * Copyright (c) 2000-2001, Boris Popov
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
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 *
1/*-
2 * Copyright (c) 2000-2001, Boris Popov
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
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 * $FreeBSD: head/sys/fs/smbfs/smbfs_io.c 140220 2005-01-14 07:33:51Z phk $
32 * $FreeBSD: head/sys/fs/smbfs/smbfs_io.c 140223 2005-01-14 08:52:55Z phk $
33 *
34 */
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/resourcevar.h> /* defines plimit structure in proc struct */
38#include <sys/kernel.h>
39#include <sys/proc.h>
40#include <sys/fcntl.h>

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

219 if (error)
220 return error;
221 np->n_mtime.tv_sec = vattr.va_mtime.tv_sec;
222 } else {
223 error = VOP_GETATTR(vp, &vattr, cred, td);
224 if (error)
225 return error;
226 if (np->n_mtime.tv_sec != vattr.va_mtime.tv_sec) {
33 *
34 */
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/resourcevar.h> /* defines plimit structure in proc struct */
38#include <sys/kernel.h>
39#include <sys/proc.h>
40#include <sys/fcntl.h>

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

219 if (error)
220 return error;
221 np->n_mtime.tv_sec = vattr.va_mtime.tv_sec;
222 } else {
223 error = VOP_GETATTR(vp, &vattr, cred, td);
224 if (error)
225 return error;
226 if (np->n_mtime.tv_sec != vattr.va_mtime.tv_sec) {
227 error = smbfs_vinvalbuf(vp, V_SAVE, cred, td, 1);
227 error = smbfs_vinvalbuf(vp, td);
228 if (error)
229 return error;
230 np->n_mtime.tv_sec = vattr.va_mtime.tv_sec;
231 }
232 }
233 smb_makescred(&scred, td, cred);
234 return smb_read(smp->sm_share, np->n_fid, uiop, &scred);
235}

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

254 return EINVAL;
255/* if (uiop->uio_offset + uiop->uio_resid > smp->nm_maxfilesize)
256 return (EFBIG);*/
257 td = uiop->uio_td;
258 p = td->td_proc;
259 if (ioflag & (IO_APPEND | IO_SYNC)) {
260 if (np->n_flag & NMODIFIED) {
261 smbfs_attr_cacheremove(vp);
228 if (error)
229 return error;
230 np->n_mtime.tv_sec = vattr.va_mtime.tv_sec;
231 }
232 }
233 smb_makescred(&scred, td, cred);
234 return smb_read(smp->sm_share, np->n_fid, uiop, &scred);
235}

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

254 return EINVAL;
255/* if (uiop->uio_offset + uiop->uio_resid > smp->nm_maxfilesize)
256 return (EFBIG);*/
257 td = uiop->uio_td;
258 p = td->td_proc;
259 if (ioflag & (IO_APPEND | IO_SYNC)) {
260 if (np->n_flag & NMODIFIED) {
261 smbfs_attr_cacheremove(vp);
262 error = smbfs_vinvalbuf(vp, V_SAVE, cred, td, 1);
262 error = smbfs_vinvalbuf(vp, td);
263 if (error)
264 return error;
265 }
266 if (ioflag & IO_APPEND) {
267#if notyet
268 /*
269 * File size can be changed by another client
270 */

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

662#endif /* SMBFS_RWGENERIC */
663}
664
665/*
666 * Flush and invalidate all dirty buffers. If another process is already
667 * doing the flush, just wait for completion.
668 */
669int
263 if (error)
264 return error;
265 }
266 if (ioflag & IO_APPEND) {
267#if notyet
268 /*
269 * File size can be changed by another client
270 */

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

662#endif /* SMBFS_RWGENERIC */
663}
664
665/*
666 * Flush and invalidate all dirty buffers. If another process is already
667 * doing the flush, just wait for completion.
668 */
669int
670smbfs_vinvalbuf(vp, flags, cred, td, intrflg)
671 struct vnode *vp;
672 int flags;
673 struct ucred *cred;
674 struct thread *td;
675 int intrflg;
670smbfs_vinvalbuf(struct vnode *vp, struct thread *td)
676{
677 struct smbnode *np = VTOSMB(vp);
671{
672 struct smbnode *np = VTOSMB(vp);
678 int error = 0, slpflag, slptimeo;
673 int error = 0;
679
680 if (vp->v_iflag & VI_XLOCK)
681 return 0;
682
674
675 if (vp->v_iflag & VI_XLOCK)
676 return 0;
677
683 if (intrflg) {
684 slpflag = PCATCH;
685 slptimeo = 2 * hz;
686 } else {
687 slpflag = 0;
688 slptimeo = 0;
689 }
690 while (np->n_flag & NFLUSHINPROG) {
691 np->n_flag |= NFLUSHWANT;
678 while (np->n_flag & NFLUSHINPROG) {
679 np->n_flag |= NFLUSHWANT;
692 error = tsleep(&np->n_flag, PRIBIO + 2, "smfsvinv", slptimeo);
680 error = tsleep(&np->n_flag, PRIBIO + 2, "smfsvinv", 2 * hz);
693 error = smb_td_intr(td);
681 error = smb_td_intr(td);
694 if (error == EINTR && intrflg)
682 if (error == EINTR)
695 return EINTR;
696 }
697 np->n_flag |= NFLUSHINPROG;
683 return EINTR;
684 }
685 np->n_flag |= NFLUSHINPROG;
698 error = vinvalbuf(vp, flags, td, slpflag, 0);
686 error = vinvalbuf(vp, V_SAVE, td, PCATCH, 0);
699 while (error) {
687 while (error) {
700 if (intrflg && (error == ERESTART || error == EINTR)) {
688 if (error == ERESTART || error == EINTR) {
701 np->n_flag &= ~NFLUSHINPROG;
702 if (np->n_flag & NFLUSHWANT) {
703 np->n_flag &= ~NFLUSHWANT;
704 wakeup(&np->n_flag);
705 }
706 return EINTR;
707 }
689 np->n_flag &= ~NFLUSHINPROG;
690 if (np->n_flag & NFLUSHWANT) {
691 np->n_flag &= ~NFLUSHWANT;
692 wakeup(&np->n_flag);
693 }
694 return EINTR;
695 }
708 error = vinvalbuf(vp, flags, td, slpflag, 0);
696 error = vinvalbuf(vp, V_SAVE, td, PCATCH, 0);
709 }
710 np->n_flag &= ~(NMODIFIED | NFLUSHINPROG);
711 if (np->n_flag & NFLUSHWANT) {
712 np->n_flag &= ~NFLUSHWANT;
713 wakeup(&np->n_flag);
714 }
715 return (error);
716}
697 }
698 np->n_flag &= ~(NMODIFIED | NFLUSHINPROG);
699 if (np->n_flag & NFLUSHWANT) {
700 np->n_flag &= ~NFLUSHWANT;
701 wakeup(&np->n_flag);
702 }
703 return (error);
704}