linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: buff@cs.boisestate.edu
To: linux-btrfs@vger.kernel.org
Cc: buff@cs.boisestate.edu
Subject: exposing checksums to user-space programs
Date: Mon, 27 Jun 2011 10:47:57 -0600	[thread overview]
Message-ID: <4404.1309193277@wave.linux.bogus> (raw)

Hi Folks (please cc: any replies to me),

I have modified GNU Make to use checksums rather than
timestamps. I would like the operating system and/or
filesystem to compute and provide the checksums, because it
can safely cache them.

Since btrfs checksums its files, I am trying to transfer its
checksums to user space. I believe I saw a thread where
Chris Mason said he didn't want to expose checksums, but
then I found a patch that sounds like it does what I want:

    http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg01182.html

In the thread, Chris said he would take the patch, but it
evidently never made it to distribution.  I applied the
patch to kernel 2.6.30.8, which is old but available on one
of my expendable laptops. I created a btrfs filesystem on a
USB thumb drive and copied a file to it. Then, I cobbled
together this example user-space program:

    http://cs.boisestate.edu/~buff/files/trycsum.c

which produces this output:

    spruce$ sudo mount /mnt/sdb1
    spruce$ trycsum /mnt/sdb1/yum.list 
    File /mnt/sdb1/yum.list has 1 extents:
    #	Logical          Physical         Length           Flags
    0:	0000000000000000 0000000000c00000 000000000015b000 0001
    sizeof(args)=420
    size=0
    csum[0]=0000007b
    spruce$ 

The "size=0" tells me the file's one extent has no
checksum. However:

    spruce$ sudo btrfs-debug-tree  /dev/sdb1 | grep -i csum
	    item 0 key (18446744073709551606 EXTENT_CSUM 12582912) itemoff 2607 itemsize 1388
		    extent csum item
    spruce$ 

suggests it has a checksum.

I traced the function defined in the patch, with printk()
calls. It seemed be accepting and processing its arguments
correctly.

I'm not a kernel-hacking expert, but I was hoping someone
could tell me what I'm doing wrong or give me some
direction. Thanks!

-- Jim

PS: I think I also noticed that a small file has no
checksum, and a big file has no checksum until after a
umount/mount. Is this true?

                 reply	other threads:[~2011-06-27 16:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4404.1309193277@wave.linux.bogus \
    --to=buff@cs.boisestate.edu \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).