[f2fs-dev] [PATCH v2] resize.f2fs: fix the number of moved ssa blocks in migrate_ssa

2016-11-29 Thread Junling Zheng
If the offset passed in migrate_ssa is not zero, it means that there're
offset segments of old main will disappear after migrating, then there're
offset blocks of old ssa should be invalidated and removed accordingly.
So, the number of moved ssa blocks should be: TOTAL_SEGS(sbi) - offset,
and the expanded summary, which is filled with zero_blocks, should start
from: new_sum_blkaddr + TOTAL_SEGS(sbi) - offset.

Signed-off-by: Yunlei He 
Signed-off-by: Junling Zheng 
---
 fsck/resize.c | 25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/fsck/resize.c b/fsck/resize.c
index ba7bb88..3e8fdd8 100644
--- a/fsck/resize.c
+++ b/fsck/resize.c
@@ -207,30 +207,33 @@ static void migrate_ssa(struct f2fs_sb_info *sbi,
block_t old_sum_blkaddr = get_sb(ssa_blkaddr);
block_t new_sum_blkaddr = get_newsb(ssa_blkaddr);
block_t end_sum_blkaddr = get_newsb(main_blkaddr);
+   block_t expand_sum_blkaddr = new_sum_blkaddr +
+   TOTAL_SEGS(sbi) - offset;
block_t blkaddr;
+   int ret;
void *zero_block = calloc(BLOCK_SZ, 1);
-
ASSERT(zero_block);
 
if (offset && new_sum_blkaddr < old_sum_blkaddr + offset) {
blkaddr = new_sum_blkaddr;
while (blkaddr < end_sum_blkaddr) {
-   if (blkaddr - new_sum_blkaddr < TOTAL_SEGS(sbi))
-   move_ssa(sbi, offset, blkaddr);
-   else
-   dev_write_block(zero_block, blkaddr);
-   offset++;
-   blkaddr++;
+   if (blkaddr < expand_sum_blkaddr)
+   move_ssa(sbi, offset++, blkaddr++);
+   else {
+   ret = dev_write_block(zero_block, blkaddr++);
+   ASSERT(ret >=0);
+   }
}
} else {
blkaddr = end_sum_blkaddr - 1;
offset = TOTAL_SEGS(sbi) - 1;
while (blkaddr >= new_sum_blkaddr) {
-   if (blkaddr >= TOTAL_SEGS(sbi) + new_sum_blkaddr)
-   dev_write_block(zero_block, blkaddr);
+   if (blkaddr >= expand_sum_blkaddr) {
+   ret = dev_write_block(zero_block, blkaddr--);
+   ASSERT(ret >=0);
+   }
else
-   move_ssa(sbi, offset--, blkaddr);
-   blkaddr--;
+   move_ssa(sbi, offset--, blkaddr--);
}
}
 
-- 
2.7.4


--
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [RFD] Common userspace tool for fscypto

2016-11-29 Thread Richard Weinberger
Michael,

On 19.10.2016 19:36, Michael Halcrow wrote:
>> That said, what about implementing such a tool as part of util-linux to 
>> control
>> fscrypto? We (David and I) would volunteer.
> 
> While discussing several changes we have staged for release (we're
> trying to minimize churn by batching a large set of format changes all
> at once), we've recently recognized this need on my team and were
> planning on starting work on exactly what you propose.

Did this plan already materialize? :-)

Thanks,
//richard


--
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [RFD] Common userspace tool for fscypto

2016-11-29 Thread Richard Weinberger
Joe,

On 29.11.2016 22:42, Joe Richey wrote:
> Hi Richard,
> 
> I'm Joe Richey, and I work on Mike's team. We've been playing around
> with a few design
> ideas regarding a tool for managing filesystem encryption. After going
> though some iterations
> with Ted, we have a fairly good idea about where to head design wise,
> and I'm working on a
> design document for it. It's a bit preliminary at this point, but I
> can share it if you want.
> 
> Our goal is to have a finished doc by end of Q4 and then get your and
> Jaegeuk's feedback.

