Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Dec 2004 15:30:00 +0000 (GMT)
From:      Robert Watson <rwatson@freebsd.org>
To:        Siddharth Aggarwal <saggarwa@cs.utah.edu>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: Freezing filesystem activity
Message-ID:  <Pine.NEB.3.96L.1041231152737.71776S-100000@fledge.watson.org>
In-Reply-To: <Pine.GSO.4.50L0.0412302339260.5205-100000@faith.cs.utah.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 30 Dec 2004, Siddharth Aggarwal wrote:

> I want to freeze any filesystem activity in the kernel (a pseudo driver) 
> i.e. while my driver code is executing (this code basically flushes
> buffer cache blocks to disk), I donot want any other filesystem
> operations coming in. I tried this by locking the filesystem before my
> code and unlocking right after as shown below. There is a problem
> because it causes a hang (rather it seems as if

If you would just like to freeze file system write operations, a facility
for this already exists via the vn_start_write() and vn_write_finished() 
calls, which are used to gate access to the file system during snapshot
operations.  All processes that attempt to start a write operation on the
file system once it's frozen will block waiting until the write lock is
released.  If you also need to freeze read operations, that would require
fairly substantial modifications to the kernel to implement something not
disimilar to the above.

Robert N M Watson


> 
> 1. The flush is happening indefinitely
> as if the filesystem never got locked and hence more disk updates keep
> coming in
> 
> or
> 
> 2. The filesystem unlock is not happening properly and hence nothing can
> proceed.
> 
> Any suggestions to rectify or probe this problem?
> 
> Thanks,
> Sid.
> 
> my_code()
> {
>  vp = lock_filesystem();
>  sync(); // flush to disk
>  unlock_filesystem(vp);
> }
> 
> struct vnode * lock_filesystem()
> {
>     NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/", curproc);
>     if ((error = vn_open(&nd, FREAD, 0)) != 0) {
>         printf ("Error opening filesystem \n");
>         return 0;
>     }
>     vp = nd.ni_vp;
>     vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curproc);
>     NDFREE(&nd, NDF_ONLY_PNBUF);
>     return vp;
> }
> 
> unlock_filesystem(struct vnode * vp)
> {
>     VOP_UNLOCK(vp, 0, curproc);
> }
> 
> _______________________________________________
> freebsd-fs@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-fs
> To unsubscribe, send any mail to "freebsd-fs-unsubscribe@freebsd.org"
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1041231152737.71776S-100000>