From: David Sterba <dave@jikos.cz>
To: Liu Bo <liubo2009@cn.fujitsu.com>
Cc: David Sterba <dsterba@suse.cz>,
linux-btrfs@vger.kernel.org, chris.mason@oracle.com
Subject: Re: [PATCH] btrfs: add new ioctl to determine size of compressed file
Date: Tue, 20 Dec 2011 18:26:58 +0100 [thread overview]
Message-ID: <20111220172658.GD7322@twin.jikos.cz> (raw)
In-Reply-To: <4EEFE5D2.6020401@cn.fujitsu.com>
On Tue, Dec 20, 2011 at 09:33:06AM +0800, Liu Bo wrote:
> > +static long btrfs_ioctl_compr_size(struct file *file, void __user *argp)
> > +{
> > + struct inode *inode = fdentry(file)->d_inode;
> > + struct btrfs_ioctl_compr_size_args compr_args;
> > + u64 len;
> > + u64 compressed_size = 0;
> > + u64 offset = 0;
> > +
> > + if (S_ISDIR(inode->i_mode))
> > + return -EISDIR;
> > +
> > + if (copy_from_user(&compr_args, argp,
> > + sizeof(struct btrfs_ioctl_compr_size_args)))
> > + return -EFAULT;
> > +
> > + if (compr_args.start > compr_args.end)
> > + return -EINVAL;
> > +
> > + mutex_lock(&inode->i_mutex);
> > +
> > + offset = compr_args.start;
> > + if (inode->i_size > compr_args.end)
> > + len = compr_args.end;
> > + else
> > + len = inode->i_size;
> > +
> > + /*
> > + * do any pending delalloc/csum calc on inode, one way or
> > + * another, and lock file content
> > + */
> > + btrfs_wait_ordered_range(inode, compr_args.start, len);
> > +
>
> missing a lock_extent() ?
yeah right, thanks, it was missing even in the original implementation
and was left unnoticed.
> and we may adjust i_mutex and [un]lock_extent.
adjusted which way? I have swapped order of unlock_extent/mutex_unlock
as it was in the wrong order wrt locking. I'll send V2 in a minute.
thanks,
david
next prev parent reply other threads:[~2011-12-20 17:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-19 14:17 [PATCH] btrfs: add new ioctl to determine size of compressed file David Sterba
2011-12-19 14:25 ` A sample tool how to use the new ioctl David Sterba
2011-12-19 14:47 ` Chris Mason
2011-12-19 17:27 ` David Sterba
2011-12-20 17:49 ` [PATCH V2] btrfs-progs: Add ioctl to read compressed size of a file David Sterba
2011-12-20 20:32 ` Goffredo Baroncelli
2012-01-06 18:21 ` [PATCH v3] " David Sterba
2011-12-20 1:33 ` [PATCH] btrfs: add new ioctl to determine size of compressed file Liu Bo
2011-12-20 17:26 ` David Sterba [this message]
2011-12-20 17:46 ` [PATCH V2] " David Sterba
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=20111220172658.GD7322@twin.jikos.cz \
--to=dave@jikos.cz \
--cc=chris.mason@oracle.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=liubo2009@cn.fujitsu.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.