Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-12-18 Thread Mark Fasheh
On Tue, Nov 24, 2015 at 08:29:41PM -0700, Gang He wrote:
> Hi Mark and Junxiao,
> 
> 
> >>> 
> > On Tue, Nov 03, 2015 at 04:20:27PM +0800, Junxiao Bi wrote:
> >> Hi Gang,
> >> 
> >> On 11/03/2015 03:54 PM, Gang He wrote:
> >> > Hi Junxiao,
> >> > 
> >> > Thank for your reviewing.
> >> > Current design, we use a sysfile as a interface to check/fix a file (via 
> > pass a ino number).
> >> > But, this operation is manually triggered by user, instead of 
> >> > automatically 
> >  fix in the kernel.
> >> > Why?
> >> > 1) we should let users make this decision, since some users do not want 
> >> > to 
> > fix when encountering a file system corruption, maybe they want to keep the 
> > file system unchanged for a further investigation.
> >> If user don't want this, they should not use error=continue option, let
> >> fs go after a corruption is very dangerous.
> > 
> > Maybe we need another errors=XXX flag (maybe errors=fix)?
> > 
> > You both make good points, here's what I gather from the conversation:
> > 
> >  - Some customers would be sad if they have to manually fix corruptions.
> >This takes effort on their part, and if the FS can handle it
> >automatically, it should.
> > 
> >  - There are valid concerns that automatically fixing things is a change in
> >behavior that might not be welcome, or worse might lead to unforseeable
> >circumstances.
> > 
> >  - I will add that fixing things automatically implies checking them
> >automatically which could introduce some performance impact depending on
> >how much checking we're doing.
> > 
> > So if the user wants errors to be fixed automatically, they could mount with
> > errros=fix, and everyone else would have no change in behavior unless they
> > wanted to make use of the new feature.
> That is what I want to say, add a mount option to let users to decide. Here, 
> I want to split "error=fix"
> mount option  task out from online file check feature, I think this part 
> should be a independent feature.
> We can implement this feature after online file check is done, I want to 
> split the feature into some more 
> detailed features, implement them one by one. Do you agree this point?

Yeah that's fine, I would have automatic checking turned off though until we
have a good plan in place for users who do / don't want this.
--Mark

--
Mark Fasheh

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-11-24 Thread Mark Fasheh
On Tue, Nov 03, 2015 at 04:20:27PM +0800, Junxiao Bi wrote:
> Hi Gang,
> 
> On 11/03/2015 03:54 PM, Gang He wrote:
> > Hi Junxiao,
> > 
> > Thank for your reviewing.
> > Current design, we use a sysfile as a interface to check/fix a file (via 
> > pass a ino number).
> > But, this operation is manually triggered by user, instead of automatically 
> >  fix in the kernel.
> > Why?
> > 1) we should let users make this decision, since some users do not want to 
> > fix when encountering a file system corruption, maybe they want to keep the 
> > file system unchanged for a further investigation.
> If user don't want this, they should not use error=continue option, let
> fs go after a corruption is very dangerous.

Maybe we need another errors=XXX flag (maybe errors=fix)?

You both make good points, here's what I gather from the conversation:

 - Some customers would be sad if they have to manually fix corruptions.
   This takes effort on their part, and if the FS can handle it
   automatically, it should.

 - There are valid concerns that automatically fixing things is a change in
   behavior that might not be welcome, or worse might lead to unforseeable
   circumstances.

 - I will add that fixing things automatically implies checking them
   automatically which could introduce some performance impact depending on
   how much checking we're doing.

So if the user wants errors to be fixed automatically, they could mount with
errros=fix, and everyone else would have no change in behavior unless they
wanted to make use of the new feature.


> > 2) frankly speaking, this feature will probably bring a second corruption 
> > if there is some error in the code, I do not suggest to use automatically 
> > fix by default in the first version.
> I think if this feature could bring more corruption, then this should be
> fixed first.

Btw, I am pretty sure that Gang is referring to the feature being new and
thus more likely to have problems. There is nothing I see in here that is
file system corrupting.
--Mark


--
Mark Fasheh

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-11-24 Thread Srinivas Eeda
On 11/24/2015 01:46 PM, Mark Fasheh wrote:
> On Tue, Nov 03, 2015 at 04:20:27PM +0800, Junxiao Bi wrote:
>> Hi Gang,
>>
>> On 11/03/2015 03:54 PM, Gang He wrote:
>>> Hi Junxiao,
>>>
>>> Thank for your reviewing.
>>> Current design, we use a sysfile as a interface to check/fix a file (via 
>>> pass a ino number).
>>> But, this operation is manually triggered by user, instead of automatically 
>>>  fix in the kernel.
>>> Why?
>>> 1) we should let users make this decision, since some users do not want to 
>>> fix when encountering a file system corruption, maybe they want to keep the 
>>> file system unchanged for a further investigation.
>> If user don't want this, they should not use error=continue option, let
>> fs go after a corruption is very dangerous.
> Maybe we need another errors=XXX flag (maybe errors=fix)?
Great idea Mark! I think adding errors=fix would be a good way to 
address both concerns :) It gives some control if anyone is 
uncomfortable of things getting checked/fixed automatically.

