flushing disk buffer cache

Don Lewis truckman at FreeBSD.org
Fri Oct 29 12:56:23 PDT 2004


On 29 Oct, Siddharth Aggarwal wrote:
> 
> Thanks for your reply.
> 
> Hmm. At the moment, the user can send an ioctl to define a checkpoint. But
> I would guess that this could happen between 2 strategy() function calls
> corresponding to the same filesystem operation?

Yes.

> So if there a way to block
> filesystem operations while a snapshot is taken? I can't unmount an active
> filesystem before the snapshot and remount it after. Any suggestions?

Yes, this is done by the following code in ffs_snapshot():

        /*
         * Suspend operation on filesystem.
         */
        for (;;) {
                vn_finished_write(wrtmp);
                if ((error = vfs_write_suspend(vp->v_mount)) != 0) {
                        vn_start_write(NULL, &wrtmp, V_WAIT);
                        vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
                        goto out;
                }
                if (mp->mnt_kern_flag & MNTK_SUSPENDED)
                        break;
                vn_start_write(NULL, &wrtmp, V_WAIT);
        }

I think the snapshot code works at a higher level than what you are
implementing, so I believe that the snapshot code doesn't need to sync
all the files to create a consistent snapshot.  You may run into
problems with syncing unwritten data while writing is suspended, but I'm
not sure because don't understand the code all that well.


More information about the freebsd-hackers mailing list