Thanks for your quick response!
I hoped you had already some code, but having a decent design document
is also nice. I'm eager to read it.

Do you also plan to address d/page cache related issues?
i.e. when two users are logged into the system user rw
is able to see decrypted file names and contents in /home/dags/
if user dags installs a key and accessed a file.

Or files in /home/dags/ are still readable even after
user dags purged the key.

The tool could play games with CLONE_NEWNS to hide directories.
To provide a correct "logout" we could expose shrink_dcache_parent()
to usespace such that the emerging tool can purge the key and flush
the dcache on the encrypted directory. But I fear exposing 
shrink_dcache_parent()
is not a good idea. :-)

Just some random ideas...

Thanks,
//richard

--
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] resize.f2fs: fix an error in migrate_ssa

2016-11-29 Thread Jaegeuk Kim
Could you please resubmit a complete patch?

On Tue, Nov 29, 2016 at 04:43:10PM +0800, Junling Zheng wrote:
> Ping ...
> 
> On 2016/11/25 11:53, Junling Zheng wrote:
> > Sorry, I forget to get the return value of dev_write_block :(
> > Please review the following patch :)
> > 
> > ---
> >  fsck/resize.c | 25 ++---
> >  1 file changed, 14 insertions(+), 11 deletions(-)
> > 
> > diff --git a/fsck/resize.c b/fsck/resize.c
> > index 46aa30e..9f9c7a6 100644
> > --- a/fsck/resize.c
> > +++ b/fsck/resize.c
> > @@ -207,30 +207,33 @@ static void migrate_ssa(struct f2fs_sb_info *sbi,
> > block_t old_sum_blkaddr = get_sb(ssa_blkaddr);
> > block_t new_sum_blkaddr = get_newsb(ssa_blkaddr);
> > block_t end_sum_blkaddr = get_newsb(main_blkaddr);
> > +   block_t expand_sum_blkaddr = new_sum_blkaddr +
> > +   TOTAL_SEGS(sbi) - offset;
> > block_t blkaddr;
> > +   int ret;
> > void *zero_block = calloc(BLOCK_SZ, 1);
> > -
> > ASSERT(zero_block);
> > 
> > if (offset && new_sum_blkaddr < old_sum_blkaddr + offset) {
> > blkaddr = new_sum_blkaddr;
> > while (blkaddr < end_sum_blkaddr) {
> > -   if (blkaddr - new_sum_blkaddr < TOTAL_SEGS(sbi))
> > -   move_ssa(sbi, offset, blkaddr);
> > -   else
> > -   dev_write_block(zero_block, blkaddr);
> > -   offset++;
> > -   blkaddr++;
> > +   if (blkaddr < expand_sum_blkaddr)
> > +   move_ssa(sbi, offset++, blkaddr++);
> > +   else {
> > +   ret = dev_write_block(zero_block, blkaddr++);
> > +   ASSERT(ret >=0);
> > +   }
> > }
> > } else {
> > blkaddr = end_sum_blkaddr - 1;
> > offset = TOTAL_SEGS(sbi) - 1;
> > while (blkaddr >= new_sum_blkaddr) {
> > -   if (blkaddr >= TOTAL_SEGS(sbi) + new_sum_blkaddr)
> > -   dev_write_block(zero_block, blkaddr);
> > +   if (blkaddr >= expand_sum_blkaddr) {
> > +   ret = dev_write_block(zero_block, blkaddr--);
> > +   ASSERT(ret >=0);
> > +   }
> > else
> > -   move_ssa(sbi, offset--, blkaddr);
> > -   blkaddr--;
> > +   move_ssa(sbi, offset--, blkaddr--);
> > }
> > }
> > 
> > 
> > On 2016/11/25 11:32, Junling Zheng wrote:
> >> How about the following patch, which I think would be a little better :)
> >>
> >> diff --git a/fsck/resize.c b/fsck/resize.c
> >> index 46aa30e..c295a06 100644
> >> --- a/fsck/resize.c
> >> +++ b/fsck/resize.c
> >> @@ -207,30 +207,33 @@ static void migrate_ssa(struct f2fs_sb_info *sbi,
> >>block_t old_sum_blkaddr = get_sb(ssa_blkaddr);
> >>block_t new_sum_blkaddr = get_newsb(ssa_blkaddr);
> >>block_t end_sum_blkaddr = get_newsb(main_blkaddr);
> >> +  block_t expand_sum_blkaddr = new_sum_blkaddr +
> >> +  TOTAL_SEGS(sbi) - offset;
> >>block_t blkaddr;
> >> +  int ret;
> >>void *zero_block = calloc(BLOCK_SZ, 1);
> >> -
> >>ASSERT(zero_block);
> >>
> >>if (offset && new_sum_blkaddr < old_sum_blkaddr + offset) {
> >>blkaddr = new_sum_blkaddr;
> >>while (blkaddr < end_sum_blkaddr) {
> >> -  if (blkaddr - new_sum_blkaddr < TOTAL_SEGS(sbi))
> >> -  move_ssa(sbi, offset, blkaddr);
> >> -  else
> >> -  dev_write_block(zero_block, blkaddr);
> >> -  offset++;
> >> -  blkaddr++;
> >> +  if (blkaddr < expand_sum_blkaddr)
> >> +  move_ssa(sbi, offset++, blkaddr++);
> >> +  else {
> >> +  dev_write_block(zero_block, blkaddr++);
> >> +  ASSERT(ret >=0);
> > 
> > forget to get the return value of dev_write_block :(
> > 
> >> +  }
> >>}
> >>} else {
> >>blkaddr = end_sum_blkaddr - 1;
> >>offset = TOTAL_SEGS(sbi) - 1;
> >>while (blkaddr >= new_sum_blkaddr) {
> >> -  if (blkaddr >= TOTAL_SEGS(sbi) + new_sum_blkaddr)
> >> -  dev_write_block(zero_block, blkaddr);
> >> +  if (blkaddr >= expand_sum_blkaddr) {
> >> +  dev_write_block(zero_block, blkaddr--);
> >> +  ASSERT(ret >=0);
> >> +  }
> >>else
> >> -  move_ssa(sbi, offset--, blkaddr);
> >> -  blkaddr--;
> >> +  move_ssa(sbi, offset--, blkaddr--);
> >>}
> >>}
> >>
> >>
> >> On 2016/11/24 15:33, Yunlei He wrote:
> >>> 

Re: [f2fs-dev] [PATCH] resize.f2fs: fix an error in migrate_ssa

2016-11-29 Thread Junling Zheng
Ping ...

On 2016/11/25 11:53, Junling Zheng wrote:
> Sorry, I forget to get the return value of dev_write_block :(
> Please review the following patch :)
> 
> ---
>  fsck/resize.c | 25 ++---
>  1 file changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/fsck/resize.c b/fsck/resize.c
> index 46aa30e..9f9c7a6 100644
> --- a/fsck/resize.c
> +++ b/fsck/resize.c
> @@ -207,30 +207,33 @@ static void migrate_ssa(struct f2fs_sb_info *sbi,
>   block_t old_sum_blkaddr = get_sb(ssa_blkaddr);
>   block_t new_sum_blkaddr = get_newsb(ssa_blkaddr);
>   block_t end_sum_blkaddr = get_newsb(main_blkaddr);
> + block_t expand_sum_blkaddr = new_sum_blkaddr +
> + TOTAL_SEGS(sbi) - offset;
>   block_t blkaddr;
> + int ret;
>   void *zero_block = calloc(BLOCK_SZ, 1);
> -
>   ASSERT(zero_block);
> 
>   if (offset && new_sum_blkaddr < old_sum_blkaddr + offset) {
>   blkaddr = new_sum_blkaddr;
>   while (blkaddr < end_sum_blkaddr) {
> - if (blkaddr - new_sum_blkaddr < TOTAL_SEGS(sbi))
> - move_ssa(sbi, offset, blkaddr);
> - else
> - dev_write_block(zero_block, blkaddr);
> - offset++;
> - blkaddr++;
> + if (blkaddr < expand_sum_blkaddr)
> + move_ssa(sbi, offset++, blkaddr++);
> + else {
> + ret = dev_write_block(zero_block, blkaddr++);
> + ASSERT(ret >=0);
> + }
>   }
>   } else {
>   blkaddr = end_sum_blkaddr - 1;
>   offset = TOTAL_SEGS(sbi) - 1;
>   while (blkaddr >= new_sum_blkaddr) {
> - if (blkaddr >= TOTAL_SEGS(sbi) + new_sum_blkaddr)
> - dev_write_block(zero_block, blkaddr);
> + if (blkaddr >= expand_sum_blkaddr) {
> + ret = dev_write_block(zero_block, blkaddr--);
> + ASSERT(ret >=0);
> + }
>   else
> - move_ssa(sbi, offset--, blkaddr);
> - blkaddr--;
> + move_ssa(sbi, offset--, blkaddr--);
>   }
>   }
> 
> 
> On 2016/11/25 11:32, Junling Zheng wrote:
>> How about the following patch, which I think would be a little better :)
>>
>> diff --git a/fsck/resize.c b/fsck/resize.c
>> index 46aa30e..c295a06 100644
>> --- a/fsck/resize.c
>> +++ b/fsck/resize.c
>> @@ -207,30 +207,33 @@ static void migrate_ssa(struct f2fs_sb_info *sbi,
>>  block_t old_sum_blkaddr = get_sb(ssa_blkaddr);
>>  block_t new_sum_blkaddr = get_newsb(ssa_blkaddr);
>>  block_t end_sum_blkaddr = get_newsb(main_blkaddr);
>> +block_t expand_sum_blkaddr = new_sum_blkaddr +
>> +TOTAL_SEGS(sbi) - offset;
>>  block_t blkaddr;
>> +int ret;
>>  void *zero_block = calloc(BLOCK_SZ, 1);
>> -
>>  ASSERT(zero_block);
>>
>>  if (offset && new_sum_blkaddr < old_sum_blkaddr + offset) {
>>  blkaddr = new_sum_blkaddr;
>>  while (blkaddr < end_sum_blkaddr) {
>> -if (blkaddr - new_sum_blkaddr < TOTAL_SEGS(sbi))
>> -move_ssa(sbi, offset, blkaddr);
>> -else
>> -dev_write_block(zero_block, blkaddr);
>> -offset++;
>> -blkaddr++;
>> +if (blkaddr < expand_sum_blkaddr)
>> +move_ssa(sbi, offset++, blkaddr++);
>> +else {
>> +dev_write_block(zero_block, blkaddr++);
>> +ASSERT(ret >=0);
> 
> forget to get the return value of dev_write_block :(
> 
>> +}
>>  }
>>  } else {
>>  blkaddr = end_sum_blkaddr - 1;
>>  offset = TOTAL_SEGS(sbi) - 1;
>>  while (blkaddr >= new_sum_blkaddr) {
>> -if (blkaddr >= TOTAL_SEGS(sbi) + new_sum_blkaddr)
>> -dev_write_block(zero_block, blkaddr);
>> +if (blkaddr >= expand_sum_blkaddr) {
>> +dev_write_block(zero_block, blkaddr--);
>> +ASSERT(ret >=0);
>> +}
>>  else
>> -move_ssa(sbi, offset--, blkaddr);
>> -blkaddr--;
>> +move_ssa(sbi, offset--, blkaddr--);
>>  }
>>  }
>>
>>
>> On 2016/11/24 15:33, Yunlei He wrote:
>>> This patch fix an error in migrate_ssa when resize with condition
>>> that offset is not zero && new_sum_blkaddr > old_sum_blkaddr + offset
>>>
>>> Signed-off-by: Yunlei He