>
> You both make good points, here's what I gather from the conversation:
>
>   - Some customers would be sad if they have to manually fix corruptions.
> This takes effort on their part, and if the FS can handle it
> automatically, it should.
>
>   - There are valid concerns that automatically fixing things is a change in
> behavior that might not be welcome, or worse might lead to unforseeable
> circumstances.
>
>   - I will add that fixing things automatically implies checking them
> automatically which could introduce some performance impact depending on
> how much checking we're doing.
>
> So if the user wants errors to be fixed automatically, they could mount with
> errros=fix, and everyone else would have no change in behavior unless they
> wanted to make use of the new feature.
>
>
>>> 2) frankly speaking, this feature will probably bring a second corruption 
>>> if there is some error in the code, I do not suggest to use automatically 
>>> fix by default in the first version.
>> I think if this feature could bring more corruption, then this should be
>> fixed first.
> Btw, I am pretty sure that Gang is referring to the feature being new and
> thus more likely to have problems. There is nothing I see in here that is
> file system corrupting.
>   --Mark
>
>
> --
> Mark Fasheh
>
> ___
> Ocfs2-devel mailing list
> Ocfs2-devel@oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-devel


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-11-24 Thread Mark Fasheh
On Wed, Oct 28, 2015 at 02:25:59PM +0800, Gang He wrote:
> Implement online file check sysfile interfaces, e.g.
> how to create the related sysfile according to device name,
> how to display/handle file check request from the sysfile.
> 
> Signed-off-by: Gang He 

FYI, This looks generally fine to me however we should address Junxiao's 
concerns
before it goes any further.
--Mark

--
Mark Fasheh

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-11-24 Thread Gang He
Hi Mark and Junxiao,


>>> 
> On Tue, Nov 03, 2015 at 04:20:27PM +0800, Junxiao Bi wrote:
>> Hi Gang,
>> 
>> On 11/03/2015 03:54 PM, Gang He wrote:
>> > Hi Junxiao,
>> > 
>> > Thank for your reviewing.
>> > Current design, we use a sysfile as a interface to check/fix a file (via 
> pass a ino number).
>> > But, this operation is manually triggered by user, instead of 
>> > automatically 
>  fix in the kernel.
>> > Why?
>> > 1) we should let users make this decision, since some users do not want to 
> fix when encountering a file system corruption, maybe they want to keep the 
> file system unchanged for a further investigation.
>> If user don't want this, they should not use error=continue option, let
>> fs go after a corruption is very dangerous.
> 
> Maybe we need another errors=XXX flag (maybe errors=fix)?
> 
> You both make good points, here's what I gather from the conversation:
> 
>  - Some customers would be sad if they have to manually fix corruptions.
>This takes effort on their part, and if the FS can handle it
>automatically, it should.
> 
>  - There are valid concerns that automatically fixing things is a change in
>behavior that might not be welcome, or worse might lead to unforseeable
>circumstances.
> 
>  - I will add that fixing things automatically implies checking them
>automatically which could introduce some performance impact depending on
>how much checking we're doing.
> 
> So if the user wants errors to be fixed automatically, they could mount with
> errros=fix, and everyone else would have no change in behavior unless they
> wanted to make use of the new feature.
That is what I want to say, add a mount option to let users to decide. Here, I 
want to split "error=fix"
mount option  task out from online file check feature, I think this part should 
be a independent feature.
We can implement this feature after online file check is done, I want to split 
the feature into some more 
detailed features, implement them one by one. Do you agree this point?

> 
> 
>> > 2) frankly speaking, this feature will probably bring a second corruption 
> if there is some error in the code, I do not suggest to use automatically fix 
> by default in the first version.
>> I think if this feature could bring more corruption, then this should be
>> fixed first.
> 
> Btw, I am pretty sure that Gang is referring to the feature being new and
> thus more likely to have problems. There is nothing I see in here that is
> file system corrupting.
>   --Mark
> 
> 
> --
> Mark Fasheh


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-11-24 Thread Junxiao Bi
On 11/25/2015 05:46 AM, Mark Fasheh wrote:
> On Tue, Nov 03, 2015 at 04:20:27PM +0800, Junxiao Bi wrote:
>> Hi Gang,
>>
>> On 11/03/2015 03:54 PM, Gang He wrote:
>>> Hi Junxiao,
>>>
>>> Thank for your reviewing.
>>> Current design, we use a sysfile as a interface to check/fix a file (via 
>>> pass a ino number).
>>> But, this operation is manually triggered by user, instead of automatically 
>>>  fix in the kernel.
>>> Why?
>>> 1) we should let users make this decision, since some users do not want to 
>>> fix when encountering a file system corruption, maybe they want to keep the 
>>> file system unchanged for a further investigation.
>> If user don't want this, they should not use error=continue option, let
>> fs go after a corruption is very dangerous.
> 
> Maybe we need another errors=XXX flag (maybe errors=fix)?
Sound great. This is a good option since user may have not enough
knowledge whether to fix the found issue.

