On 04/06/2018 04:41 AM, Sayan Ghosh wrote: > The patch is on top of Linux Kernel 4.7.2. > > Signed-off-by: Sayan Ghosh <sgdgp.2014@xxxxxxxxx> > --- > fs/ext4/ext4.h | 1 + > fs/ext4/extents.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- > 2 files changed, 114 insertions(+), 3 deletions(-) > > diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c > index de9194f..aaff3a3 100755 > --- a/fs/ext4/extents.c > +++ b/fs/ext4/extents.c > @@ -58,6 +58,12 @@ > #define EXT4_EXT_DATA_VALID2 0x10 /* second half contains valid data */ > > /* > + * Starting block numbers for low and high grades > + */ > +#define LOW_GRADE_STARTING_BLOCK 0 > +#define HIGH_GRADE_STARTING_BLOCK 1249280 > + > +/* > * read_grade_xattr() is used to read the grade array from the > extended attribute. > */ > void read_grade_xattr(struct inode *inode,struct grade_struct *grade_array) > @@ -92,6 +98,43 @@ unsigned long long read_count_xattr(struct inode *inode) > return total; > } > > +/* > + * find_grade() is to find the grade of a logical block. > + * This also returns the length of graded or ungraded portion > + * starting from that logical block number (gets stored in the variable > + * req_len). The return value is 1 for high grade and 0 otherwise. > + */ Lots of style issues: > +int find_grade(struct grade_struct* grade_array, unsigned long long > total, ext4_fsblk_t val, unsigned long long *req_len) line too long. > +{ > + if (val >= (grade_array[total -1].block_num + grade_array[total -1].len) ){ > + if (req_len != NULL) > + (*req_len) = 0; > + return 0; > + } use tabs, not spaces. and indentation should be 8, not 4. (many places) > + unsigned long long beg, end, mid; Don't declare variables after code. > + beg = 0; > + end = total-1; > + while (beg <= end){ > + mid = (beg + end)/2; > + if ((val >= grade_array[mid].block_num) && (val <= > (grade_array[mid].block_num + grade_array[mid].len - 1)) ){ line too long. > + if (req_len != NULL) > + (*req_len) = grade_array[mid].len; > + return 1; > + } > + if(beg == end) space after "if" > + break; > + if (grade_array[mid].block_num > val){ > + end = (mid > 0) ? (mid - 1) : 0; > + } > + else{ > + beg = mid + 1; > + } > + } > + if (req_len != NULL) > + (*req_len) = grade_array[mid].block_num - val; > + return 0; > +} > + > static __le32 ext4_extent_block_csum(struct inode *inode, > struct ext4_extent_header *eh) > { -- ~Randy