From owner-freebsd-fs@FreeBSD.ORG Sat May 1 23:42:01 2004 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B557516A4CE for ; Sat, 1 May 2004 23:42:01 -0700 (PDT) Received: from mail-svr1.cs.utah.edu (mail-svr1.cs.utah.edu [155.99.198.200]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5842543D2D for ; Sat, 1 May 2004 23:41:59 -0700 (PDT) (envelope-from saggarwa@cs.utah.edu) Received: from faith.cs.utah.edu (faith.cs.utah.edu [155.99.198.108]) by mail-svr1.cs.utah.edu (Postfix) with ESMTP id 313B9346EB for ; Sun, 2 May 2004 00:42:00 -0600 (MDT) Received: by faith.cs.utah.edu (Postfix, from userid 4973) id 620802EC21; Sun, 2 May 2004 00:41:56 -0600 (MDT) Received: from localhost (localhost [127.0.0.1]) by faith.cs.utah.edu (Postfix) with ESMTP id DB3B934406 for ; Sun, 2 May 2004 06:41:56 +0000 (UTC) Date: Sun, 2 May 2004 00:41:56 -0600 (MDT) From: Siddharth Aggarwal To: freebsd-fs@freebsd.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Debugging pseudo-disk driver on FreeBSD X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 May 2004 06:42:01 -0000 Hi, I am working on a Copy on Write disk driver on FreeBSD where I try to save the state of a filesystem (/dev/ad0s3) to another device (/dev/ad0s4) by making a virtual device that sits on top of these two (/dev/shd0). 1. So in the strategy routine, I get the block read/write calls to (/dev/shd0) . 2. For a write operation, I copy the previous contents of the block (number corresponding to /dev/ad0s3) on to a free block on /dev/ad0s4 3. To restore previous contents of disk, I read the allocated free block from /dev/ad0s4 and write it back to original block number /dev/ad0s3. The virtual device /dev/shd0 is mounted on /mnt So to test it out, my /dev/ad0s3 originally had a file "old1" of 13685 bytes containing repeating string pattern (OLDOLD) I then copied a file "new1" of 8211 bytes having the repeating pattern (NEWNEW) to overwrite the old one i.e. cp new1 /mnt/old1 A hexdump shows that a block of 8192 bytes containing "OLDOLD" was copied over to /dev/ad0s4 and its place being taken be "NEWNEW" in /dev/ad0s3. Also remaining bytes (beyond the 8192 bytes) still remain in /dev/ad0s3. So this shows that the copy on write was done correctly. And I correctly see 8211 bytes of "NEWNEW" in /mnt/old1 (ls -l /mnt/old1) I then send an IOCTL to my driver to restore to the previous state (expecting it to give me 13685 bytes of "OLDOLD" back in /mnt/old1) After unmounting and remounting, I see that the contents of /mnt/old1 have become OLDOLD, but there are only 8211 bytes instead of 13685. A hexdump of /dev/ad0s3 however, shows that there are indeed 13685 consecutive bytes of OLDOLD lying there. This has lead me to believe that the Inode of /mnt/old1 is not being refereshed (or it was never saved off to the /dev/ad0s4 in the first place). Do Inode read/writes go through the strategy routine in the first place? Any idea what could be going wrong? Thanks.