Thanks,
Junxiao.
> 
> You both make good points, here's what I gather from the conversation:
> 
>  - Some customers would be sad if they have to manually fix corruptions.
>This takes effort on their part, and if the FS can handle it
>automatically, it should.
> 
>  - There are valid concerns that automatically fixing things is a change in
>behavior that might not be welcome, or worse might lead to unforseeable
>circumstances.
> 
>  - I will add that fixing things automatically implies checking them
>automatically which could introduce some performance impact depending on
>how much checking we're doing.
> 
> So if the user wants errors to be fixed automatically, they could mount with
> errros=fix, and everyone else would have no change in behavior unless they
> wanted to make use of the new feature.
> 
> 
>>> 2) frankly speaking, this feature will probably bring a second corruption 
>>> if there is some error in the code, I do not suggest to use automatically 
>>> fix by default in the first version.
>> I think if this feature could bring more corruption, then this should be
>> fixed first.
> 
> Btw, I am pretty sure that Gang is referring to the feature being new and
> thus more likely to have problems. There is nothing I see in here that is
> file system corrupting.
>   --Mark
> 
> 
> --
> Mark Fasheh
> 


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-11-24 Thread Junxiao Bi
Hi Gang,

On 11/25/2015 11:29 AM, Gang He wrote:
> Hi Mark and Junxiao,
> 
> 

>> On Tue, Nov 03, 2015 at 04:20:27PM +0800, Junxiao Bi wrote:
>>> Hi Gang,
>>>
>>> On 11/03/2015 03:54 PM, Gang He wrote:
 Hi Junxiao,

 Thank for your reviewing.
 Current design, we use a sysfile as a interface to check/fix a file (via 
>> pass a ino number).
 But, this operation is manually triggered by user, instead of 
 automatically 
>>  fix in the kernel.
 Why?
 1) we should let users make this decision, since some users do not want to 
>> fix when encountering a file system corruption, maybe they want to keep the 
>> file system unchanged for a further investigation.
>>> If user don't want this, they should not use error=continue option, let
>>> fs go after a corruption is very dangerous.
>>
>> Maybe we need another errors=XXX flag (maybe errors=fix)?
>>
>> You both make good points, here's what I gather from the conversation:
>>
>>  - Some customers would be sad if they have to manually fix corruptions.
>>This takes effort on their part, and if the FS can handle it
>>automatically, it should.
>>
>>  - There are valid concerns that automatically fixing things is a change in
>>behavior that might not be welcome, or worse might lead to unforseeable
>>circumstances.
>>
>>  - I will add that fixing things automatically implies checking them
>>automatically which could introduce some performance impact depending on
>>how much checking we're doing.
>>
>> So if the user wants errors to be fixed automatically, they could mount with
>> errros=fix, and everyone else would have no change in behavior unless they
>> wanted to make use of the new feature.
> That is what I want to say, add a mount option to let users to decide. Here, 
> I want to split "error=fix"
> mount option  task out from online file check feature, I think this part 
> should be a independent feature.
> We can implement this feature after online file check is done, I want to 
> split the feature into some more 
> detailed features, implement them one by one. Do you agree this point?
With error=fix, when a possible corruption is found, online fsck will
start to check and fix things. So this doesn't looks like a independent
feature.

Thanks,
Junxiao.

> 
>>
>>
 2) frankly speaking, this feature will probably bring a second corruption 
>> if there is some error in the code, I do not suggest to use automatically 
>> fix 
>> by default in the first version.
>>> I think if this feature could bring more corruption, then this should be
>>> fixed first.
>>
>> Btw, I am pretty sure that Gang is referring to the feature being new and
>> thus more likely to have problems. There is nothing I see in here that is
>> file system corrupting.
>>  --Mark
>>
>>
>> --
>> Mark Fasheh
> 


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-11-24 Thread Gang He
Hi Junxiao,


>>> 
> Hi Gang,
> 
> On 11/25/2015 11:29 AM, Gang He wrote:
>> Hi Mark and Junxiao,
>> 
>> 
>
>>> On Tue, Nov 03, 2015 at 04:20:27PM +0800, Junxiao Bi wrote:
 Hi Gang,

 On 11/03/2015 03:54 PM, Gang He wrote:
> Hi Junxiao,
>
> Thank for your reviewing.
> Current design, we use a sysfile as a interface to check/fix a file (via 
>>> pass a ino number).
> But, this operation is manually triggered by user, instead of 
> automatically 
>>>  fix in the kernel.
> Why?
> 1) we should let users make this decision, since some users do not want 
> to 
>>> fix when encountering a file system corruption, maybe they want to keep the 
>>> file system unchanged for a further investigation.
 If user don't want this, they should not use error=continue option, let
 fs go after a corruption is very dangerous.
>>>
>>> Maybe we need another errors=XXX flag (maybe errors=fix)?
>>>
>>> You both make good points, here's what I gather from the conversation:
>>>
>>>  - Some customers would be sad if they have to manually fix corruptions.
>>>This takes effort on their part, and if the FS can handle it
>>>automatically, it should.
>>>
>>>  - There are valid concerns that automatically fixing things is a change in
>>>behavior that might not be welcome, or worse might lead to unforseeable
>>>circumstances.
>>>
>>>  - I will add that fixing things automatically implies checking them
>>>automatically which could introduce some performance impact depending on
>>>how much checking we're doing.
>>>
>>> So if the user wants errors to be fixed automatically, they could mount with
>>> errros=fix, and everyone else would have no change in behavior unless they
>>> wanted to make use of the new feature.
>> That is what I want to say, add a mount option to let users to decide. Here, 
> I want to split "error=fix"
>> mount option  task out from online file check feature, I think this part 
> should be a independent feature.
>> We can implement this feature after online file check is done, I want to 
> split the feature into some more 
>> detailed features, implement them one by one. Do you agree this point?
> With error=fix, when a possible corruption is found, online fsck will
> start to check and fix things. So this doesn't looks like a independent
> feature.
My means is, we can implement online file check by manually triage feature 
first, then
Add a mount option "error=fix" feature, the second feature can be implemented 
after
the first part is done. I want to split them into more detailed items, maybe it 
is more helpful
to be reviewed, but the whole feature ideas are very OK, just need to do one by 
one.  

