All of lore.kernel.org
 help / color / mirror / Atom feed
From: Allison Henderson <achender@linux.vnet.ibm.com>
To: djwong@us.ibm.com
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [Ext4 Secure Delete 2/7v4] ext4: Secure Delete: Add ext4_ind_hole_lookup function
Date: Fri, 07 Oct 2011 16:10:09 -0700	[thread overview]
Message-ID: <4E8F86D1.4010708@linux.vnet.ibm.com> (raw)
In-Reply-To: <20111007174732.GG12447@tux1.beaverton.ibm.com>

On 10/07/2011 10:47 AM, Darrick J. Wong wrote:
> On Fri, Oct 07, 2011 at 12:11:00AM -0700, Allison Henderson wrote:
>> This patch adds a new ext4_ind_hole_lookup function that
>> will be used to identify and skip over holes during a
>> secure delete operation
>>
>> Signed-off-by: Allison Henderson<achender@linux.vnet.ibm.com>
>> ---
>> :100644 100644 db54ce4... 5c9f88c... M	fs/ext4/ext4.h
>> :100644 100644 0962642... 2fe9dfd... M	fs/ext4/indirect.c
>> :100644 100644 c4da98a... 9dc8c14... M	fs/ext4/inode.c
>>   fs/ext4/ext4.h     |    5 +++
>>   fs/ext4/indirect.c |    2 +-
>>   fs/ext4/inode.c    |   73 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 79 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
>> index db54ce4..5c9f88c 100644
>> --- a/fs/ext4/ext4.h
>> +++ b/fs/ext4/ext4.h
>> @@ -2241,6 +2241,11 @@ extern int ext4_bio_write_page(struct ext4_io_submit *io,
>>   /* mmp.c */
>>   extern int ext4_multi_mount_protect(struct super_block *, ext4_fsblk_t);
>>
>> +/* indirects.c */
>> +extern int ext4_block_to_path(struct inode *inode,
>> +			ext4_lblk_t i_block,
>> +			ext4_lblk_t offsets[4], int *boundary);
>> +
>>   /* BH_Uninit flag: blocks are allocated but uninitialized on disk */
>>   enum ext4_state_bits {
>>   	BH_Uninit	/* blocks are allocated but uninitialized on disk */
>> diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
>> index 0962642..2fe9dfd 100644
>> --- a/fs/ext4/indirect.c
>> +++ b/fs/ext4/indirect.c
>> @@ -69,7 +69,7 @@ static inline void add_chain(Indirect *p, struct buffer_head *bh, __le32 *v)
>>    * get there at all.
>>    */
>>
>> -static int ext4_block_to_path(struct inode *inode,
>> +int ext4_block_to_path(struct inode *inode,
>>   			      ext4_lblk_t i_block,
>>   			      ext4_lblk_t offsets[4], int *boundary)
>>   {
>> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
>> index c4da98a..9dc8c14 100644
>> --- a/fs/ext4/inode.c
>> +++ b/fs/ext4/inode.c
>> @@ -640,6 +640,79 @@ struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode,
>>   	return bh;
>>   }
>>
>> +/*
>> + * ext4_in_hole_lookup
>> + *
>> + * Returns the size of the hole located at the given block up to
>> + * the first boundry, or 0 if there is no hole. Returns negative on err.
>
> boundary
>
>> + */
>> +static int ext4_ind_hole_lookup(struct inode *inode, ext4_lblk_t block)
>> +{
>> +	struct super_block *sb = inode->i_sb;
>> +	struct buffer_head *bh;
>> +	ext4_lblk_t offsets[4];
>> +	ext4_lblk_t offset;
>> +	__le32 *children;
>> +	__le32 blk;
>> +	int blocks_to_boundary = 0;
>> +	int depth = 0;
>> +	int hole_size = 0;
>> +	unsigned int i, j;
>> +
>> +	depth = ext4_block_to_path(inode, block, offsets,&blocks_to_boundary);
>> +
>> +	if (depth == 0)
>> +		return 0;
>> +
>> +	offset = offsets[0];
>> +	blk = EXT4_I(inode)->i_data[offset];
>> +	if (blk == 0) {
>> +		for (i = *offsets; i<  EXT4_NDIR_BLOCKS; i++) {
>> +			if (EXT4_I(inode)->i_data[i] == 0)
>> +				hole_size++;
>> +			else
>> +				break;
>> +		}
>> +		return hole_size;
>> +	}
>> +
>> +
>> +	for (j = 1; j<  depth; j++) {
>> +		offset = offsets[j];
>> +		bh = sb_getblk(sb, le32_to_cpu(blk));
>> +		if (unlikely(!bh))
>> +			return -EIO;
>> +
>> +		if (!bh_uptodate_or_lock(bh)) {
>> +			if (bh_submit_read(bh)<  0) {
>> +				put_bh(bh);
>> +				return -EIO;
>> +			}
>> +			/* validate block references */
>> +			if (ext4_check_indirect_blockref(inode, bh)) {
>> +				put_bh(bh);
>> +				return -EIO;
>> +			}
>> +		}
>> +
>> +		blk = ((__le32 *)bh->b_data)[offset];
>> +		/* Reader: end */
>> +		if (blk == 0) {
>> +			children = (__le32 *)(bh->b_data);
>> +			for (i = offset; i<  offset +
>> +					blocks_to_boundary; i++) {
>> +				if (children[i] == 0)
>> +					hole_size++;
>> +				else
>> +					break;
>> +			}
>
> Do you need a put_bh here somewhere?
>
> --D

I think you're right, I will add that in somewhere, thx!

> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2011-10-07 23:10 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-07  7:10 [Ext4 Secure Delete 0/7 v4] Ext4 secure delete Allison Henderson
2011-10-07  7:10 ` [Ext4 Secure Delete 1/7v4] ext4: Secure Delete: Add new EXT4_SECRM_RANDOM_FL flag Allison Henderson
2011-10-07 17:02   ` Darrick J. Wong
2011-10-07 17:14     ` Allison Henderson
2011-10-07  7:11 ` [Ext4 Secure Delete 2/7v4] ext4: Secure Delete: Add ext4_ind_hole_lookup function Allison Henderson
2011-10-07 17:47   ` Darrick J. Wong
2011-10-07 23:10     ` Allison Henderson [this message]
2011-10-07  7:11 ` [Ext4 Secure Delete 3/7v4] ext4: Secure Delete: Add secure delete functions Allison Henderson
2011-10-07 17:19   ` Allison Henderson
2011-10-07 18:07   ` Darrick J. Wong
2011-10-07 23:08     ` Allison Henderson
2011-10-07  7:11 ` [Ext4 Secure Delete 4/7v4] ext4: Secure Delete: Secure delete file data Allison Henderson
2011-10-07  7:11 ` [Ext4 Secure Delete 5/7v4] ext4: Secure Delete: Secure delete directory entry Allison Henderson
2011-10-07 17:22   ` Darrick J. Wong
2011-10-07 17:59     ` Allison Henderson
2011-10-07  7:11 ` [Ext4 Secure Delete 6/7v4] ext4: Secure Delete: Secure delete meta data blocks Allison Henderson
2011-10-07  7:11 ` [Ext4 Secure Delete 7/7v4] ext4/jbd2: Secure Delete: Secure delete journal blocks Allison Henderson
2011-10-07 18:35   ` Darrick J. Wong
2011-10-07 19:31     ` Sunil Mushran
2011-10-07 19:54     ` Eric Sandeen
2011-10-07 20:14       ` Allison Henderson
2011-10-07 19:55     ` Allison Henderson
2011-10-07 20:58       ` Darrick J. Wong
2011-10-08  0:06         ` Allison Henderson
2011-10-10 19:47   ` Jonathan Corbet
2011-10-10 23:35     ` Allison Henderson
2011-10-10 23:41       ` Jonathan Corbet
2011-10-11  0:54         ` Allison Henderson
2011-10-10 20:00   ` Jonathan Corbet
2011-10-10 23:36     ` Allison Henderson
2011-10-07 15:21 ` [Ext4 Secure Delete 0/7 v4] Ext4 secure delete Andreas Dilger
2011-10-07 17:07   ` Allison Henderson
2011-10-10 17:20     ` Allison Henderson

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=4E8F86D1.4010708@linux.vnet.ibm.com \
    --to=achender@linux.vnet.ibm.com \
    --cc=djwong@us.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@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 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.