> 
> Thanks,
> Junxiao.
> 
>> 
>>>
>>>
> 2) frankly speaking, this feature will probably bring a second corruption 
>>> if there is some error in the code, I do not suggest to use automatically 
> fix 
>>> by default in the first version.
 I think if this feature could bring more corruption, then this should be
 fixed first.
>>>
>>> Btw, I am pretty sure that Gang is referring to the feature being new and
>>> thus more likely to have problems. There is nothing I see in here that is
>>> file system corrupting.
>>> --Mark
>>>
>>>
>>> --
>>> Mark Fasheh
>> 


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-11-03 Thread Gang He
Hi Junxiao,

Thank for your reviewing.
Current design, we use a sysfile as a interface to check/fix a file (via pass a 
ino number).
But, this operation is manually triggered by user, instead of automatically  
fix in the kernel.
Why?
1) we should let users make this decision, since some users do not want to fix 
when encountering a file system corruption, maybe they want to keep the file 
system unchanged for a further investigation.
2) frankly speaking, this feature will probably bring a second corruption if 
there is some error in the code, I do not suggest to use automatically fix by 
default in the first version.
3) in the future, if this feature is well proved, we can add a mount option to 
make this automatically fix enabled.


Thanks
Gang
   


>>> 
> Hi Gang,
> 
> I didn't see a need to add a sysfs file for the check and repair. This
> leaves a hard problem for customer to decide. How they decide whether
> they should repair the bad inode since this may cause corruption even
> harder?
> I think the error should be fixed by this feature automaticlly if repair
> helps, of course this can be done only when error=continue is enabled or
> add some mount option for it.
> 
> Thanks,
> Junxiao.
> 
> On 10/28/2015 02:25 PM, Gang He wrote:
>> Implement online file check sysfile interfaces, e.g.
>> how to create the related sysfile according to device name,
>> how to display/handle file check request from the sysfile.
>> 
>> Signed-off-by: Gang He 
>> ---
>>  fs/ocfs2/Makefile|   3 +-
>>  fs/ocfs2/filecheck.c | 566 
> +++
>>  fs/ocfs2/filecheck.h |  48 +
>>  fs/ocfs2/inode.h |   3 +
>>  4 files changed, 619 insertions(+), 1 deletion(-)
>>  create mode 100644 fs/ocfs2/filecheck.c
>>  create mode 100644 fs/ocfs2/filecheck.h
>> 
>> diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
>> index ce210d4..e27e652 100644
>> --- a/fs/ocfs2/Makefile
>> +++ b/fs/ocfs2/Makefile
>> @@ -41,7 +41,8 @@ ocfs2-objs := \
>>  quota_local.o   \
>>  quota_global.o  \
>>  xattr.o \
>> -acl.o
>> +acl.o   \
>> +filecheck.o
>>  
>>  ocfs2_stackglue-objs := stackglue.o
>>  ocfs2_stack_o2cb-objs := stack_o2cb.o
>> diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
>> new file mode 100644
>> index 000..f12ed1f
>> --- /dev/null
>> +++ b/fs/ocfs2/filecheck.c
>> @@ -0,0 +1,566 @@
>> +/* -*- mode: c; c-basic-offset: 8; -*-
>> + * vim: noexpandtab sw=8 ts=8 sts=0:
>> + *
>> + * filecheck.c
>> + *
>> + * Code which implements online file check.
>> + *
>> + * Copyright (C) 2015 Novell.  All rights reserved.
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public
>> + * License as published by the Free Software Foundation, version 2.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "ocfs2.h"
>> +#include "ocfs2_fs.h"
>> +#include "stackglue.h"
>> +#include "inode.h"
>> +
>> +#include "filecheck.h"
>> +
>> +
>> +/* File check error strings,
>> + * must correspond with error number in header file.
>> + */
>> +static const char * const ocfs2_filecheck_errs[] = {
>> +"SUCCESS",
>> +"FAILED",
>> +"INPROGRESS",
>> +"READONLY",
>> +"INVALIDINO",
>> +"BLOCKECC",
>> +"BLOCKNO",
>> +"VALIDFLAG",
>> +"GENERATION",
>> +"UNSUPPORTED"
>> +};
>> +
>> +static DEFINE_SPINLOCK(ocfs2_filecheck_sysfs_lock);
>> +static LIST_HEAD(ocfs2_filecheck_sysfs_list);
>> +
>> +struct ocfs2_filecheck {
>> +struct list_head fc_head;   /* File check entry list head */
>> +spinlock_t fc_lock;
>> +unsigned int fc_max;/* Maximum number of entry in list */
>> +unsigned int fc_size;   /* Current entry count in list */
>> +unsigned int fc_done;   /* File check entries are done in list */
>> +};
>> +
>> +struct ocfs2_filecheck_sysfs_entry {
>> +struct list_head fs_list;
>> +atomic_t fs_count;
>> +struct super_block *fs_sb;
>> +struct kset *fs_kset;
>> +struct ocfs2_filecheck *fs_fcheck;
>> +};
>> +
>> +#define OCFS2_FILECHECK_MAXSIZE 100
>> +#define OCFS2_FILECHECK_MINSIZE 10
>> +
>> +/* File check operation type */
>> +enum {
>> +OCFS2_FILECHECK_TYPE_CHK = 0,   /* Check a file */
>> +OCFS2_FILECHECK_TYPE_FIX,   /* Fix a file */
>> +OCFS2_FILECHECK_TYPE_SET = 100  /* Set file check options */
>> +};
>> +
>> +struct ocfs2_filecheck_entry {
>> +struct list_head fe_list;
>> +unsigned long fe_ino;
>> +unsigned int fe_type;
>> +unsigned short 

Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-11-03 Thread Gang He
Hi Junxiao,


>>> 
> Hi Gang,
> 
> On 11/03/2015 03:54 PM, Gang He wrote:
>> Hi Junxiao,
>> 
>> Thank for your reviewing.
>> Current design, we use a sysfile as a interface to check/fix a file (via 
> pass a ino number).
>> But, this operation is manually triggered by user, instead of automatically  
> fix in the kernel.
>> Why?
>> 1) we should let users make this decision, since some users do not want to 
> fix when encountering a file system corruption, maybe they want to keep the 
> file system unchanged for a further investigation.
> If user don't want this, they should not use error=continue option, let
> fs go after a corruption is very dangerous.
>> 2) frankly speaking, this feature will probably bring a second corruption if 
> there is some error in the code, I do not suggest to use automatically fix by 
> default in the first version.
> I think if this feature could bring more corruption, then this should be
> fixed first.
In theory, this feature will avoid bringing any second corruption after our 
detailed reviewing and discussion.
but, my means is that if there is any carelessness due to our experience 
limitation, it will probably bring a accident second corruption.
this is why, I do not suggest to use automatically fix by default in the kernel 
when a feature is firstly introduced.

> 
> Thanks,
> Junxiao
>> 3) in the future, if this feature is well proved, we can add a mount option 
> to make this automatically fix enabled.
>> 
>> 
>> Thanks
>> Gang
>>
>> 
>> 
>
>>> Hi Gang,
>>>
>>> I didn't see a need to add a sysfs file for the check and repair. This
>>> leaves a hard problem for customer to decide. How they decide whether
>>> they should repair the bad inode since this may cause corruption even
>>> harder?
>>> I think the error should be fixed by this feature automaticlly if repair
>>> helps, of course this can be done only when error=continue is enabled or
>>> add some mount option for it.
>>>
>>> Thanks,
>>> Junxiao.
>>>
>>> On 10/28/2015 02:25 PM, Gang He wrote:
 Implement online file check sysfile interfaces, e.g.
 how to create the related sysfile according to device name,
 how to display/handle file check request from the sysfile.

 Signed-off-by: Gang He 
 ---
  fs/ocfs2/Makefile|   3 +-
  fs/ocfs2/filecheck.c | 566 
>>> +++
  fs/ocfs2/filecheck.h |  48 +
  fs/ocfs2/inode.h |   3 +
  4 files changed, 619 insertions(+), 1 deletion(-)
  create mode 100644 fs/ocfs2/filecheck.c
  create mode 100644 fs/ocfs2/filecheck.h

 diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
 index ce210d4..e27e652 100644
 --- a/fs/ocfs2/Makefile
 +++ b/fs/ocfs2/Makefile
 @@ -41,7 +41,8 @@ ocfs2-objs := \
quota_local.o   \
quota_global.o  \
xattr.o \
 -  acl.o
 +  acl.o   \
 +  filecheck.o
  
  ocfs2_stackglue-objs := stackglue.o
  ocfs2_stack_o2cb-objs := stack_o2cb.o
 diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
 new file mode 100644
 index 000..f12ed1f
 --- /dev/null
 +++ b/fs/ocfs2/filecheck.c
 @@ -0,0 +1,566 @@
 +/* -*- mode: c; c-basic-offset: 8; -*-
 + * vim: noexpandtab sw=8 ts=8 sts=0:
 + *
 + * filecheck.c
 + *
 + * Code which implements online file check.
 + *
 + * Copyright (C) 2015 Novell.  All rights reserved.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public
 + * License as published by the Free Software Foundation, version 2.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * General Public License for more details.
 + */
 +
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +
 +#include "ocfs2.h"
 +#include "ocfs2_fs.h"
 +#include "stackglue.h"
 +#include "inode.h"
 +
 +#include "filecheck.h"
 +
 +
 +/* File check error strings,
 + * must correspond with error number in header file.
 + */
 +static const char * const ocfs2_filecheck_errs[] = {
 +  "SUCCESS",
 +  "FAILED",
 +  "INPROGRESS",
 +  "READONLY",
 +  "INVALIDINO",
 +  "BLOCKECC",
 +  "BLOCKNO",
 +  "VALIDFLAG",
 +  "GENERATION",
 +  "UNSUPPORTED"
 +};
 +
 +static DEFINE_SPINLOCK(ocfs2_filecheck_sysfs_lock);
 +static LIST_HEAD(ocfs2_filecheck_sysfs_list);
 +
 +struct ocfs2_filecheck {
 +  struct list_head fc_head;   /* File check entry list head */
 +  spinlock_t fc_lock;
 +  unsigned int fc_max;/* 

Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-11-03 Thread Junxiao Bi
Hi Gang,

On 11/03/2015 03:54 PM, Gang He wrote:
> Hi Junxiao,
> 
> Thank for your reviewing.
> Current design, we use a sysfile as a interface to check/fix a file (via pass 
> a ino number).
> But, this operation is manually triggered by user, instead of automatically  
> fix in the kernel.
> Why?
> 1) we should let users make this decision, since some users do not want to 
> fix when encountering a file system corruption, maybe they want to keep the 
> file system unchanged for a further investigation.
If user don't want this, they should not use error=continue option, let
fs go after a corruption is very dangerous.
> 2) frankly speaking, this feature will probably bring a second corruption if 
> there is some error in the code, I do not suggest to use automatically fix by 
> default in the first version.
I think if this feature could bring more corruption, then this should be
fixed first.

Thanks,
Junxiao
> 3) in the future, if this feature is well proved, we can add a mount option 
> to make this automatically fix enabled.
> 
> 
> Thanks
> Gang
>
> 
> 

>> Hi Gang,
>>
>> I didn't see a need to add a sysfs file for the check and repair. This
>> leaves a hard problem for customer to decide. How they decide whether
>> they should repair the bad inode since this may cause corruption even
>> harder?
>> I think the error should be fixed by this feature automaticlly if repair
>> helps, of course this can be done only when error=continue is enabled or
>> add some mount option for it.
>>
>> Thanks,
>> Junxiao.
>>
>> On 10/28/2015 02:25 PM, Gang He wrote:
>>> Implement online file check sysfile interfaces, e.g.
>>> how to create the related sysfile according to device name,
>>> how to display/handle file check request from the sysfile.
>>>
>>> Signed-off-by: Gang He 
>>> ---
>>>  fs/ocfs2/Makefile|   3 +-
>>>  fs/ocfs2/filecheck.c | 566 
>> +++
>>>  fs/ocfs2/filecheck.h |  48 +
>>>  fs/ocfs2/inode.h |   3 +
>>>  4 files changed, 619 insertions(+), 1 deletion(-)
>>>  create mode 100644 fs/ocfs2/filecheck.c
>>>  create mode 100644 fs/ocfs2/filecheck.h
>>>
>>> diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
>>> index ce210d4..e27e652 100644
>>> --- a/fs/ocfs2/Makefile
>>> +++ b/fs/ocfs2/Makefile
>>> @@ -41,7 +41,8 @@ ocfs2-objs := \
>>> quota_local.o   \
>>> quota_global.o  \
>>> xattr.o \
>>> -   acl.o
>>> +   acl.o   \
>>> +   filecheck.o
>>>  
>>>  ocfs2_stackglue-objs := stackglue.o
>>>  ocfs2_stack_o2cb-objs := stack_o2cb.o
>>> diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
>>> new file mode 100644
>>> index 000..f12ed1f
>>> --- /dev/null
>>> +++ b/fs/ocfs2/filecheck.c
>>> @@ -0,0 +1,566 @@
>>> +/* -*- mode: c; c-basic-offset: 8; -*-
>>> + * vim: noexpandtab sw=8 ts=8 sts=0:
>>> + *
>>> + * filecheck.c
>>> + *
>>> + * Code which implements online file check.
>>> + *
>>> + * Copyright (C) 2015 Novell.  All rights reserved.
>>> + *
>>> + * This program is free software; you can redistribute it and/or
>>> + * modify it under the terms of the GNU General Public
>>> + * License as published by the Free Software Foundation, version 2.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>> + * General Public License for more details.
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include "ocfs2.h"
>>> +#include "ocfs2_fs.h"
>>> +#include "stackglue.h"
>>> +#include "inode.h"
>>> +
>>> +#include "filecheck.h"
>>> +
>>> +
>>> +/* File check error strings,
>>> + * must correspond with error number in header file.
>>> + */
>>> +static const char * const ocfs2_filecheck_errs[] = {
>>> +   "SUCCESS",
>>> +   "FAILED",
>>> +   "INPROGRESS",
>>> +   "READONLY",
>>> +   "INVALIDINO",
>>> +   "BLOCKECC",
>>> +   "BLOCKNO",
>>> +   "VALIDFLAG",
>>> +   "GENERATION",
>>> +   "UNSUPPORTED"
>>> +};
>>> +
>>> +static DEFINE_SPINLOCK(ocfs2_filecheck_sysfs_lock);
>>> +static LIST_HEAD(ocfs2_filecheck_sysfs_list);
>>> +
>>> +struct ocfs2_filecheck {
>>> +   struct list_head fc_head;   /* File check entry list head */
>>> +   spinlock_t fc_lock;
>>> +   unsigned int fc_max;/* Maximum number of entry in list */
>>> +   unsigned int fc_size;   /* Current entry count in list */
>>> +   unsigned int fc_done;   /* File check entries are done in list */
>>> +};
>>> +
>>> +struct ocfs2_filecheck_sysfs_entry {
>>> +   struct list_head fs_list;
>>> +   atomic_t fs_count;
>>> +   struct super_block *fs_sb;
>>> +   struct kset *fs_kset;
>>> +   struct ocfs2_filecheck *fs_fcheck;
>>> +};
>>> +
>>> +#define OCFS2_FILECHECK_MAXSIZE100
>>> +#define OCFS2_FILECHECK_MINSIZE10
>>> 

Re: [Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-11-02 Thread Junxiao Bi
Hi Gang,

I didn't see a need to add a sysfs file for the check and repair. This
leaves a hard problem for customer to decide. How they decide whether
they should repair the bad inode since this may cause corruption even
harder?
I think the error should be fixed by this feature automaticlly if repair
helps, of course this can be done only when error=continue is enabled or
add some mount option for it.

Thanks,
Junxiao.

On 10/28/2015 02:25 PM, Gang He wrote:
> Implement online file check sysfile interfaces, e.g.
> how to create the related sysfile according to device name,
> how to display/handle file check request from the sysfile.
> 
> Signed-off-by: Gang He 
> ---
>  fs/ocfs2/Makefile|   3 +-
>  fs/ocfs2/filecheck.c | 566 
> +++
>  fs/ocfs2/filecheck.h |  48 +
>  fs/ocfs2/inode.h |   3 +
>  4 files changed, 619 insertions(+), 1 deletion(-)
>  create mode 100644 fs/ocfs2/filecheck.c
>  create mode 100644 fs/ocfs2/filecheck.h
> 
> diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
> index ce210d4..e27e652 100644
> --- a/fs/ocfs2/Makefile
> +++ b/fs/ocfs2/Makefile
> @@ -41,7 +41,8 @@ ocfs2-objs := \
>   quota_local.o   \
>   quota_global.o  \
>   xattr.o \
> - acl.o
> + acl.o   \
> + filecheck.o
>  
>  ocfs2_stackglue-objs := stackglue.o
>  ocfs2_stack_o2cb-objs := stack_o2cb.o
> diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
> new file mode 100644
> index 000..f12ed1f
> --- /dev/null
> +++ b/fs/ocfs2/filecheck.c
> @@ -0,0 +1,566 @@
> +/* -*- mode: c; c-basic-offset: 8; -*-
> + * vim: noexpandtab sw=8 ts=8 sts=0:
> + *
> + * filecheck.c
> + *
> + * Code which implements online file check.
> + *
> + * Copyright (C) 2015 Novell.  All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public
> + * License as published by the Free Software Foundation, version 2.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "ocfs2.h"
> +#include "ocfs2_fs.h"
> +#include "stackglue.h"
> +#include "inode.h"
> +
> +#include "filecheck.h"
> +
> +
> +/* File check error strings,
> + * must correspond with error number in header file.
> + */
> +static const char * const ocfs2_filecheck_errs[] = {
> + "SUCCESS",
> + "FAILED",
> + "INPROGRESS",
> + "READONLY",
> + "INVALIDINO",
> + "BLOCKECC",
> + "BLOCKNO",
> + "VALIDFLAG",
> + "GENERATION",
> + "UNSUPPORTED"
> +};
> +
> +static DEFINE_SPINLOCK(ocfs2_filecheck_sysfs_lock);
> +static LIST_HEAD(ocfs2_filecheck_sysfs_list);
> +
> +struct ocfs2_filecheck {
> + struct list_head fc_head;   /* File check entry list head */
> + spinlock_t fc_lock;
> + unsigned int fc_max;/* Maximum number of entry in list */
> + unsigned int fc_size;   /* Current entry count in list */
> + unsigned int fc_done;   /* File check entries are done in list */
> +};
> +
> +struct ocfs2_filecheck_sysfs_entry {
> + struct list_head fs_list;
> + atomic_t fs_count;
> + struct super_block *fs_sb;
> + struct kset *fs_kset;
> + struct ocfs2_filecheck *fs_fcheck;
> +};
> +
> +#define OCFS2_FILECHECK_MAXSIZE  100
> +#define OCFS2_FILECHECK_MINSIZE  10
> +
> +/* File check operation type */
> +enum {
> + OCFS2_FILECHECK_TYPE_CHK = 0,   /* Check a file */
> + OCFS2_FILECHECK_TYPE_FIX,   /* Fix a file */
> + OCFS2_FILECHECK_TYPE_SET = 100  /* Set file check options */
> +};
> +
> +struct ocfs2_filecheck_entry {
> + struct list_head fe_list;
> + unsigned long fe_ino;
> + unsigned int fe_type;
> + unsigned short fe_done:1;
> + unsigned short fe_status:15;
> +};
> +
> +struct ocfs2_filecheck_args {
> + unsigned int fa_type;
> + union {
> + unsigned long fa_ino;
> + unsigned int fa_len;
> + };
> +};
> +
> +static const char *
> +ocfs2_filecheck_error(int errno)
> +{
> + if (!errno)
> + return ocfs2_filecheck_errs[errno];
> +
> + BUG_ON(errno < OCFS2_FILECHECK_ERR_START ||
> + errno > OCFS2_FILECHECK_ERR_END);
> + return ocfs2_filecheck_errs[errno - OCFS2_FILECHECK_ERR_START + 1];
> +}
> +
> +static ssize_t ocfs2_filecheck_show(struct kobject *kobj,
> + struct kobj_attribute *attr,
> + char *buf);
> +static ssize_t ocfs2_filecheck_store(struct kobject *kobj,
> + struct kobj_attribute *attr,
> +

[Ocfs2-devel] [PATCH v2 2/4] ocfs2: sysfile interfaces for online file check

2015-10-28 Thread Gang He
Implement online file check sysfile interfaces, e.g.
how to create the related sysfile according to device name,
how to display/handle file check request from the sysfile.

Signed-off-by: Gang He 
---
 fs/ocfs2/Makefile|   3 +-
 fs/ocfs2/filecheck.c | 566 +++
 fs/ocfs2/filecheck.h |  48 +
 fs/ocfs2/inode.h |   3 +
 4 files changed, 619 insertions(+), 1 deletion(-)
 create mode 100644 fs/ocfs2/filecheck.c
 create mode 100644 fs/ocfs2/filecheck.h

diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
index ce210d4..e27e652 100644
--- a/fs/ocfs2/Makefile
+++ b/fs/ocfs2/Makefile
@@ -41,7 +41,8 @@ ocfs2-objs := \
quota_local.o   \
quota_global.o  \
xattr.o \
-   acl.o
+   acl.o   \
+   filecheck.o
 
 ocfs2_stackglue-objs := stackglue.o
 ocfs2_stack_o2cb-objs := stack_o2cb.o
diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
new file mode 100644
index 000..f12ed1f
--- /dev/null
+++ b/fs/ocfs2/filecheck.c
@@ -0,0 +1,566 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * filecheck.c
+ *
+ * Code which implements online file check.
+ *
+ * Copyright (C) 2015 Novell.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ocfs2.h"
+#include "ocfs2_fs.h"
+#include "stackglue.h"
+#include "inode.h"
+
+#include "filecheck.h"
+
+
+/* File check error strings,
+ * must correspond with error number in header file.
+ */
+static const char * const ocfs2_filecheck_errs[] = {
+   "SUCCESS",
+   "FAILED",
+   "INPROGRESS",
+   "READONLY",
+   "INVALIDINO",
+   "BLOCKECC",
+   "BLOCKNO",
+   "VALIDFLAG",
+   "GENERATION",
+   "UNSUPPORTED"
+};
+
+static DEFINE_SPINLOCK(ocfs2_filecheck_sysfs_lock);
+static LIST_HEAD(ocfs2_filecheck_sysfs_list);
+
+struct ocfs2_filecheck {
+   struct list_head fc_head;   /* File check entry list head */
+   spinlock_t fc_lock;
+   unsigned int fc_max;/* Maximum number of entry in list */
+   unsigned int fc_size;   /* Current entry count in list */
+   unsigned int fc_done;   /* File check entries are done in list */
+};
+
+struct ocfs2_filecheck_sysfs_entry {
+   struct list_head fs_list;
+   atomic_t fs_count;
+   struct super_block *fs_sb;
+   struct kset *fs_kset;
+   struct ocfs2_filecheck *fs_fcheck;
+};
+
+#define OCFS2_FILECHECK_MAXSIZE100
+#define OCFS2_FILECHECK_MINSIZE10
+
+/* File check operation type */
+enum {
+   OCFS2_FILECHECK_TYPE_CHK = 0,   /* Check a file */
+   OCFS2_FILECHECK_TYPE_FIX,   /* Fix a file */
+   OCFS2_FILECHECK_TYPE_SET = 100  /* Set file check options */
+};
+
+struct ocfs2_filecheck_entry {
+   struct list_head fe_list;
+   unsigned long fe_ino;
+   unsigned int fe_type;
+   unsigned short fe_done:1;
+   unsigned short fe_status:15;
+};
+
+struct ocfs2_filecheck_args {
+   unsigned int fa_type;
+   union {
+   unsigned long fa_ino;
+   unsigned int fa_len;
+   };
+};
+
+static const char *
+ocfs2_filecheck_error(int errno)
+{
+   if (!errno)
+   return ocfs2_filecheck_errs[errno];
+
+   BUG_ON(errno < OCFS2_FILECHECK_ERR_START ||
+   errno > OCFS2_FILECHECK_ERR_END);
+   return ocfs2_filecheck_errs[errno - OCFS2_FILECHECK_ERR_START + 1];
+}
+
+static ssize_t ocfs2_filecheck_show(struct kobject *kobj,
+   struct kobj_attribute *attr,
+   char *buf);
+static ssize_t ocfs2_filecheck_store(struct kobject *kobj,
+   struct kobj_attribute *attr,
+   const char *buf, size_t count);
+static struct kobj_attribute ocfs2_attr_filecheck =
+   __ATTR(filecheck, S_IRUSR | S_IWUSR,
+   ocfs2_filecheck_show,
+   ocfs2_filecheck_store);
+
+static int ocfs2_filecheck_sysfs_wait(atomic_t *p)
+{
+   schedule();
+   return 0;
+}
+
+static void
+ocfs2_filecheck_sysfs_free(struct ocfs2_filecheck_sysfs_entry *entry)
+{
+   struct ocfs2_filecheck_entry *p;
+
+   if (!atomic_dec_and_test(>fs_count))
+   wait_on_atomic_t(>fs_count, ocfs2_filecheck_sysfs_wait,
+