Re: [PATCH] erofs: using switch-case while checking the inode type.

2019-09-03 Thread Greg KH
On Wed, Sep 04, 2019 at 10:12:47AM +0800, Gao Xiang wrote:
> Hi Greg,
> 
> On Fri, Aug 30, 2019 at 10:22:33PM +0800, Gao Xiang wrote:
> > On Fri, Aug 30, 2019 at 07:59:48PM +0800, Gao Xiang wrote:
> > > Hi Pratik,
> > > 
> > > The subject line could be better as '[PATCH v2] xx'...
> > > 
> > > On Fri, Aug 30, 2019 at 03:26:15PM +0530, Pratik Shinde wrote:
> > > > while filling the linux inode, using switch-case statement to check
> > > > the type of inode.
> > > > switch-case statement looks more clean here.
> > > > 
> > > > Signed-off-by: Pratik Shinde 
> > > 
> > > I have no problem of this patch, and I will do a test and reply
> > > you "Reviewed-by:" in hours (I'm doing another patchset to resolve
> > > what Christoph suggested again)...
> > 
> > Reviewed-by: Gao Xiang 
> 
> ping.. could you kindly merge this patch, the following patchset
> has dependency on it...

Will go do that now, sorry for the delay.

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 00/25] erofs: patchset addressing Christoph's comments

2019-09-03 Thread Gao Xiang
Hi Christoph,

On Wed, Sep 04, 2019 at 07:16:55AM +0200, Christoph Hellwig wrote:
> On Wed, Sep 04, 2019 at 10:08:47AM +0800, Gao Xiang wrote:
> > Hi,
> > 
> > This patchset is based on the following patch by Pratik Shinde,
> > https://lore.kernel.org/linux-erofs/20190830095615.10995-1-pratikshinde...@gmail.com/
> > 
> > All patches addressing Christoph's comments on v6, which are trivial,
> > most deleted code are from erofs specific fault injection, which was
> > followed f2fs and previously discussed in earlier topic [1], but
> > let's follow what Christoph's said now.
> > 
> > Comments and suggestions are welcome...
> 
> Do you have a git branch available somewhere containing the state
> with all these patches applied?

here you are...
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/linux.git -b 
erofs-experimental

Thanks,
Gao Xiang

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 00/25] erofs: patchset addressing Christoph's comments

2019-09-03 Thread Christoph Hellwig
On Wed, Sep 04, 2019 at 10:08:47AM +0800, Gao Xiang wrote:
> Hi,
> 
> This patchset is based on the following patch by Pratik Shinde,
> https://lore.kernel.org/linux-erofs/20190830095615.10995-1-pratikshinde...@gmail.com/
> 
> All patches addressing Christoph's comments on v6, which are trivial,
> most deleted code are from erofs specific fault injection, which was
> followed f2fs and previously discussed in earlier topic [1], but
> let's follow what Christoph's said now.
> 
> Comments and suggestions are welcome...

Do you have a git branch available somewhere containing the state
with all these patches applied?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[staging:staging-testing 314/401] ERROR: "__udivdi3" [drivers/iio/common/hid-sensors/hid-sensor-iio-common.ko] undefined!

2019-09-03 Thread kbuild test robot
tree:   
https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/staging.git 
staging-testing
head:   74eb9c06b1d722468db397595ac6834b9e4ac235
commit: 473d12f7638c93acbd9296a8cd455b203d5eb528 [314/401] iio: 
hid-sensor-attributes: Convert to use int_pow()
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 7.4.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 473d12f7638c93acbd9296a8cd455b203d5eb528
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 

All errors (new ones prefixed by >>):

>> ERROR: "__udivdi3" [drivers/iio/common/hid-sensors/hid-sensor-iio-common.ko] 
>> undefined!
>> ERROR: "__umoddi3" [drivers/iio/common/hid-sensors/hid-sensor-iio-common.ko] 
>> undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[staging:staging-testing 314/401] drivers/iio/common/hid-sensors/hid-sensor-attributes.c:312: undefined reference to `__udivdi3'

2019-09-03 Thread kbuild test robot
tree:   
https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/staging.git 
staging-testing
head:   74eb9c06b1d722468db397595ac6834b9e4ac235
commit: 473d12f7638c93acbd9296a8cd455b203d5eb528 [314/401] iio: 
hid-sensor-attributes: Convert to use int_pow()
config: i386-randconfig-e004-201935 (attached as .config)
compiler: gcc-7 (Debian 7.4.0-11) 7.4.0
reproduce:
git checkout 473d12f7638c93acbd9296a8cd455b203d5eb528
# save the attached .config to linux build tree
make ARCH=i386 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 

All errors (new ones prefixed by >>):

   ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.o: in function 
`adjust_exponent_nano':
>> drivers/iio/common/hid-sensors/hid-sensor-attributes.c:312: undefined 
>> reference to `__udivdi3'
>> ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.c:314: undefined 
>> reference to `__umoddi3'
>> ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.c:324: undefined 
>> reference to `__udivdi3'
   ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.c:325: undefined 
reference to `__umoddi3'
   ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.c:328: undefined 
reference to `__udivdi3'
   ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.c:330: undefined 
reference to `__umoddi3'
   ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.o: in function 
`split_micro_fraction':
   drivers/iio/common/hid-sensors/hid-sensor-attributes.c:96: undefined 
reference to `__udivdi3'
   ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.c:97: undefined 
reference to `__umoddi3'
   ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.o: in function 
`convert_to_vtf_format':
   drivers/iio/common/hid-sensors/hid-sensor-attributes.c:140: undefined 
reference to `__udivdi3'
   ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.c:142: undefined 
reference to `__udivdi3'
   ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.o: in function 
`hid_sensor_write_samp_freq_value':
   drivers/iio/common/hid-sensors/hid-sensor-attributes.c:208: undefined 
reference to `__udivdi3'
   ld: drivers/iio/common/hid-sensors/hid-sensor-attributes.c:210: undefined 
reference to `__udivdi3'

vim +312 drivers/iio/common/hid-sensors/hid-sensor-attributes.c

   284  
   285  /*
   286   * This fuction applies the unit exponent to the scale.
   287   * For example:
   288   * 9.80665 ->exp:2-> val0[980]val1[66500]
   289   * 9.000806000 ->exp:2-> val0[900]val1[8060]
   290   * 0.174535293 ->exp:2-> val0[17]val1[453529300]
   291   * 1.001745329 ->exp:0-> val0[1]val1[1745329]
   292   * 1.001745329 ->exp:2-> val0[100]val1[174532900]
   293   * 1.001745329 ->exp:4-> val0[10017]val1[45329]
   294   * 9.80665 ->exp:-2-> val0[0]val1[98066500]
   295   */
   296  static void adjust_exponent_nano(int *val0, int *val1, int scale0,
   297int scale1, int exp)
   298  {
   299  int i;
   300  int x;
   301  int res;
   302  int rem;
   303  
   304  if (exp > 0) {
   305  *val0 = scale0 * int_pow(10, exp);
   306  res = 0;
   307  if (exp > 9) {
   308  *val1 = 0;
   309  return;
   310  }
   311  for (i = 0; i < exp; ++i) {
 > 312  x = scale1 / int_pow(10, 8 - i);
   313  res += int_pow(10, exp - 1 - i) * x;
 > 314  scale1 = scale1 % int_pow(10, 8 - i);
   315  }
   316  *val0 += res;
   317  *val1 = scale1 * int_pow(10, exp);
   318  } else if (exp < 0) {
   319  exp = abs(exp);
   320  if (exp > 9) {
   321  *val0 = *val1 = 0;
   322  return;
   323  }
 > 324  *val0 = scale0 / int_pow(10, exp);
   325  rem = scale0 % int_pow(10, exp);
   326  res = 0;
   327  for (i = 0; i < (9 - exp); ++i) {
   328  x = scale1 / int_pow(10, 8 - i);
   329  res += int_pow(10, 8 - exp - i) * x;
   330  scale1 = scale1 % int_pow(10, 8 - i);
   331  }
   332  *val1 = rem * int_pow(10, 9 - exp) + res;
   333  } else {
   334  *val0 = scale0;
   335  *val1 = scale1;
   336  }
   337  }
   338  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo

Re: [PATCH v2 00/25] erofs: patchset addressing Christoph's comments

2019-09-03 Thread Chao Yu
On 2019/9/4 10:08, Gao Xiang wrote:
> Hi,
> 
> This patchset is based on the following patch by Pratik Shinde,
> https://lore.kernel.org/linux-erofs/20190830095615.10995-1-pratikshinde...@gmail.com/
> 
> All patches addressing Christoph's comments on v6, which are trivial,
> most deleted code are from erofs specific fault injection, which was
> followed f2fs and previously discussed in earlier topic [1], but
> let's follow what Christoph's said now.

Reviewed-by: Chao Yu 

Thanks,

> 
> Comments and suggestions are welcome...
> 
> [1] https://lore.kernel.org/r/1eed1e6b-f95e-aa8e-c3e7-e9870401e...@kernel.org/
> 
> changes since v1:
>  - leave some comments near the numbers to indicate where they are stored;
>  - avoid a u8 cast;
>  - use erofs_{err,info,dbg} and print sb->s_id as a prefix before
>the actual message;
>  - add a on-disk title in erofs_fs.h
>  - use feature_{compat,incompat} rather than features and requirements;
>  - suggestions on erofs_grab_bio:
>https://lore.kernel.org/r/20190902122016.gl15...@infradead.org/
>  - use compact/extended instead of erofs_inode_v1/v2 and
>i_format instead of i_advise;
>  - avoid chained if/else if/else if statements in erofs_read_inode;
>  - avoid erofs_vmap/vunmap wrappers;
>  - use read_cache_page_gfp for erofs_get_meta_page;
> 
> Gao Xiang (25):
>   erofs: remove all the byte offset comments
>   erofs: on-disk format should have explicitly assigned numbers
>   erofs: some macros are much more readable as a function
>   erofs: kill __packed for on-disk structures
>   erofs: update erofs_inode_is_data_compressed helper
>   erofs: use feature_incompat rather than requirements
>   erofs: better naming for erofs inode related stuffs
>   erofs: kill erofs_{init,exit}_inode_cache
>   erofs: use erofs_inode naming
>   erofs: update erofs_fs.h comments
>   erofs: update comments in inode.c
>   erofs: better erofs symlink stuffs
>   erofs: use dsb instead of layout for ondisk super_block
>   erofs: kill verbose debug info in erofs_fill_super
>   erofs: localize erofs_grab_bio()
>   erofs: kill prio and nofail of erofs_get_meta_page()
>   erofs: kill __submit_bio()
>   erofs: add "erofs_" prefix for common and short functions
>   erofs: kill all erofs specific fault injection
>   erofs: kill use_vmap module parameter
>   erofs: save one level of indentation
>   erofs: rename errln/infoln/debugln to erofs_{err,info,dbg}
>   erofs: use read_mapping_page instead of sb_bread
>   erofs: always use iget5_locked
>   erofs: use read_cache_page_gfp for erofs_get_meta_page
> 
>  Documentation/filesystems/erofs.txt |   9 -
>  fs/erofs/Kconfig|   7 -
>  fs/erofs/data.c | 118 +++
>  fs/erofs/decompressor.c |  76 +++
>  fs/erofs/dir.c  |  17 +-
>  fs/erofs/erofs_fs.h | 197 +-
>  fs/erofs/inode.c| 297 ++--
>  fs/erofs/internal.h | 192 --
>  fs/erofs/namei.c|  21 +-
>  fs/erofs/super.c| 282 +++---
>  fs/erofs/xattr.c|  41 ++--
>  fs/erofs/xattr.h|   4 +-
>  fs/erofs/zdata.c|  63 +++---
>  fs/erofs/zdata.h|   2 +-
>  fs/erofs/zmap.c |  73 +++
>  include/trace/events/erofs.h|  14 +-
>  16 files changed, 578 insertions(+), 835 deletions(-)
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] erofs: using switch-case while checking the inode type.

2019-09-03 Thread Gao Xiang
Hi Greg,

On Fri, Aug 30, 2019 at 10:22:33PM +0800, Gao Xiang wrote:
> On Fri, Aug 30, 2019 at 07:59:48PM +0800, Gao Xiang wrote:
> > Hi Pratik,
> > 
> > The subject line could be better as '[PATCH v2] xx'...
> > 
> > On Fri, Aug 30, 2019 at 03:26:15PM +0530, Pratik Shinde wrote:
> > > while filling the linux inode, using switch-case statement to check
> > > the type of inode.
> > > switch-case statement looks more clean here.
> > > 
> > > Signed-off-by: Pratik Shinde 
> > 
> > I have no problem of this patch, and I will do a test and reply
> > you "Reviewed-by:" in hours (I'm doing another patchset to resolve
> > what Christoph suggested again)...
> 
> Reviewed-by: Gao Xiang 

ping.. could you kindly merge this patch, the following patchset
has dependency on it...

Thanks,
Gao Xiang

> 
> Thanks,
> Gao Xiang
> 
> > 
> > Thanks,
> > Gao Xiang
> > 
> > > ---
> > >  fs/erofs/inode.c | 18 --
> > >  1 file changed, 12 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
> > > index 80f4fe9..6336cc1 100644
> > > --- a/fs/erofs/inode.c
> > > +++ b/fs/erofs/inode.c
> > > @@ -190,22 +190,28 @@ static int fill_inode(struct inode *inode, int 
> > > isdir)
> > >   err = read_inode(inode, data + ofs);
> > >   if (!err) {
> > >   /* setup the new inode */
> > > - if (S_ISREG(inode->i_mode)) {
> > > + switch (inode->i_mode & S_IFMT) {
> > > + case S_IFREG:
> > >   inode->i_op = &erofs_generic_iops;
> > >   inode->i_fop = &generic_ro_fops;
> > > - } else if (S_ISDIR(inode->i_mode)) {
> > > + break;
> > > + case S_IFDIR:
> > >   inode->i_op = &erofs_dir_iops;
> > >   inode->i_fop = &erofs_dir_fops;
> > > - } else if (S_ISLNK(inode->i_mode)) {
> > > + break;
> > > + case S_IFLNK:
> > >   /* by default, page_get_link is used for symlink */
> > >   inode->i_op = &erofs_symlink_iops;
> > >   inode_nohighmem(inode);
> > > - } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
> > > - S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
> > > + break;
> > > + case S_IFCHR:
> > > + case S_IFBLK:
> > > + case S_IFIFO:
> > > + case S_IFSOCK:
> > >   inode->i_op = &erofs_generic_iops;
> > >   init_special_inode(inode, inode->i_mode, inode->i_rdev);
> > >   goto out_unlock;
> > > - } else {
> > > + default:
> > >   err = -EFSCORRUPTED;
> > >   goto out_unlock;
> > >   }
> > > -- 
> > > 2.9.3
> > > 
> > > ___
> > > devel mailing list
> > > de...@linuxdriverproject.org
> > > http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 18/25] erofs: add "erofs_" prefix for common and short functions

2019-09-03 Thread Gao Xiang
Add erofs_ prefix to free_inode, alloc_inode, ...

Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/data.c |  4 ++--
 fs/erofs/decompressor.c | 22 +++---
 fs/erofs/inode.c|  8 
 fs/erofs/internal.h |  2 +-
 fs/erofs/namei.c| 12 ++--
 fs/erofs/super.c| 40 
 fs/erofs/zdata.c| 19 ++-
 7 files changed, 54 insertions(+), 53 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 70b1e353756e..3ce87a88452a 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -9,7 +9,7 @@
 
 #include 
 
-static inline void read_endio(struct bio *bio)
+static void erofs_readendio(struct bio *bio)
 {
struct super_block *const sb = bio->bi_private;
struct bio_vec *bvec;
@@ -45,7 +45,7 @@ static struct bio *erofs_grab_raw_bio(struct super_block *sb,
 {
struct bio *bio = bio_alloc(GFP_NOIO, nr_pages);
 
-   bio->bi_end_io = read_endio;
+   bio->bi_end_io = erofs_readendio;
bio_set_dev(bio, sb->s_bdev);
bio->bi_iter.bi_sector = (sector_t)blkaddr << LOG_SECTORS_PER_BLOCK;
bio->bi_private = sb;
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 555c04730f87..8ed38504a9f1 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -32,8 +32,8 @@ static bool use_vmap;
 module_param(use_vmap, bool, 0444);
 MODULE_PARM_DESC(use_vmap, "Use vmap() instead of vm_map_ram() (default 0)");
 
-static int lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
-struct list_head *pagepool)
+static int z_erofs_lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
+struct list_head *pagepool)
 {
const unsigned int nr =
PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
@@ -114,7 +114,7 @@ static void *generic_copy_inplace_data(struct 
z_erofs_decompress_req *rq,
return tmp;
 }
 
-static int lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
+static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
 {
unsigned int inputmargin, inlen;
u8 *src;
@@ -188,8 +188,8 @@ static struct z_erofs_decompressor decompressors[] = {
.name = "shifted"
},
[Z_EROFS_COMPRESSION_LZ4] = {
-   .prepare_destpages = lz4_prepare_destpages,
-   .decompress = lz4_decompress,
+   .prepare_destpages = z_erofs_lz4_prepare_destpages,
+   .decompress = z_erofs_lz4_decompress,
.name = "lz4"
},
 };
@@ -247,8 +247,8 @@ static void erofs_vunmap(const void *mem, unsigned int 
count)
vunmap(mem);
 }
 
-static int decompress_generic(struct z_erofs_decompress_req *rq,
- struct list_head *pagepool)
+static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
+ struct list_head *pagepool)
 {
const unsigned int nrpages_out =
PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
@@ -308,8 +308,8 @@ static int decompress_generic(struct z_erofs_decompress_req 
*rq,
return ret;
 }
 
-static int shifted_decompress(const struct z_erofs_decompress_req *rq,
- struct list_head *pagepool)
+static int z_erofs_shifted_transform(const struct z_erofs_decompress_req *rq,
+struct list_head *pagepool)
 {
const unsigned int nrpages_out =
PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
@@ -353,7 +353,7 @@ int z_erofs_decompress(struct z_erofs_decompress_req *rq,
   struct list_head *pagepool)
 {
if (rq->alg == Z_EROFS_COMPRESSION_SHIFTED)
-   return shifted_decompress(rq, pagepool);
-   return decompress_generic(rq, pagepool);
+   return z_erofs_shifted_transform(rq, pagepool);
+   return z_erofs_decompress_generic(rq, pagepool);
 }
 
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 8d496adbeaea..384905e0677c 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -9,7 +9,7 @@
 #include 
 
 /* no locking */
-static int read_inode(struct inode *inode, void *data)
+static int erofs_read_inode(struct inode *inode, void *data)
 {
struct erofs_inode *vi = EROFS_I(inode);
struct erofs_inode_compact *dic = data;
@@ -163,7 +163,7 @@ static int erofs_fill_symlink(struct inode *inode, void 
*data,
return 0;
 }
 
-static int fill_inode(struct inode *inode, int isdir)
+static int erofs_fill_inode(struct inode *inode, int isdir)
 {
struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb);
struct erofs_inode *vi = EROFS_I(inode);
@@ -193,7 +193,7 @@ static int fill_inode(struct inode *inode, int isdir)
DBG_BUGON(!PageUptodate(page));
data = page_address(page);
 
-   err = read_in

[PATCH v2 20/25] erofs: kill use_vmap module parameter

2019-09-03 Thread Gao Xiang
As Christoph said [1],
"vm_map_ram is supposed to generally behave better.  So if
it doesn't please report that that to the arch maintainer
and linux-mm so that they can look into the issue.  Having
user make choices of deep down kernel internals is just
a horrible interface.

Please talk to maintainers of other bits of the kernel
if you see issues and / or need enhancements. "

Let's redo the previous conclusion and kill the vmap
approach.

[1] https://lore.kernel.org/r/20190830165533.ga10...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 Documentation/filesystems/erofs.txt |  4 ---
 fs/erofs/decompressor.c | 46 -
 2 files changed, 13 insertions(+), 37 deletions(-)

diff --git a/Documentation/filesystems/erofs.txt 
b/Documentation/filesystems/erofs.txt
index c3b5f603b2b6..b0c085326e2e 100644
--- a/Documentation/filesystems/erofs.txt
+++ b/Documentation/filesystems/erofs.txt
@@ -67,10 +67,6 @@ cache_strategy=%s  Select a strategy for cached 
decompression from now on:
It still does in-place I/O decompression
for the rest compressed physical clusters.
 
-Module parameters
-=
-use_vmap=[0|1] Use vmap() instead of vm_map_ram() (default 0).
-
 On-disk details
 ===
 
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 8ed38504a9f1..37177d49d125 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -28,10 +28,6 @@ struct z_erofs_decompressor {
char *name;
 };
 
-static bool use_vmap;
-module_param(use_vmap, bool, 0444);
-MODULE_PARM_DESC(use_vmap, "Use vmap() instead of vm_map_ram() (default 0)");
-
 static int z_erofs_lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
 struct list_head *pagepool)
 {
@@ -221,32 +217,6 @@ static void copy_from_pcpubuf(struct page **out, const 
char *dst,
}
 }
 
-static void *erofs_vmap(struct page **pages, unsigned int count)
-{
-   int i = 0;
-
-   if (use_vmap)
-   return vmap(pages, count, VM_MAP, PAGE_KERNEL);
-
-   while (1) {
-   void *addr = vm_map_ram(pages, count, -1, PAGE_KERNEL);
-
-   /* retry two more times (totally 3 times) */
-   if (addr || ++i >= 3)
-   return addr;
-   vm_unmap_aliases();
-   }
-   return NULL;
-}
-
-static void erofs_vunmap(const void *mem, unsigned int count)
-{
-   if (!use_vmap)
-   vm_unmap_ram(mem, count);
-   else
-   vunmap(mem);
-}
-
 static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
  struct list_head *pagepool)
 {
@@ -255,7 +225,7 @@ static int z_erofs_decompress_generic(struct 
z_erofs_decompress_req *rq,
const struct z_erofs_decompressor *alg = decompressors + rq->alg;
unsigned int dst_maptype;
void *dst;
-   int ret;
+   int ret, i;
 
if (nrpages_out == 1 && !rq->inplace_io) {
DBG_BUGON(!*rq->out);
@@ -293,9 +263,19 @@ static int z_erofs_decompress_generic(struct 
z_erofs_decompress_req *rq,
goto dstmap_out;
}
 
-   dst = erofs_vmap(rq->out, nrpages_out);
+   i = 0;
+   while (1) {
+   dst = vm_map_ram(rq->out, nrpages_out, -1, PAGE_KERNEL);
+
+   /* retry two more times (totally 3 times) */
+   if (dst || ++i >= 3)
+   break;
+   vm_unmap_aliases();
+   }
+
if (!dst)
return -ENOMEM;
+
dst_maptype = 2;
 
 dstmap_out:
@@ -304,7 +284,7 @@ static int z_erofs_decompress_generic(struct 
z_erofs_decompress_req *rq,
if (!dst_maptype)
kunmap_atomic(dst);
else if (dst_maptype == 2)
-   erofs_vunmap(dst, nrpages_out);
+   vm_unmap_ram(dst, nrpages_out);
return ret;
 }
 
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 22/25] erofs: rename errln/infoln/debugln to erofs_{err, info, dbg}

2019-09-03 Thread Gao Xiang
Add prefix "erofs_" to these functions and print
sb->s_id as a prefix to erofs_{err, info} so that
the user knows which file system is affected.

Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/data.c | 10 +++--
 fs/erofs/decompressor.c |  5 +--
 fs/erofs/dir.c  | 17 +
 fs/erofs/inode.c| 31 ---
 fs/erofs/internal.h | 14 +--
 fs/erofs/namei.c|  9 +++--
 fs/erofs/super.c| 83 +++--
 fs/erofs/xattr.c|  8 ++--
 fs/erofs/zdata.c| 13 ---
 fs/erofs/zdata.h|  2 +-
 fs/erofs/zmap.c | 37 ++
 11 files changed, 139 insertions(+), 90 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index b5f5b8592d14..eb7bbae89ed0 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -137,8 +137,9 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
 
/* inline data should be located in one meta block */
if (erofs_blkoff(map->m_pa) + map->m_plen > PAGE_SIZE) {
-   errln("inline data cross block boundary @ nid %llu",
- vi->nid);
+   erofs_err(inode->i_sb,
+ "inline data cross block boundary @ nid %llu",
+ vi->nid);
DBG_BUGON(1);
err = -EFSCORRUPTED;
goto err_out;
@@ -146,8 +147,9 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
 
map->m_flags |= EROFS_MAP_META;
} else {
-   errln("internal error @ nid: %llu (size %llu), m_la 0x%llx",
- vi->nid, inode->i_size, map->m_la);
+   erofs_err(inode->i_sb,
+ "internal error @ nid: %llu (size %llu), m_la 0x%llx",
+ vi->nid, inode->i_size, map->m_la);
DBG_BUGON(1);
err = -EIO;
goto err_out;
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 37177d49d125..19f89f9fb10c 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -161,9 +161,8 @@ static int z_erofs_lz4_decompress(struct 
z_erofs_decompress_req *rq, u8 *out)
  inlen, rq->outputsize,
  rq->outputsize);
if (ret < 0) {
-   errln("%s, failed to decompress, in[%p, %u, %u] out[%p, %u]",
- __func__, src + inputmargin, inlen, inputmargin,
- out, rq->outputsize);
+   erofs_err(rq->sb, "failed to decompress, in[%u, %u] out[%u]",
+ inlen, inputmargin, rq->outputsize);
WARN_ON(1);
print_hex_dump(KERN_DEBUG, "[ in]: ", DUMP_PREFIX_OFFSET,
   16, 1, src + inputmargin, inlen, true);
diff --git a/fs/erofs/dir.c b/fs/erofs/dir.c
index a032c8217071..d28c623dfef9 100644
--- a/fs/erofs/dir.c
+++ b/fs/erofs/dir.c
@@ -16,8 +16,8 @@ static void debug_one_dentry(unsigned char d_type, const char 
*de_name,
memcpy(dbg_namebuf, de_name, de_namelen);
dbg_namebuf[de_namelen] = '\0';
 
-   debugln("found dirent %s de_len %u d_type %d", dbg_namebuf,
-   de_namelen, d_type);
+   erofs_dbg("found dirent %s de_len %u d_type %d", dbg_namebuf,
+ de_namelen, d_type);
 #endif
 }
 
@@ -47,7 +47,8 @@ static int erofs_fill_dentries(struct inode *dir, struct 
dir_context *ctx,
/* a corrupted entry is found */
if (nameoff + de_namelen > maxsize ||
de_namelen > EROFS_NAME_LEN) {
-   errln("bogus dirent @ nid %llu", EROFS_I(dir)->nid);
+   erofs_err(dir->i_sb, "bogus dirent @ nid %llu",
+ EROFS_I(dir)->nid);
DBG_BUGON(1);
return -EFSCORRUPTED;
}
@@ -84,8 +85,9 @@ static int erofs_readdir(struct file *f, struct dir_context 
*ctx)
err = -ENOMEM;
break;
} else if (IS_ERR(dentry_page)) {
-   errln("fail to readdir of logical block %u of nid %llu",
- i, EROFS_I(dir)->nid);
+   erofs_err(dir->i_sb,
+ "fail to readdir of logical block %u of nid 
%llu",
+ i, EROFS_I(dir)->nid);
err = -EFSCORRUPTED;
break;
}
@@ -96,8 +98,9 @@ static int erofs_readdir(struct file *f, struct dir_context 
*ctx)
 
if (nameoff < sizeof(struct erofs_dirent) ||
nameoff >= PAGE_SIZE) {
-   errln("%s, invalid de[0].nameoff %u @ nid %llu",
- __func__, nameoff, EROFS_I(dir)->nid);
+   

[PATCH v2 25/25] erofs: use read_cache_page_gfp for erofs_get_meta_page

2019-09-03 Thread Gao Xiang
As Christoph said [1], "I'd much prefer to just use
read_cache_page_gfp, and live with the fact that this
allocates bufferheads behind you for now.  I'll try to
speed up my attempts to get rid of the buffer heads on
the block device mapping instead. "

This simplifies the code a lot and a minor thing is
"no REQ_META (e.g. for blktrace) on metadata at all..."

[1] https://lore.kernel.org/r/20190903153704.ga2...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/data.c | 70 +++--
 1 file changed, 9 insertions(+), 61 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index eb7bbae89ed0..8a9fcbd0e8ac 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -32,71 +32,13 @@ static void erofs_readendio(struct bio *bio)
bio_put(bio);
 }
 
-static struct bio *erofs_grab_raw_bio(struct super_block *sb,
- erofs_blk_t blkaddr,
- unsigned int nr_pages,
- bool ismeta)
-{
-   struct bio *bio = bio_alloc(GFP_NOIO, nr_pages);
-
-   bio->bi_end_io = erofs_readendio;
-   bio_set_dev(bio, sb->s_bdev);
-   bio->bi_iter.bi_sector = (sector_t)blkaddr << LOG_SECTORS_PER_BLOCK;
-   if (ismeta)
-   bio->bi_opf = REQ_OP_READ | REQ_META;
-   else
-   bio->bi_opf = REQ_OP_READ;
-
-   return bio;
-}
-
 struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr)
 {
struct inode *const bd_inode = sb->s_bdev->bd_inode;
struct address_space *const mapping = bd_inode->i_mapping;
-   const gfp_t gfp = mapping_gfp_constraint(mapping, ~__GFP_FS);
-   struct page *page;
-   int err;
-
-repeat:
-   page = find_or_create_page(mapping, blkaddr, gfp);
-   if (!page)
-   return ERR_PTR(-ENOMEM);
-
-   DBG_BUGON(!PageLocked(page));
-
-   if (!PageUptodate(page)) {
-   struct bio *bio;
-
-   bio = erofs_grab_raw_bio(sb, blkaddr, 1, true);
-
-   if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
-   err = -EFAULT;
-   goto err_out;
-   }
-
-   submit_bio(bio);
-   lock_page(page);
 
-   /* this page has been truncated by others */
-   if (page->mapping != mapping) {
-   unlock_page(page);
-   put_page(page);
-   goto repeat;
-   }
-
-   /* more likely a read error */
-   if (!PageUptodate(page)) {
-   err = -EIO;
-   goto err_out;
-   }
-   }
-   return page;
-
-err_out:
-   unlock_page(page);
-   put_page(page);
-   return ERR_PTR(err);
+   return read_cache_page_gfp(mapping, blkaddr,
+  mapping_gfp_constraint(mapping, ~__GFP_FS));
 }
 
 static int erofs_map_blocks_flatmode(struct inode *inode,
@@ -272,7 +214,13 @@ static inline struct bio *erofs_read_raw_page(struct bio 
*bio,
if (nblocks > BIO_MAX_PAGES)
nblocks = BIO_MAX_PAGES;
 
-   bio = erofs_grab_raw_bio(sb, blknr, nblocks, false);
+   bio = bio_alloc(GFP_NOIO, nblocks);
+
+   bio->bi_end_io = erofs_readendio;
+   bio_set_dev(bio, sb->s_bdev);
+   bio->bi_iter.bi_sector = (sector_t)blknr <<
+   LOG_SECTORS_PER_BLOCK;
+   bio->bi_opf = REQ_OP_READ;
}
 
err = bio_add_page(bio, page, PAGE_SIZE, 0);
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 16/25] erofs: kill prio and nofail of erofs_get_meta_page()

2019-09-03 Thread Gao Xiang
As Christoph pointed out [1],
"Why is there __erofs_get_meta_page with the two weird
booleans instead of a single erofs_get_meta_page that
gets and gfp_t for additional flags and an unsigned int
for additional bio op flags."

And since all callers can handle errors, let's kill
prio and nofail and erofs_get_inline_page() now.

[1] https://lore.kernel.org/r/20190830162812.ga10...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/data.c | 25 ++---
 fs/erofs/inode.c|  2 +-
 fs/erofs/internal.h | 18 +-
 fs/erofs/xattr.c| 13 ++---
 fs/erofs/zmap.c |  4 ++--
 5 files changed, 16 insertions(+), 46 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 0136ea117934..28eda71bb1a9 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -51,25 +51,19 @@ static struct bio *erofs_grab_raw_bio(struct super_block 
*sb,
return bio;
 }
 
-/* prio -- true is used for dir */
-struct page *__erofs_get_meta_page(struct super_block *sb,
-  erofs_blk_t blkaddr, bool prio, bool nofail)
+struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr)
 {
struct inode *const bd_inode = sb->s_bdev->bd_inode;
struct address_space *const mapping = bd_inode->i_mapping;
-   /* prefer retrying in the allocator to blindly looping below */
-   const gfp_t gfp = mapping_gfp_constraint(mapping, ~__GFP_FS) |
-   (nofail ? __GFP_NOFAIL : 0);
-   unsigned int io_retries = nofail ? EROFS_IO_MAX_RETRIES_NOFAIL : 0;
+   const gfp_t gfp = mapping_gfp_constraint(mapping, ~__GFP_FS);
struct page *page;
int err;
 
 repeat:
page = find_or_create_page(mapping, blkaddr, gfp);
-   if (!page) {
-   DBG_BUGON(nofail);
+   if (!page)
return ERR_PTR(-ENOMEM);
-   }
+
DBG_BUGON(!PageLocked(page));
 
if (!PageUptodate(page)) {
@@ -82,14 +76,11 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
goto err_out;
}
 
-   __submit_bio(bio, REQ_OP_READ,
-REQ_META | (prio ? REQ_PRIO : 0));
-
+   __submit_bio(bio, REQ_OP_READ, REQ_META);
lock_page(page);
 
/* this page has been truncated by others */
if (page->mapping != mapping) {
-unlock_repeat:
unlock_page(page);
put_page(page);
goto repeat;
@@ -97,10 +88,6 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
 
/* more likely a read error */
if (!PageUptodate(page)) {
-   if (io_retries) {
-   --io_retries;
-   goto unlock_repeat;
-   }
err = -EIO;
goto err_out;
}
@@ -251,7 +238,7 @@ static inline struct bio *erofs_read_raw_page(struct bio 
*bio,
 
DBG_BUGON(map.m_plen > PAGE_SIZE);
 
-   ipage = erofs_get_meta_page(inode->i_sb, blknr, 0);
+   ipage = erofs_get_meta_page(inode->i_sb, blknr);
 
if (IS_ERR(ipage)) {
err = PTR_ERR(ipage);
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 770f3259c862..8d496adbeaea 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -182,7 +182,7 @@ static int fill_inode(struct inode *inode, int isdir)
debugln("%s, reading inode nid %llu at %u of blkaddr %u",
__func__, vi->nid, ofs, blkaddr);
 
-   page = erofs_get_meta_page(inode->i_sb, blkaddr, isdir);
+   page = erofs_get_meta_page(inode->i_sb, blkaddr);
 
if (IS_ERR(page)) {
errln("failed to get inode (nid: %llu) page, err %ld",
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 000ea92b36a3..90c62fb5f80d 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -258,8 +258,6 @@ static inline int erofs_wait_on_workgroup_freezed(struct 
erofs_workgroup *grp)
 #error erofs cannot be used in this platform
 #endif
 
-#define EROFS_IO_MAX_RETRIES_NOFAIL 5
-
 #define ROOT_NID(sb)   ((sb)->root_nid)
 
 #define erofs_blknr(addr)   ((addr) / EROFS_BLKSIZ)
@@ -418,24 +416,10 @@ static inline void __submit_bio(struct bio *bio, unsigned 
int op,
submit_bio(bio);
 }
 
-struct page *__erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr,
-  bool prio, bool nofail);
-
-static inline struct page *erofs_get_meta_page(struct super_block *sb,
-   erofs_blk_t blkaddr, bool prio)
-{
-   return __erofs_get_meta_page(sb, blkaddr, prio, false);
-}
+struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr);
 
 int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int)

[PATCH v2 09/25] erofs: use erofs_inode naming

2019-09-03 Thread Gao Xiang
As Christoph suggested [1], "Why is this called vnode instead
of inode?  That seems like a rather odd naming for a Linux
file system."

[1] https://lore.kernel.org/r/20190829101545.gc20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/data.c  |  8 
 fs/erofs/dir.c   |  6 +++---
 fs/erofs/inode.c | 12 ++--
 fs/erofs/internal.h  | 14 +++---
 fs/erofs/namei.c |  2 +-
 fs/erofs/super.c | 10 +-
 fs/erofs/xattr.c | 18 +-
 fs/erofs/xattr.h |  4 ++--
 fs/erofs/zdata.c |  9 +++--
 fs/erofs/zmap.c  | 28 ++--
 include/trace/events/erofs.h | 14 +++---
 11 files changed, 61 insertions(+), 64 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 4d9b07991d07..be11b5ea9d2e 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -112,7 +112,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
int err = 0;
erofs_blk_t nblocks, lastblk;
u64 offset = map->m_la;
-   struct erofs_vnode *vi = EROFS_V(inode);
+   struct erofs_inode *vi = EROFS_I(inode);
bool tailendpacking = (vi->datalayout == EROFS_INODE_FLAT_INLINE);
 
trace_erofs_map_blocks_flatmode_enter(inode, map, flags);
@@ -170,7 +170,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
 int erofs_map_blocks(struct inode *inode,
 struct erofs_map_blocks *map, int flags)
 {
-   if (erofs_inode_is_data_compressed(EROFS_V(inode)->datalayout)) {
+   if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout)) {
int err = z_erofs_map_blocks_iter(inode, map, flags);
 
if (map->mpage) {
@@ -365,7 +365,7 @@ static int erofs_raw_access_readpages(struct file *filp,
if (IS_ERR(bio)) {
pr_err("%s, readahead error at page %lu of nid 
%llu\n",
   __func__, page->index,
-  EROFS_V(mapping->host)->nid);
+  EROFS_I(mapping->host)->nid);
 
bio = NULL;
}
@@ -404,7 +404,7 @@ static sector_t erofs_bmap(struct address_space *mapping, 
sector_t block)
 {
struct inode *inode = mapping->host;
 
-   if (EROFS_V(inode)->datalayout == EROFS_INODE_FLAT_INLINE) {
+   if (EROFS_I(inode)->datalayout == EROFS_INODE_FLAT_INLINE) {
erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE;
 
if (block >> LOG_SECTORS_PER_BLOCK >= blks)
diff --git a/fs/erofs/dir.c b/fs/erofs/dir.c
index 6a5b43f7fb29..a032c8217071 100644
--- a/fs/erofs/dir.c
+++ b/fs/erofs/dir.c
@@ -47,7 +47,7 @@ static int erofs_fill_dentries(struct inode *dir, struct 
dir_context *ctx,
/* a corrupted entry is found */
if (nameoff + de_namelen > maxsize ||
de_namelen > EROFS_NAME_LEN) {
-   errln("bogus dirent @ nid %llu", EROFS_V(dir)->nid);
+   errln("bogus dirent @ nid %llu", EROFS_I(dir)->nid);
DBG_BUGON(1);
return -EFSCORRUPTED;
}
@@ -85,7 +85,7 @@ static int erofs_readdir(struct file *f, struct dir_context 
*ctx)
break;
} else if (IS_ERR(dentry_page)) {
errln("fail to readdir of logical block %u of nid %llu",
- i, EROFS_V(dir)->nid);
+ i, EROFS_I(dir)->nid);
err = -EFSCORRUPTED;
break;
}
@@ -97,7 +97,7 @@ static int erofs_readdir(struct file *f, struct dir_context 
*ctx)
if (nameoff < sizeof(struct erofs_dirent) ||
nameoff >= PAGE_SIZE) {
errln("%s, invalid de[0].nameoff %u @ nid %llu",
- __func__, nameoff, EROFS_V(dir)->nid);
+ __func__, nameoff, EROFS_I(dir)->nid);
err = -EFSCORRUPTED;
goto skip_this;
}
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 494b35e5830a..f6dfd0271261 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -11,7 +11,7 @@
 /* no locking */
 static int read_inode(struct inode *inode, void *data)
 {
-   struct erofs_vnode *vi = EROFS_V(inode);
+   struct erofs_inode *vi = EROFS_I(inode);
struct erofs_inode_compact *dic = data;
struct erofs_inode_extended *die;
 
@@ -140,7 +140,7 @@ static int read_inode(struct inode *inode, void *data)
 static int fill_inline_data(struct inode *inode, void *data,
unsigned int m_pofs)
 {
-   struct erofs_vnode *vi = EROFS_V(inode);
+   struct erofs_inode *vi = EROFS

[PATCH v2 23/25] erofs: use read_mapping_page instead of sb_bread

2019-09-03 Thread Gao Xiang
As Christoph said [1], "This seems to be your only direct
use of buffer heads, which while not deprecated are a bit
of an ugly step child.  So if you can easily avoid creating
a buffer_head dependency in a new filesystem I think you
should avoid it. "

[1] https://lore.kernel.org/r/20190902125109.ga9...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/super.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 1d9880195ef0..caf9a95173b0 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -98,20 +98,22 @@ static bool check_layout_compatibility(struct super_block 
*sb,
 static int erofs_read_superblock(struct super_block *sb)
 {
struct erofs_sb_info *sbi;
-   struct buffer_head *bh;
+   struct page *page;
struct erofs_super_block *dsb;
unsigned int blkszbits;
+   void *data;
int ret;
 
-   bh = sb_bread(sb, 0);
-
-   if (!bh) {
+   page = read_mapping_page(sb->s_bdev->bd_inode->i_mapping, 0, NULL);
+   if (!page) {
erofs_err(sb, "cannot read erofs superblock");
return -EIO;
}
 
sbi = EROFS_SB(sb);
-   dsb = (struct erofs_super_block *)(bh->b_data + EROFS_SUPER_OFFSET);
+
+   data = kmap_atomic(page);
+   dsb = (struct erofs_super_block *)(data + EROFS_SUPER_OFFSET);
 
ret = -EINVAL;
if (le32_to_cpu(dsb->magic) != EROFS_SUPER_MAGIC_V1) {
@@ -153,7 +155,8 @@ static int erofs_read_superblock(struct super_block *sb)
}
ret = 0;
 out:
-   brelse(bh);
+   kunmap_atomic(data);
+   put_page(page);
return ret;
 }
 
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 19/25] erofs: kill all erofs specific fault injection

2019-09-03 Thread Gao Xiang
As Christoph suggested [1], "Please just use plain kmalloc
everywhere and let the normal kernel error injection code
take care of injeting any errors."

[1] https://lore.kernel.org/r/20190829102426.ge20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 Documentation/filesystems/erofs.txt |  5 ---
 fs/erofs/Kconfig|  7 ---
 fs/erofs/data.c |  7 ---
 fs/erofs/inode.c|  3 +-
 fs/erofs/internal.h | 65 ---
 fs/erofs/super.c| 70 -
 fs/erofs/zdata.c|  8 +---
 7 files changed, 2 insertions(+), 163 deletions(-)

diff --git a/Documentation/filesystems/erofs.txt 
b/Documentation/filesystems/erofs.txt
index 38aa9126ec98..c3b5f603b2b6 100644
--- a/Documentation/filesystems/erofs.txt
+++ b/Documentation/filesystems/erofs.txt
@@ -52,11 +52,6 @@ linux-erofs mailing list:
 Mount options
 =
 
-fault_injection=%d Enable fault injection in all supported types with
-   specified injection rate. Supported injection type:
-   Type_NameType_Value
-   FAULT_KMALLOC0x1
-   FAULT_READ_IO0x2
 (no)user_xattr Setup Extended User Attributes. Note: xattr is enabled
by default if CONFIG_EROFS_FS_XATTR is selected.
 (no)aclSetup POSIX Access Control List. Note: acl is enabled
diff --git a/fs/erofs/Kconfig b/fs/erofs/Kconfig
index 16316d1adca3..9d634d3a1845 100644
--- a/fs/erofs/Kconfig
+++ b/fs/erofs/Kconfig
@@ -27,13 +27,6 @@ config EROFS_FS_DEBUG
 
  For daily use, say N.
 
-config EROFS_FAULT_INJECTION
-   bool "EROFS fault injection facility"
-   depends on EROFS_FS
-   help
- Test EROFS to inject faults such as ENOMEM, EIO, and so on.
- If unsure, say N.
-
 config EROFS_FS_XATTR
bool "EROFS extended attributes"
depends on EROFS_FS
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 3ce87a88452a..b5f5b8592d14 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -11,16 +11,10 @@
 
 static void erofs_readendio(struct bio *bio)
 {
-   struct super_block *const sb = bio->bi_private;
struct bio_vec *bvec;
blk_status_t err = bio->bi_status;
struct bvec_iter_all iter_all;
 
-   if (time_to_inject(EROFS_SB(sb), FAULT_READ_IO)) {
-   erofs_show_injection_info(FAULT_READ_IO);
-   err = BLK_STS_IOERR;
-   }
-
bio_for_each_segment_all(bvec, bio, iter_all) {
struct page *page = bvec->bv_page;
 
@@ -48,7 +42,6 @@ static struct bio *erofs_grab_raw_bio(struct super_block *sb,
bio->bi_end_io = erofs_readendio;
bio_set_dev(bio, sb->s_bdev);
bio->bi_iter.bi_sector = (sector_t)blkaddr << LOG_SECTORS_PER_BLOCK;
-   bio->bi_private = sb;
if (ismeta)
bio->bi_opf = REQ_OP_READ | REQ_META;
else
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 384905e0677c..8e53765a532c 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -131,7 +131,6 @@ static int erofs_fill_symlink(struct inode *inode, void 
*data,
  unsigned int m_pofs)
 {
struct erofs_inode *vi = EROFS_I(inode);
-   struct erofs_sb_info *sbi = EROFS_I_SB(inode);
char *lnk;
 
/* if it cannot be handled with fast symlink scheme */
@@ -141,7 +140,7 @@ static int erofs_fill_symlink(struct inode *inode, void 
*data,
return 0;
}
 
-   lnk = erofs_kmalloc(sbi, inode->i_size + 1, GFP_KERNEL);
+   lnk = kmalloc(inode->i_size + 1, GFP_KERNEL);
if (!lnk)
return -ENOMEM;
 
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 881eb2ee18b5..d659c1941f93 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -32,23 +32,6 @@
 #define DBG_BUGON(x)((void)(x))
 #endif /* !CONFIG_EROFS_FS_DEBUG */
 
-enum {
-   FAULT_KMALLOC,
-   FAULT_READ_IO,
-   FAULT_MAX,
-};
-
-#ifdef CONFIG_EROFS_FAULT_INJECTION
-extern const char *erofs_fault_name[FAULT_MAX];
-#define IS_FAULT_SET(fi, type) ((fi)->inject_type & (1 << (type)))
-
-struct erofs_fault_info {
-   atomic_t inject_ops;
-   unsigned int inject_rate;
-   unsigned int inject_type;
-};
-#endif /* CONFIG_EROFS_FAULT_INJECTION */
-
 /* EROFS_SUPER_MAGIC_V1 to represent the whole file system */
 #define EROFS_SUPER_MAGIC   EROFS_SUPER_MAGIC_V1
 
@@ -99,62 +82,14 @@ struct erofs_sb_info {
u32 feature_incompat;
 
unsigned int mount_opt;
-
-#ifdef CONFIG_EROFS_FAULT_INJECTION
-   struct erofs_fault_info fault_info; /* For fault injection */
-#endif
 };
 
-#ifdef CONFIG_EROFS_FAULT_INJECTION
-#define erofs_show_injection_info(type)
\
-   infoln("inject %s in %s of %

[PATCH v2 17/25] erofs: kill __submit_bio()

2019-09-03 Thread Gao Xiang
As Christoph pointed out [1], "
Why is there __submit_bio which really just obsfucates
what is going on?  Also why is __submit_bio using
bio_set_op_attrs instead of opencode it as the comment
right next to it asks you to? "

Let's use submit_bio directly instead.

[1] https://lore.kernel.org/r/20190830162812.ga10...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/data.c | 21 +
 fs/erofs/internal.h |  7 ---
 fs/erofs/zdata.c|  6 --
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 28eda71bb1a9..70b1e353756e 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -40,7 +40,8 @@ static inline void read_endio(struct bio *bio)
 
 static struct bio *erofs_grab_raw_bio(struct super_block *sb,
  erofs_blk_t blkaddr,
- unsigned int nr_pages)
+ unsigned int nr_pages,
+ bool ismeta)
 {
struct bio *bio = bio_alloc(GFP_NOIO, nr_pages);
 
@@ -48,6 +49,11 @@ static struct bio *erofs_grab_raw_bio(struct super_block *sb,
bio_set_dev(bio, sb->s_bdev);
bio->bi_iter.bi_sector = (sector_t)blkaddr << LOG_SECTORS_PER_BLOCK;
bio->bi_private = sb;
+   if (ismeta)
+   bio->bi_opf = REQ_OP_READ | REQ_META;
+   else
+   bio->bi_opf = REQ_OP_READ;
+
return bio;
 }
 
@@ -69,14 +75,14 @@ struct page *erofs_get_meta_page(struct super_block *sb, 
erofs_blk_t blkaddr)
if (!PageUptodate(page)) {
struct bio *bio;
 
-   bio = erofs_grab_raw_bio(sb, blkaddr, 1);
+   bio = erofs_grab_raw_bio(sb, blkaddr, 1, true);
 
if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
err = -EFAULT;
goto err_out;
}
 
-   __submit_bio(bio, REQ_OP_READ, REQ_META);
+   submit_bio(bio);
lock_page(page);
 
/* this page has been truncated by others */
@@ -201,7 +207,7 @@ static inline struct bio *erofs_read_raw_page(struct bio 
*bio,
/* not continuous */
*last_block + 1 != current_block) {
 submit_bio_retry:
-   __submit_bio(bio, REQ_OP_READ, 0);
+   submit_bio(bio);
bio = NULL;
}
 
@@ -271,7 +277,7 @@ static inline struct bio *erofs_read_raw_page(struct bio 
*bio,
if (nblocks > BIO_MAX_PAGES)
nblocks = BIO_MAX_PAGES;
 
-   bio = erofs_grab_raw_bio(sb, blknr, nblocks);
+   bio = erofs_grab_raw_bio(sb, blknr, nblocks, false);
}
 
err = bio_add_page(bio, page, PAGE_SIZE, 0);
@@ -302,8 +308,7 @@ static inline struct bio *erofs_read_raw_page(struct bio 
*bio,
/* if updated manually, continuous pages has a gap */
if (bio)
 submit_bio_out:
-   __submit_bio(bio, REQ_OP_READ, 0);
-
+   submit_bio(bio);
return err ? ERR_PTR(err) : NULL;
 }
 
@@ -367,7 +372,7 @@ static int erofs_raw_access_readpages(struct file *filp,
 
/* the rare case (end in gaps) */
if (bio)
-   __submit_bio(bio, REQ_OP_READ, 0);
+   submit_bio(bio);
return 0;
 }
 
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 90c62fb5f80d..13c8d841c43a 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -409,13 +409,6 @@ static inline int z_erofs_map_blocks_iter(struct inode 
*inode,
 #endif /* !CONFIG_EROFS_FS_ZIP */
 
 /* data.c */
-static inline void __submit_bio(struct bio *bio, unsigned int op,
-   unsigned int op_flags)
-{
-   bio_set_op_attrs(bio, op, op_flags);
-   submit_bio(bio);
-}
-
 struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr);
 
 int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int);
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 21ade322cc81..3010fa3d1ac3 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1258,7 +1258,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
 
if (bio && force_submit) {
 submit_bio_retry:
-   __submit_bio(bio, REQ_OP_READ, 0);
+   submit_bio(bio);
bio = NULL;
}
 
@@ -1270,6 +1270,8 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
bio->bi_iter.bi_sector = (sector_t)(first_index + i) <<
LOG_SECTORS_PER_BLOCK;
bio->bi_private = bi_private;
+   bio->bi_opf = REQ_OP_READ;
+
++nr_bios;
}
 
@@ -1290,7 +1292,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
} while (owned_head != Z_EROFS_PCLUSTER_TAIL);
 
if (bio)

[PATCH v2 24/25] erofs: always use iget5_locked

2019-09-03 Thread Gao Xiang
As Christoph said [1] [2], "Just use the slightly
more complicated 32-bit version everywhere so that
you have a single actually tested code path.
And then remove this helper. "

[1] https://lore.kernel.org/r/20190829102426.ge20...@infradead.org/
[2] https://lore.kernel.org/r/20190902125320.ga16...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/inode.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index a0cec3c754cd..3350ab65d892 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -243,7 +243,6 @@ static int erofs_fill_inode(struct inode *inode, int isdir)
  * erofs nid is 64bits, but i_ino is 'unsigned long', therefore
  * we should do more for 32-bit platform to find the right inode.
  */
-#if BITS_PER_LONG == 32
 static int erofs_ilookup_test_actor(struct inode *inode, void *opaque)
 {
const erofs_nid_t nid = *(erofs_nid_t *)opaque;
@@ -258,20 +257,14 @@ static int erofs_iget_set_actor(struct inode *inode, void 
*opaque)
inode->i_ino = erofs_inode_hash(nid);
return 0;
 }
-#endif
 
 static inline struct inode *erofs_iget_locked(struct super_block *sb,
  erofs_nid_t nid)
 {
const unsigned long hashval = erofs_inode_hash(nid);
 
-#if BITS_PER_LONG >= 64
-   /* it is safe to use iget_locked for >= 64-bit platform */
-   return iget_locked(sb, hashval);
-#else
return iget5_locked(sb, hashval, erofs_ilookup_test_actor,
erofs_iget_set_actor, &nid);
-#endif
 }
 
 struct inode *erofs_iget(struct super_block *sb,
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 07/25] erofs: better naming for erofs inode related stuffs

2019-09-03 Thread Gao Xiang
updates inode naming
 - kill is_inode_layout_compression [1]
 - kill magic underscores [2] [3]
 - better naming for datamode & data_mapping_mode [3]
 - better naming erofs_inode_{compact, extended} [4]

[1] https://lore.kernel.org/r/20190829102426.ge20...@infradead.org/
[2] https://lore.kernel.org/r/20190829102426.ge20...@infradead.org/
[3] https://lore.kernel.org/r/20190902122627.gn15...@infradead.org/
[4] https://lore.kernel.org/r/20190902125438.ga17...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/data.c |   9 ++--
 fs/erofs/erofs_fs.h |  24 -
 fs/erofs/inode.c| 126 +---
 fs/erofs/internal.h |  31 ++-
 fs/erofs/super.c|   2 +-
 fs/erofs/zmap.c |   6 +--
 6 files changed, 108 insertions(+), 90 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 0983807737fd..4d9b07991d07 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -113,11 +113,12 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
erofs_blk_t nblocks, lastblk;
u64 offset = map->m_la;
struct erofs_vnode *vi = EROFS_V(inode);
+   bool tailendpacking = (vi->datalayout == EROFS_INODE_FLAT_INLINE);
 
trace_erofs_map_blocks_flatmode_enter(inode, map, flags);
 
nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE);
-   lastblk = nblocks - is_inode_flat_inline(inode);
+   lastblk = nblocks - tailendpacking;
 
if (offset >= inode->i_size) {
/* leave out-of-bound access unmapped */
@@ -132,7 +133,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
if (offset < blknr_to_addr(lastblk)) {
map->m_pa = blknr_to_addr(vi->raw_blkaddr) + map->m_la;
map->m_plen = blknr_to_addr(lastblk) - offset;
-   } else if (is_inode_flat_inline(inode)) {
+   } else if (tailendpacking) {
/* 2 - inode inline B: inode, [xattrs], inline last blk... */
struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb);
 
@@ -169,7 +170,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
 int erofs_map_blocks(struct inode *inode,
 struct erofs_map_blocks *map, int flags)
 {
-   if (is_inode_layout_compression(inode)) {
+   if (erofs_inode_is_data_compressed(EROFS_V(inode)->datalayout)) {
int err = z_erofs_map_blocks_iter(inode, map, flags);
 
if (map->mpage) {
@@ -403,7 +404,7 @@ static sector_t erofs_bmap(struct address_space *mapping, 
sector_t block)
 {
struct inode *inode = mapping->host;
 
-   if (is_inode_flat_inline(inode)) {
+   if (EROFS_V(inode)->datalayout == EROFS_INODE_FLAT_INLINE) {
erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE;
 
if (block >> LOG_SECTORS_PER_BLOCK >= blks)
diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index b2aef3bc377d..18689e916e94 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -41,7 +41,7 @@ struct erofs_super_block {
 };
 
 /*
- * erofs inode data mapping:
+ * erofs inode datalayout:
  * 0 - inode plain without inline data A:
  * inode, [xattrs], ... | ... | no-holed data
  * 1 - inode VLE compression B (legacy):
@@ -57,7 +57,7 @@ enum {
EROFS_INODE_FLAT_COMPRESSION_LEGACY = 1,
EROFS_INODE_FLAT_INLINE = 2,
EROFS_INODE_FLAT_COMPRESSION= 3,
-   EROFS_INODE_LAYOUT_MAX
+   EROFS_INODE_DATALAYOUT_MAX
 };
 
 static inline bool erofs_inode_is_data_compressed(unsigned int datamode)
@@ -68,14 +68,14 @@ static inline bool erofs_inode_is_data_compressed(unsigned 
int datamode)
 
 /* bit definitions of inode i_advise */
 #define EROFS_I_VERSION_BITS1
-#define EROFS_I_DATA_MAPPING_BITS   3
+#define EROFS_I_DATALAYOUT_BITS 3
 
 #define EROFS_I_VERSION_BIT 0
-#define EROFS_I_DATA_MAPPING_BIT1
+#define EROFS_I_DATALAYOUT_BIT  1
 
 /* 32-byte reduced form of an ondisk inode */
-struct erofs_inode_v1 {
-   __le16 i_advise;/* inode hints */
+struct erofs_inode_compact {
+   __le16 i_format;/* inode format hints */
 
 /* 1 header + n-1 * 4 bytes inline xattr to keep continuity */
__le16 i_xattr_icount;
@@ -98,13 +98,13 @@ struct erofs_inode_v1 {
 };
 
 /* 32 bytes on-disk inode */
-#define EROFS_INODE_LAYOUT_V1   0
+#define EROFS_INODE_LAYOUT_COMPACT 0
 /* 64 bytes on-disk inode */
-#define EROFS_INODE_LAYOUT_V2   1
+#define EROFS_INODE_LAYOUT_EXTENDED1
 
 /* 64-byte complete form of an ondisk inode */
-struct erofs_inode_v2 {
-   __le16 i_advise;/* inode hints */
+struct erofs_inode_extended {
+   __le16 i_format;/* inode format hints */
 
 /* 1 header + n-1 * 4 bytes inline xattr to keep continuity */
__le16 i_xattr_icount;
@@ -299,8 +299,8 @@ struct erofs_dirent {
 static inline void erofs_check_ondisk_layout_definitions(void)
 {
BUILD_BUG_ON(si

[PATCH v2 15/25] erofs: localize erofs_grab_bio()

2019-09-03 Thread Gao Xiang
As Christoph pointed out [1], "erofs_grab_bio tries to
handle a bio_alloc failure, except that the function will
not actually fail due the mempool backing it."

Sorry about useless code, fix it now and
localize erofs_grab_bio [2].

[1] https://lore.kernel.org/r/20190830162812.ga10...@infradead.org/
[2] https://lore.kernel.org/r/20190902122016.gl15...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/data.c | 28 +++-
 fs/erofs/internal.h | 29 -
 fs/erofs/zdata.c| 10 +++---
 3 files changed, 22 insertions(+), 45 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index be11b5ea9d2e..0136ea117934 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -38,6 +38,19 @@ static inline void read_endio(struct bio *bio)
bio_put(bio);
 }
 
+static struct bio *erofs_grab_raw_bio(struct super_block *sb,
+ erofs_blk_t blkaddr,
+ unsigned int nr_pages)
+{
+   struct bio *bio = bio_alloc(GFP_NOIO, nr_pages);
+
+   bio->bi_end_io = read_endio;
+   bio_set_dev(bio, sb->s_bdev);
+   bio->bi_iter.bi_sector = (sector_t)blkaddr << LOG_SECTORS_PER_BLOCK;
+   bio->bi_private = sb;
+   return bio;
+}
+
 /* prio -- true is used for dir */
 struct page *__erofs_get_meta_page(struct super_block *sb,
   erofs_blk_t blkaddr, bool prio, bool nofail)
@@ -62,12 +75,7 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
if (!PageUptodate(page)) {
struct bio *bio;
 
-   bio = erofs_grab_bio(sb, blkaddr, 1, sb, read_endio, nofail);
-   if (IS_ERR(bio)) {
-   DBG_BUGON(nofail);
-   err = PTR_ERR(bio);
-   goto err_out;
-   }
+   bio = erofs_grab_raw_bio(sb, blkaddr, 1);
 
if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
err = -EFAULT;
@@ -276,13 +284,7 @@ static inline struct bio *erofs_read_raw_page(struct bio 
*bio,
if (nblocks > BIO_MAX_PAGES)
nblocks = BIO_MAX_PAGES;
 
-   bio = erofs_grab_bio(sb, blknr, nblocks, sb,
-read_endio, false);
-   if (IS_ERR(bio)) {
-   err = PTR_ERR(bio);
-   bio = NULL;
-   goto err_out;
-   }
+   bio = erofs_grab_raw_bio(sb, blknr, nblocks);
}
 
err = bio_add_page(bio, page, PAGE_SIZE, 0);
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index cc1ea98c5c89..000ea92b36a3 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -411,35 +411,6 @@ static inline int z_erofs_map_blocks_iter(struct inode 
*inode,
 #endif /* !CONFIG_EROFS_FS_ZIP */
 
 /* data.c */
-static inline struct bio *erofs_grab_bio(struct super_block *sb,
-erofs_blk_t blkaddr,
-unsigned int nr_pages,
-void *bi_private, bio_end_io_t endio,
-bool nofail)
-{
-   const gfp_t gfp = GFP_NOIO;
-   struct bio *bio;
-
-   do {
-   if (nr_pages == 1) {
-   bio = bio_alloc(gfp | (nofail ? __GFP_NOFAIL : 0), 1);
-   if (!bio) {
-   DBG_BUGON(nofail);
-   return ERR_PTR(-ENOMEM);
-   }
-   break;
-   }
-   bio = bio_alloc(gfp, nr_pages);
-   nr_pages /= 2;
-   } while (!bio);
-
-   bio->bi_end_io = endio;
-   bio_set_dev(bio, sb->s_bdev);
-   bio->bi_iter.bi_sector = (sector_t)blkaddr << LOG_SECTORS_PER_BLOCK;
-   bio->bi_private = bi_private;
-   return bio;
-}
-
 static inline void __submit_bio(struct bio *bio, unsigned int op,
unsigned int op_flags)
 {
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index f06a2fad7af2..21ade322cc81 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1263,9 +1263,13 @@ static bool z_erofs_vle_submit_all(struct super_block 
*sb,
}
 
if (!bio) {
-   bio = erofs_grab_bio(sb, first_index + i,
-BIO_MAX_PAGES, bi_private,
-z_erofs_vle_read_endio, true);
+   bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
+
+   bio->bi_end_io = z_erofs_vle_read_endio;
+   bio_set_dev(bio, sb->s_bdev);
+   bio->bi_iter.bi_sector = (sector_t)(first_index + i) <<
+   LOG_SECTORS_PER_BLOCK;
+   bio->bi_private = bi_private;

[PATCH v2 21/25] erofs: save one level of indentation

2019-09-03 Thread Gao Xiang
As Christoph said [1], ".. and save one
level of indentation."

[1] https://lore.kernel.org/r/20190829102426.ge20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/inode.c | 65 
 1 file changed, 33 insertions(+), 32 deletions(-)

diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 8e53765a532c..5a6d3282fefb 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -193,41 +193,42 @@ static int erofs_fill_inode(struct inode *inode, int 
isdir)
data = page_address(page);
 
err = erofs_read_inode(inode, data + ofs);
-   if (!err) {
-   /* setup the new inode */
-   switch (inode->i_mode & S_IFMT) {
-   case S_IFREG:
-   inode->i_op = &erofs_generic_iops;
-   inode->i_fop = &generic_ro_fops;
-   break;
-   case S_IFDIR:
-   inode->i_op = &erofs_dir_iops;
-   inode->i_fop = &erofs_dir_fops;
-   break;
-   case S_IFLNK:
-   err = erofs_fill_symlink(inode, data, ofs);
-   if (err)
-   goto out_unlock;
-   inode_nohighmem(inode);
-   break;
-   case S_IFCHR:
-   case S_IFBLK:
-   case S_IFIFO:
-   case S_IFSOCK:
-   inode->i_op = &erofs_generic_iops;
-   init_special_inode(inode, inode->i_mode, inode->i_rdev);
-   goto out_unlock;
-   default:
-   err = -EFSCORRUPTED;
+   if (err)
+   goto out_unlock;
+
+   /* setup the new inode */
+   switch (inode->i_mode & S_IFMT) {
+   case S_IFREG:
+   inode->i_op = &erofs_generic_iops;
+   inode->i_fop = &generic_ro_fops;
+   break;
+   case S_IFDIR:
+   inode->i_op = &erofs_dir_iops;
+   inode->i_fop = &erofs_dir_fops;
+   break;
+   case S_IFLNK:
+   err = erofs_fill_symlink(inode, data, ofs);
+   if (err)
goto out_unlock;
-   }
+   inode_nohighmem(inode);
+   break;
+   case S_IFCHR:
+   case S_IFBLK:
+   case S_IFIFO:
+   case S_IFSOCK:
+   inode->i_op = &erofs_generic_iops;
+   init_special_inode(inode, inode->i_mode, inode->i_rdev);
+   goto out_unlock;
+   default:
+   err = -EFSCORRUPTED;
+   goto out_unlock;
+   }
 
-   if (erofs_inode_is_data_compressed(vi->datalayout)) {
-   err = z_erofs_fill_inode(inode);
-   goto out_unlock;
-   }
-   inode->i_mapping->a_ops = &erofs_raw_access_aops;
+   if (erofs_inode_is_data_compressed(vi->datalayout)) {
+   err = z_erofs_fill_inode(inode);
+   goto out_unlock;
}
+   inode->i_mapping->a_ops = &erofs_raw_access_aops;
 
 out_unlock:
unlock_page(page);
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 01/25] erofs: remove all the byte offset comments

2019-09-03 Thread Gao Xiang
As Christoph suggested [1], "Please remove all the byte offset comments.
that is something that can easily be checked with gdb or pahole."

[1] https://lore.kernel.org/r/20190829095954.gb20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/erofs_fs.h | 105 +++-
 1 file changed, 54 insertions(+), 51 deletions(-)

diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index afa7d45ca958..49335fff9d65 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -17,27 +17,28 @@
 #define EROFS_REQUIREMENT_LZ4_0PADDING 0x0001
 #define EROFS_ALL_REQUIREMENTS EROFS_REQUIREMENT_LZ4_0PADDING
 
+/* 128-byte erofs on-disk super block */
 struct erofs_super_block {
-/*  0 */__le32 magic;   /* in the little endian */
-/*  4 */__le32 checksum;/* crc32c(super_block) */
-/*  8 */__le32 features;/* (aka. feature_compat) */
-/* 12 */__u8 blkszbits; /* support block_size == PAGE_SIZE only */
-/* 13 */__u8 reserved;
-
-/* 14 */__le16 root_nid;
-/* 16 */__le64 inos;/* total valid ino # (== f_files - f_favail) */
-
-/* 24 */__le64 build_time;  /* inode v1 time derivation */
-/* 32 */__le32 build_time_nsec;
-/* 36 */__le32 blocks;  /* used for statfs */
-/* 40 */__le32 meta_blkaddr;
-/* 44 */__le32 xattr_blkaddr;
-/* 48 */__u8 uuid[16];  /* 128-bit uuid for volume */
-/* 64 */__u8 volume_name[16];   /* volume name */
-/* 80 */__le32 requirements;/* (aka. feature_incompat) */
-
-/* 84 */__u8 reserved2[44];
-} __packed; /* 128 bytes */
+   __le32 magic;   /* file system magic number */
+   __le32 checksum;/* crc32c(super_block) */
+   __le32 features;/* (aka. feature_compat) */
+   __u8 blkszbits; /* support block_size == PAGE_SIZE only */
+   __u8 reserved;
+
+   __le16 root_nid;/* nid of root directory */
+   __le64 inos;/* total valid ino # (== f_files - f_favail) */
+
+   __le64 build_time;  /* inode v1 time derivation */
+   __le32 build_time_nsec; /* inode v1 time derivation in nano scale */
+   __le32 blocks;  /* used for statfs */
+   __le32 meta_blkaddr;/* start block address of metadata area */
+   __le32 xattr_blkaddr;   /* start block address of shared xattr area */
+   __u8 uuid[16];  /* 128-bit uuid for volume */
+   __u8 volume_name[16];   /* volume name */
+   __le32 requirements;/* (aka. feature_incompat) */
+
+   __u8 reserved2[44];
+} __packed;
 
 /*
  * erofs inode data mapping:
@@ -73,16 +74,17 @@ static inline bool erofs_inode_is_data_compressed(unsigned 
int datamode)
 #define EROFS_I_VERSION_BIT 0
 #define EROFS_I_DATA_MAPPING_BIT1
 
+/* 32-byte reduced form of an ondisk inode */
 struct erofs_inode_v1 {
-/*  0 */__le16 i_advise;
+   __le16 i_advise;/* inode hints */
 
 /* 1 header + n-1 * 4 bytes inline xattr to keep continuity */
-/*  2 */__le16 i_xattr_icount;
-/*  4 */__le16 i_mode;
-/*  6 */__le16 i_nlink;
-/*  8 */__le32 i_size;
-/* 12 */__le32 i_reserved;
-/* 16 */union {
+   __le16 i_xattr_icount;
+   __le16 i_mode;
+   __le16 i_nlink;
+   __le32 i_size;
+   __le32 i_reserved;
+   union {
/* file total compressed blocks for data mapping 1 */
__le32 compressed_blocks;
__le32 raw_blkaddr;
@@ -90,10 +92,10 @@ struct erofs_inode_v1 {
/* for device files, used to indicate old/new device # */
__le32 rdev;
} i_u __packed;
-/* 20 */__le32 i_ino;   /* only used for 32-bit stat compatibility */
-/* 24 */__le16 i_uid;
-/* 26 */__le16 i_gid;
-/* 28 */__le32 i_reserved2;
+   __le32 i_ino;   /* only used for 32-bit stat compatibility */
+   __le16 i_uid;
+   __le16 i_gid;
+   __le32 i_reserved2;
 } __packed;
 
 /* 32 bytes on-disk inode */
@@ -101,15 +103,16 @@ struct erofs_inode_v1 {
 /* 64 bytes on-disk inode */
 #define EROFS_INODE_LAYOUT_V2   1
 
+/* 64-byte complete form of an ondisk inode */
 struct erofs_inode_v2 {
-/*  0 */__le16 i_advise;
+   __le16 i_advise;/* inode hints */
 
 /* 1 header + n-1 * 4 bytes inline xattr to keep continuity */
-/*  2 */__le16 i_xattr_icount;
-/*  4 */__le16 i_mode;
-/*  6 */__le16 i_reserved;
-/*  8 */__le64 i_size;
-/* 16 */union {
+   __le16 i_xattr_icount;
+   __le16 i_mode;
+   __le16 i_reserved;
+   __le64 i_size;
+   union {
/* file total compressed blocks for data mapping 1 */
__le32 compressed_blocks;
__le32 raw_blkaddr;
@@ -119,15 +122,15 @@ struct erofs_inode_v2 {
} i_u __packed;
 
/* only used for 32-bit stat compatibility */
-/* 20 */__le32 i_ino;
-
-/* 24 */__le32 i_uid;
-/* 28 */__le32 i_gid;
-/* 32 */__le64 i_ctime;
-/* 40 */__le32 i_ctime_nsec;
-/* 44 */__le32 i_nlink;
-/*

[PATCH v2 02/25] erofs: on-disk format should have explicitly assigned numbers

2019-09-03 Thread Gao Xiang
As Christoph suggested [1], on-disk format should have
explicitly assigned numbers.

[1] https://lore.kernel.org/r/20190829095954.gb20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/erofs_fs.h | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index 49335fff9d65..d1f152a3670a 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -53,10 +53,10 @@ struct erofs_super_block {
  * 4~7 - reserved
  */
 enum {
-   EROFS_INODE_FLAT_PLAIN,
-   EROFS_INODE_FLAT_COMPRESSION_LEGACY,
-   EROFS_INODE_FLAT_INLINE,
-   EROFS_INODE_FLAT_COMPRESSION,
+   EROFS_INODE_FLAT_PLAIN  = 0,
+   EROFS_INODE_FLAT_COMPRESSION_LEGACY = 1,
+   EROFS_INODE_FLAT_INLINE = 2,
+   EROFS_INODE_FLAT_COMPRESSION= 3,
EROFS_INODE_LAYOUT_MAX
 };
 
@@ -184,7 +184,7 @@ struct erofs_xattr_entry {
 
 /* available compression algorithm types */
 enum {
-   Z_EROFS_COMPRESSION_LZ4,
+   Z_EROFS_COMPRESSION_LZ4 = 0,
Z_EROFS_COMPRESSION_MAX
 };
 
@@ -242,10 +242,10 @@ struct z_erofs_map_header {
  *(di_advise could be 0, 1 or 2)
  */
 enum {
-   Z_EROFS_VLE_CLUSTER_TYPE_PLAIN,
-   Z_EROFS_VLE_CLUSTER_TYPE_HEAD,
-   Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD,
-   Z_EROFS_VLE_CLUSTER_TYPE_RESERVED,
+   Z_EROFS_VLE_CLUSTER_TYPE_PLAIN  = 0,
+   Z_EROFS_VLE_CLUSTER_TYPE_HEAD   = 1,
+   Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD= 2,
+   Z_EROFS_VLE_CLUSTER_TYPE_RESERVED   = 3,
Z_EROFS_VLE_CLUSTER_TYPE_MAX
 };
 
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 10/25] erofs: update erofs_fs.h comments

2019-09-03 Thread Gao Xiang
As Christoph said [1] [2], update it now.

[1] https://lore.kernel.org/r/20190902124521.ga22...@infradead.org/
[2] https://lore.kernel.org/r/20190902120548.gb15...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/erofs_fs.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index 18689e916e94..b1ee5654750d 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -1,5 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 */
 /*
+ * EROFS (Enhanced ROM File System) on-disk format definition
+ *
  * Copyright (C) 2017-2018 HUAWEI, Inc.
  * http://www.huawei.com/
  * Created by Gao Xiang 
@@ -7,7 +9,6 @@
 #ifndef __EROFS_FS_H
 #define __EROFS_FS_H
 
-/* Enhanced(Extended) ROM File System */
 #define EROFS_SUPER_OFFSET  1024
 
 /*
@@ -41,7 +42,7 @@ struct erofs_super_block {
 };
 
 /*
- * erofs inode datalayout:
+ * erofs inode datalayout (i_format in on-disk inode):
  * 0 - inode plain without inline data A:
  * inode, [xattrs], ... | ... | no-holed data
  * 1 - inode VLE compression B (legacy):
@@ -187,7 +188,7 @@ static inline unsigned int erofs_xattr_entry_size(struct 
erofs_xattr_entry *e)
 e->e_name_len + le16_to_cpu(e->e_value_size));
 }
 
-/* available compression algorithm types */
+/* available compression algorithm types (for h_algorithmtype) */
 enum {
Z_EROFS_COMPRESSION_LZ4 = 0,
Z_EROFS_COMPRESSION_MAX
@@ -222,7 +223,7 @@ struct z_erofs_map_header {
 #define Z_EROFS_VLE_LEGACY_HEADER_PADDING   8
 
 /*
- * Z_EROFS Variable-sized Logical Extent cluster type:
+ * Fixed-sized output compression ondisk Logical Extent cluster type:
  *0 - literal (uncompressed) cluster
  *1 - compressed cluster (for the head logical cluster)
  *2 - compressed cluster (for the other logical clusters)
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 11/25] erofs: update comments in inode.c

2019-09-03 Thread Gao Xiang
As Christoph suggested [1], update them all.

[1] https://lore.kernel.org/r/20190829102426.ge20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/inode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index f6dfd0271261..a42f5fc14df9 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -147,7 +147,7 @@ static int fill_inline_data(struct inode *inode, void *data,
if (vi->datalayout != EROFS_INODE_FLAT_INLINE)
return 0;
 
-   /* fast symlink (following ext4) */
+   /* fast symlink */
if (S_ISLNK(inode->i_mode) && inode->i_size < PAGE_SIZE) {
char *lnk = erofs_kmalloc(sbi, inode->i_size + 1, GFP_KERNEL);
 
@@ -156,7 +156,7 @@ static int fill_inline_data(struct inode *inode, void *data,
 
m_pofs += vi->inode_isize + vi->xattr_isize;
 
-   /* inline symlink data shouldn't across page boundary as well */
+   /* inline symlink data shouldn't cross page boundary as well */
if (m_pofs + inode->i_size > PAGE_SIZE) {
kfree(lnk);
errln("inline data cross block boundary @ nid %llu",
@@ -165,7 +165,6 @@ static int fill_inline_data(struct inode *inode, void *data,
return -EFSCORRUPTED;
}
 
-   /* get in-page inline data */
memcpy(lnk, data + m_pofs, inode->i_size);
lnk[inode->i_size] = '\0';
 
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 14/25] erofs: kill verbose debug info in erofs_fill_super

2019-09-03 Thread Gao Xiang
As Christoph said [1], "That is some very verbose
debug info.  We usually don't add that and let
people trace the function instead. "

[1] https://lore.kernel.org/r/20190829101545.gc20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/super.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 63cb17a4073b..b64d69f18270 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -384,9 +384,6 @@ static int erofs_fill_super(struct super_block *sb, void 
*data, int silent)
struct erofs_sb_info *sbi;
int err;
 
-   infoln("fill_super, device -> %s", sb->s_id);
-   infoln("options -> %s", (char *)data);
-
sb->s_magic = EROFS_SUPER_MAGIC;
 
if (!sb_set_blocksize(sb, EROFS_BLKSIZ)) {
@@ -419,9 +416,6 @@ static int erofs_fill_super(struct super_block *sb, void 
*data, int silent)
if (err)
return err;
 
-   if (!silent)
-   infoln("root inode @ nid %llu", ROOT_NID(sbi));
-
if (test_opt(sbi, POSIX_ACL))
sb->s_flags |= SB_POSIXACL;
else
@@ -454,7 +448,8 @@ static int erofs_fill_super(struct super_block *sb, void 
*data, int silent)
return err;
 
if (!silent)
-   infoln("mounted on %s with opts: %s.", sb->s_id, (char *)data);
+   infoln("mounted on %s with opts: %s, root inode @ nid %llu.",
+  sb->s_id, (char *)data, ROOT_NID(sbi));
return 0;
 }
 
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 13/25] erofs: use dsb instead of layout for ondisk super_block

2019-09-03 Thread Gao Xiang
As Christoph pointed out [1], "Why is the variable name
for the on-disk subperblock layout? We usually still
calls this something with sb in the name, e.g. dsb.
for disksuper block. " Let's fix it.

[1] https://lore.kernel.org/r/20190829101545.gc20...@infradead.org/
Signed-off-by: Gao Xiang 
---
 fs/erofs/super.c | 35 +--
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index b8b0e35f6621..63cb17a4073b 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -49,9 +49,9 @@ static void free_inode(struct inode *inode)
 }
 
 static bool check_layout_compatibility(struct super_block *sb,
-  struct erofs_super_block *layout)
+  struct erofs_super_block *dsb)
 {
-   const unsigned int feature = le32_to_cpu(layout->feature_incompat);
+   const unsigned int feature = le32_to_cpu(dsb->feature_incompat);
 
EROFS_SB(sb)->feature_incompat = feature;
 
@@ -68,7 +68,7 @@ static int superblock_read(struct super_block *sb)
 {
struct erofs_sb_info *sbi;
struct buffer_head *bh;
-   struct erofs_super_block *layout;
+   struct erofs_super_block *dsb;
unsigned int blkszbits;
int ret;
 
@@ -80,16 +80,15 @@ static int superblock_read(struct super_block *sb)
}
 
sbi = EROFS_SB(sb);
-   layout = (struct erofs_super_block *)((u8 *)bh->b_data
-+ EROFS_SUPER_OFFSET);
+   dsb = (struct erofs_super_block *)(bh->b_data + EROFS_SUPER_OFFSET);
 
ret = -EINVAL;
-   if (le32_to_cpu(layout->magic) != EROFS_SUPER_MAGIC_V1) {
+   if (le32_to_cpu(dsb->magic) != EROFS_SUPER_MAGIC_V1) {
errln("cannot find valid erofs superblock");
goto out;
}
 
-   blkszbits = layout->blkszbits;
+   blkszbits = dsb->blkszbits;
/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
if (blkszbits != LOG_BLOCK_SIZE) {
errln("blksize %u isn't supported on this platform",
@@ -97,25 +96,25 @@ static int superblock_read(struct super_block *sb)
goto out;
}
 
-   if (!check_layout_compatibility(sb, layout))
+   if (!check_layout_compatibility(sb, dsb))
goto out;
 
-   sbi->blocks = le32_to_cpu(layout->blocks);
-   sbi->meta_blkaddr = le32_to_cpu(layout->meta_blkaddr);
+   sbi->blocks = le32_to_cpu(dsb->blocks);
+   sbi->meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr);
 #ifdef CONFIG_EROFS_FS_XATTR
-   sbi->xattr_blkaddr = le32_to_cpu(layout->xattr_blkaddr);
+   sbi->xattr_blkaddr = le32_to_cpu(dsb->xattr_blkaddr);
 #endif
sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact));
-   sbi->root_nid = le16_to_cpu(layout->root_nid);
-   sbi->inos = le64_to_cpu(layout->inos);
+   sbi->root_nid = le16_to_cpu(dsb->root_nid);
+   sbi->inos = le64_to_cpu(dsb->inos);
 
-   sbi->build_time = le64_to_cpu(layout->build_time);
-   sbi->build_time_nsec = le32_to_cpu(layout->build_time_nsec);
+   sbi->build_time = le64_to_cpu(dsb->build_time);
+   sbi->build_time_nsec = le32_to_cpu(dsb->build_time_nsec);
 
-   memcpy(&sb->s_uuid, layout->uuid, sizeof(layout->uuid));
+   memcpy(&sb->s_uuid, dsb->uuid, sizeof(dsb->uuid));
 
-   ret = strscpy(sbi->volume_name, layout->volume_name,
- sizeof(layout->volume_name));
+   ret = strscpy(sbi->volume_name, dsb->volume_name,
+ sizeof(dsb->volume_name));
if (ret < 0) {  /* -E2BIG */
errln("bad volume name without NIL terminator");
ret = -EFSCORRUPTED;
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 12/25] erofs: better erofs symlink stuffs

2019-09-03 Thread Gao Xiang
Fix as Christoph suggested [1] [2], "remove is_inode_fast_symlink
and just opencode it in the few places using it"

and
"Please just set the ops directly instead of obsfucating that in
a single caller, single line inline function.  And please set it
instead of the normal symlink iops in the same place where you
also set those."

[1] https://lore.kernel.org/r/20190830163910.gb29...@infradead.org/
[2] https://lore.kernel.org/r/20190829102426.ge20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/inode.c| 68 ++---
 fs/erofs/internal.h | 10 ---
 fs/erofs/super.c|  5 ++--
 3 files changed, 29 insertions(+), 54 deletions(-)

diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index a42f5fc14df9..770f3259c862 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -127,50 +127,39 @@ static int read_inode(struct inode *inode, void *data)
return -EFSCORRUPTED;
 }
 
-/*
- * try_lock can be required since locking order is:
- *   file data(fs_inode)
- *meta(bd_inode)
- * but the majority of the callers is "iget",
- * in that case we are pretty sure no deadlock since
- * no data operations exist. However I tend to
- * try_lock since it takes no much overhead and
- * will success immediately.
- */
-static int fill_inline_data(struct inode *inode, void *data,
-   unsigned int m_pofs)
+static int erofs_fill_symlink(struct inode *inode, void *data,
+ unsigned int m_pofs)
 {
struct erofs_inode *vi = EROFS_I(inode);
struct erofs_sb_info *sbi = EROFS_I_SB(inode);
+   char *lnk;
 
-   /* should be tail-packing data inline */
-   if (vi->datalayout != EROFS_INODE_FLAT_INLINE)
+   /* if it cannot be handled with fast symlink scheme */
+   if (vi->datalayout != EROFS_INODE_FLAT_INLINE ||
+   inode->i_size >= PAGE_SIZE) {
+   inode->i_op = &erofs_symlink_iops;
return 0;
+   }
 
-   /* fast symlink */
-   if (S_ISLNK(inode->i_mode) && inode->i_size < PAGE_SIZE) {
-   char *lnk = erofs_kmalloc(sbi, inode->i_size + 1, GFP_KERNEL);
-
-   if (!lnk)
-   return -ENOMEM;
-
-   m_pofs += vi->inode_isize + vi->xattr_isize;
+   lnk = erofs_kmalloc(sbi, inode->i_size + 1, GFP_KERNEL);
+   if (!lnk)
+   return -ENOMEM;
 
-   /* inline symlink data shouldn't cross page boundary as well */
-   if (m_pofs + inode->i_size > PAGE_SIZE) {
-   kfree(lnk);
-   errln("inline data cross block boundary @ nid %llu",
- vi->nid);
-   DBG_BUGON(1);
-   return -EFSCORRUPTED;
-   }
+   m_pofs += vi->inode_isize + vi->xattr_isize;
+   /* inline symlink data shouldn't cross page boundary as well */
+   if (m_pofs + inode->i_size > PAGE_SIZE) {
+   kfree(lnk);
+   errln("inline data cross block boundary @ nid %llu",
+ vi->nid);
+   DBG_BUGON(1);
+   return -EFSCORRUPTED;
+   }
 
-   memcpy(lnk, data + m_pofs, inode->i_size);
-   lnk[inode->i_size] = '\0';
+   memcpy(lnk, data + m_pofs, inode->i_size);
+   lnk[inode->i_size] = '\0';
 
-   inode->i_link = lnk;
-   set_inode_fast_symlink(inode);
-   }
+   inode->i_link = lnk;
+   inode->i_op = &erofs_fast_symlink_iops;
return 0;
 }
 
@@ -217,8 +206,9 @@ static int fill_inode(struct inode *inode, int isdir)
inode->i_fop = &erofs_dir_fops;
break;
case S_IFLNK:
-   /* by default, page_get_link is used for symlink */
-   inode->i_op = &erofs_symlink_iops;
+   err = erofs_fill_symlink(inode, data, ofs);
+   if (err)
+   goto out_unlock;
inode_nohighmem(inode);
break;
case S_IFCHR:
@@ -237,11 +227,7 @@ static int fill_inode(struct inode *inode, int isdir)
err = z_erofs_fill_inode(inode);
goto out_unlock;
}
-
inode->i_mapping->a_ops = &erofs_raw_access_aops;
-
-   /* fill last page if inline data is available */
-   err = fill_inline_data(inode, data, ofs);
}
 
 out_unlock:
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 10497ee07cae..cc1ea98c5c89 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -479,16 +479,6 @@ extern const struct inode_operations erofs_generic_iops;
 extern const struct inode_operations erofs_symlink_iops;
 extern const struct inode_operations erofs_fast_symlink_iops;
 
-static inline void set_inode_fast_symlink(struct inode *i

[PATCH v2 05/25] erofs: update erofs_inode_is_data_compressed helper

2019-09-03 Thread Gao Xiang
As Christoph said, "This looks like a really obsfucated
way to write:
return datamode == EROFS_INODE_FLAT_COMPRESSION ||
datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY; "

Although I had my own consideration, it's the right way for now.

[1] https://lore.kernel.org/r/20190829095954.gb20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/erofs_fs.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index 59dcc2e8cb02..87d7ae82339a 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -62,9 +62,8 @@ enum {
 
 static inline bool erofs_inode_is_data_compressed(unsigned int datamode)
 {
-   if (datamode == EROFS_INODE_FLAT_COMPRESSION)
-   return true;
-   return datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY;
+   return datamode == EROFS_INODE_FLAT_COMPRESSION ||
+   datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY;
 }
 
 /* bit definitions of inode i_advise */
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 06/25] erofs: use feature_incompat rather than requirements

2019-09-03 Thread Gao Xiang
As Christoph said [1], "This is only cosmetic, why
not stick to feature_compat and feature_incompat?"

In my thought, requirements means "incompatible"
instead of "feature" though.

[1] https://lore.kernel.org/r/20190902125109.ga9...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/decompressor.c |  3 ++-
 fs/erofs/erofs_fs.h | 12 ++--
 fs/erofs/internal.h |  2 +-
 fs/erofs/super.c| 10 +-
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index df349888f911..555c04730f87 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -129,7 +129,8 @@ static int lz4_decompress(struct z_erofs_decompress_req 
*rq, u8 *out)
support_0padding = false;
 
/* decompression inplace is only safe when 0padding is enabled */
-   if (EROFS_SB(rq->sb)->requirements & EROFS_REQUIREMENT_LZ4_0PADDING) {
+   if (EROFS_SB(rq->sb)->feature_incompat &
+   EROFS_FEATURE_INCOMPAT_LZ4_0PADDING) {
support_0padding = true;
 
while (!src[inputmargin & ~PAGE_MASK])
diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index 87d7ae82339a..b2aef3bc377d 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -11,17 +11,17 @@
 #define EROFS_SUPER_OFFSET  1024
 
 /*
- * Any bits that aren't in EROFS_ALL_REQUIREMENTS should be
- * incompatible with this kernel version.
+ * Any bits that aren't in EROFS_ALL_FEATURE_INCOMPAT should
+ * be incompatible with this kernel version.
  */
-#define EROFS_REQUIREMENT_LZ4_0PADDING 0x0001
-#define EROFS_ALL_REQUIREMENTS EROFS_REQUIREMENT_LZ4_0PADDING
+#define EROFS_FEATURE_INCOMPAT_LZ4_0PADDING0x0001
+#define EROFS_ALL_FEATURE_INCOMPAT 
EROFS_FEATURE_INCOMPAT_LZ4_0PADDING
 
 /* 128-byte erofs on-disk super block */
 struct erofs_super_block {
__le32 magic;   /* file system magic number */
__le32 checksum;/* crc32c(super_block) */
-   __le32 features;/* (aka. feature_compat) */
+   __le32 feature_compat;
__u8 blkszbits; /* support block_size == PAGE_SIZE only */
__u8 reserved;
 
@@ -35,7 +35,7 @@ struct erofs_super_block {
__le32 xattr_blkaddr;   /* start block address of shared xattr area */
__u8 uuid[16];  /* 128-bit uuid for volume */
__u8 volume_name[16];   /* volume name */
-   __le32 requirements;/* (aka. feature_incompat) */
+   __le32 feature_incompat;
 
__u8 reserved2[44];
 };
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 141ea424587d..7ff36f404ec3 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -96,7 +96,7 @@ struct erofs_sb_info {
 
u8 uuid[16];/* 128-bit uuid for volume */
u8 volume_name[16]; /* volume name */
-   u32 requirements;
+   u32 feature_incompat;
 
unsigned int mount_opt;
 
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 6603f0ba8905..6a7ab194783c 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -67,14 +67,14 @@ static void free_inode(struct inode *inode)
 static bool check_layout_compatibility(struct super_block *sb,
   struct erofs_super_block *layout)
 {
-   const unsigned int requirements = le32_to_cpu(layout->requirements);
+   const unsigned int feature = le32_to_cpu(layout->feature_incompat);
 
-   EROFS_SB(sb)->requirements = requirements;
+   EROFS_SB(sb)->feature_incompat = feature;
 
/* check if current kernel meets all mandatory requirements */
-   if (requirements & (~EROFS_ALL_REQUIREMENTS)) {
-   errln("unidentified requirements %x, please upgrade kernel 
version",
- requirements & ~EROFS_ALL_REQUIREMENTS);
+   if (feature & (~EROFS_ALL_FEATURE_INCOMPAT)) {
+   errln("unidentified incompatible feature %x, please upgrade 
kernel version",
+ feature & ~EROFS_ALL_FEATURE_INCOMPAT);
return false;
}
return true;
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 03/25] erofs: some macros are much more readable as a function

2019-09-03 Thread Gao Xiang
As Christoph suggested [1], these macros are much
more readable as a function.

[1] https://lore.kernel.org/r/20190829095954.gb20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/erofs_fs.h | 22 ++
 fs/erofs/inode.c|  4 ++--
 fs/erofs/xattr.c|  2 +-
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index d1f152a3670a..c1220b0f26e0 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -171,16 +171,22 @@ struct erofs_xattr_entry {
char   e_name[0];   /* attribute name */
 } __packed;
 
-#define ondisk_xattr_ibody_size(count) ({\
-   u32 __count = le16_to_cpu(count); \
-   ((__count) == 0) ? 0 : \
-   sizeof(struct erofs_xattr_ibody_header) + \
-   sizeof(__u32) * ((__count) - 1); })
+static inline unsigned int erofs_xattr_ibody_size(__le16 i_xattr_icount)
+{
+   if (!i_xattr_icount)
+   return 0;
+
+   return sizeof(struct erofs_xattr_ibody_header) +
+   sizeof(__u32) * (le16_to_cpu(i_xattr_icount) - 1);
+}
 
 #define EROFS_XATTR_ALIGN(size) round_up(size, sizeof(struct 
erofs_xattr_entry))
-#define EROFS_XATTR_ENTRY_SIZE(entry) EROFS_XATTR_ALIGN( \
-   sizeof(struct erofs_xattr_entry) + \
-   (entry)->e_name_len + le16_to_cpu((entry)->e_value_size))
+
+static inline unsigned int erofs_xattr_entry_size(struct erofs_xattr_entry *e)
+{
+   return EROFS_XATTR_ALIGN(sizeof(struct erofs_xattr_entry) +
+e->e_name_len + le16_to_cpu(e->e_value_size));
+}
 
 /* available compression algorithm types */
 enum {
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 8a0574530a0a..3fc4f764b387 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -29,7 +29,7 @@ static int read_inode(struct inode *inode, void *data)
struct erofs_inode_v2 *v2 = data;
 
vi->inode_isize = sizeof(struct erofs_inode_v2);
-   vi->xattr_isize = ondisk_xattr_ibody_size(v2->i_xattr_icount);
+   vi->xattr_isize = erofs_xattr_ibody_size(v2->i_xattr_icount);
 
inode->i_mode = le16_to_cpu(v2->i_mode);
if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
@@ -62,7 +62,7 @@ static int read_inode(struct inode *inode, void *data)
struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb);
 
vi->inode_isize = sizeof(struct erofs_inode_v1);
-   vi->xattr_isize = ondisk_xattr_ibody_size(v1->i_xattr_icount);
+   vi->xattr_isize = erofs_xattr_ibody_size(v1->i_xattr_icount);
 
inode->i_mode = le16_to_cpu(v1->i_mode);
if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
index d80f61dde72f..620cbc15f4d0 100644
--- a/fs/erofs/xattr.c
+++ b/fs/erofs/xattr.c
@@ -231,7 +231,7 @@ static int xattr_foreach(struct xattr_iter *it,
 */
entry = *(struct erofs_xattr_entry *)(it->kaddr + it->ofs);
if (tlimit) {
-   unsigned int entry_sz = EROFS_XATTR_ENTRY_SIZE(&entry);
+   unsigned int entry_sz = erofs_xattr_entry_size(&entry);
 
/* xattr on-disk corruption: xattr entry beyond xattr_isize */
if (*tlimit < entry_sz) {
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 08/25] erofs: kill erofs_{init,exit}_inode_cache

2019-09-03 Thread Gao Xiang
As Christoph said [1] "having this function seems
entirely pointless", let's kill those.

filesystem  function name
ext2,f2fs,ext4,isofs,squashfs,cifs,...  init_inodecache

In addition, add a necessary "rcu_barrier()" on exit_fs();

[1] https://lore.kernel.org/r/20190829101545.gc20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/super.c | 31 ---
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 8d9f38d56b3b..499dc7f5d0e6 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -23,21 +23,6 @@ static void init_once(void *ptr)
inode_init_once(&vi->vfs_inode);
 }
 
-static int __init erofs_init_inode_cache(void)
-{
-   erofs_inode_cachep = kmem_cache_create("erofs_inode",
-  sizeof(struct erofs_vnode), 0,
-  SLAB_RECLAIM_ACCOUNT,
-  init_once);
-
-   return erofs_inode_cachep ? 0 : -ENOMEM;
-}
-
-static void erofs_exit_inode_cache(void)
-{
-   kmem_cache_destroy(erofs_inode_cachep);
-}
-
 static struct inode *alloc_inode(struct super_block *sb)
 {
struct erofs_vnode *vi =
@@ -531,9 +516,14 @@ static int __init erofs_module_init(void)
erofs_check_ondisk_layout_definitions();
infoln("initializing erofs " EROFS_VERSION);
 
-   err = erofs_init_inode_cache();
-   if (err)
+   erofs_inode_cachep = kmem_cache_create("erofs_inode",
+  sizeof(struct erofs_vnode), 0,
+  SLAB_RECLAIM_ACCOUNT,
+  init_once);
+   if (!erofs_inode_cachep) {
+   err = -ENOMEM;
goto icache_err;
+   }
 
err = erofs_init_shrinker();
if (err)
@@ -555,7 +545,7 @@ static int __init erofs_module_init(void)
 zip_err:
erofs_exit_shrinker();
 shrinker_err:
-   erofs_exit_inode_cache();
+   kmem_cache_destroy(erofs_inode_cachep);
 icache_err:
return err;
 }
@@ -565,7 +555,10 @@ static void __exit erofs_module_exit(void)
unregister_filesystem(&erofs_fs_type);
z_erofs_exit_zip_subsystem();
erofs_exit_shrinker();
-   erofs_exit_inode_cache();
+
+   /* Ensure all RCU free inodes are safe before cache is destroyed. */
+   rcu_barrier();
+   kmem_cache_destroy(erofs_inode_cachep);
infoln("successfully finalize erofs");
 }
 
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 00/25] erofs: patchset addressing Christoph's comments

2019-09-03 Thread Gao Xiang
Hi,

This patchset is based on the following patch by Pratik Shinde,
https://lore.kernel.org/linux-erofs/20190830095615.10995-1-pratikshinde...@gmail.com/

All patches addressing Christoph's comments on v6, which are trivial,
most deleted code are from erofs specific fault injection, which was
followed f2fs and previously discussed in earlier topic [1], but
let's follow what Christoph's said now.

Comments and suggestions are welcome...

[1] https://lore.kernel.org/r/1eed1e6b-f95e-aa8e-c3e7-e9870401e...@kernel.org/

changes since v1:
 - leave some comments near the numbers to indicate where they are stored;
 - avoid a u8 cast;
 - use erofs_{err,info,dbg} and print sb->s_id as a prefix before
   the actual message;
 - add a on-disk title in erofs_fs.h
 - use feature_{compat,incompat} rather than features and requirements;
 - suggestions on erofs_grab_bio:
   https://lore.kernel.org/r/20190902122016.gl15...@infradead.org/
 - use compact/extended instead of erofs_inode_v1/v2 and
   i_format instead of i_advise;
 - avoid chained if/else if/else if statements in erofs_read_inode;
 - avoid erofs_vmap/vunmap wrappers;
 - use read_cache_page_gfp for erofs_get_meta_page;

Gao Xiang (25):
  erofs: remove all the byte offset comments
  erofs: on-disk format should have explicitly assigned numbers
  erofs: some macros are much more readable as a function
  erofs: kill __packed for on-disk structures
  erofs: update erofs_inode_is_data_compressed helper
  erofs: use feature_incompat rather than requirements
  erofs: better naming for erofs inode related stuffs
  erofs: kill erofs_{init,exit}_inode_cache
  erofs: use erofs_inode naming
  erofs: update erofs_fs.h comments
  erofs: update comments in inode.c
  erofs: better erofs symlink stuffs
  erofs: use dsb instead of layout for ondisk super_block
  erofs: kill verbose debug info in erofs_fill_super
  erofs: localize erofs_grab_bio()
  erofs: kill prio and nofail of erofs_get_meta_page()
  erofs: kill __submit_bio()
  erofs: add "erofs_" prefix for common and short functions
  erofs: kill all erofs specific fault injection
  erofs: kill use_vmap module parameter
  erofs: save one level of indentation
  erofs: rename errln/infoln/debugln to erofs_{err,info,dbg}
  erofs: use read_mapping_page instead of sb_bread
  erofs: always use iget5_locked
  erofs: use read_cache_page_gfp for erofs_get_meta_page

 Documentation/filesystems/erofs.txt |   9 -
 fs/erofs/Kconfig|   7 -
 fs/erofs/data.c | 118 +++
 fs/erofs/decompressor.c |  76 +++
 fs/erofs/dir.c  |  17 +-
 fs/erofs/erofs_fs.h | 197 +-
 fs/erofs/inode.c| 297 ++--
 fs/erofs/internal.h | 192 --
 fs/erofs/namei.c|  21 +-
 fs/erofs/super.c| 282 +++---
 fs/erofs/xattr.c|  41 ++--
 fs/erofs/xattr.h|   4 +-
 fs/erofs/zdata.c|  63 +++---
 fs/erofs/zdata.h|   2 +-
 fs/erofs/zmap.c |  73 +++
 include/trace/events/erofs.h|  14 +-
 16 files changed, 578 insertions(+), 835 deletions(-)

-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 04/25] erofs: kill __packed for on-disk structures

2019-09-03 Thread Gao Xiang
As Christoph suggested "Please don't add __packed" [1],
remove all __packed except struct erofs_dirent here.

Note that all on-disk fields except struct erofs_dirent
(12 bytes with a 8-byte nid) in EROFS are naturally aligned.

[1] https://lore.kernel.org/r/20190829095954.gb20...@infradead.org/
Reported-by: Christoph Hellwig 
Signed-off-by: Gao Xiang 
---
 fs/erofs/erofs_fs.h | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index c1220b0f26e0..59dcc2e8cb02 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -38,7 +38,7 @@ struct erofs_super_block {
__le32 requirements;/* (aka. feature_incompat) */
 
__u8 reserved2[44];
-} __packed;
+};
 
 /*
  * erofs inode data mapping:
@@ -91,12 +91,12 @@ struct erofs_inode_v1 {
 
/* for device files, used to indicate old/new device # */
__le32 rdev;
-   } i_u __packed;
+   } i_u;
__le32 i_ino;   /* only used for 32-bit stat compatibility */
__le16 i_uid;
__le16 i_gid;
__le32 i_reserved2;
-} __packed;
+};
 
 /* 32 bytes on-disk inode */
 #define EROFS_INODE_LAYOUT_V1   0
@@ -119,7 +119,7 @@ struct erofs_inode_v2 {
 
/* for device files, used to indicate old/new device # */
__le32 rdev;
-   } i_u __packed;
+   } i_u;
 
/* only used for 32-bit stat compatibility */
__le32 i_ino;
@@ -130,7 +130,7 @@ struct erofs_inode_v2 {
__le32 i_ctime_nsec;
__le32 i_nlink;
__u8   i_reserved2[16];
-} __packed;
+};
 
 #define EROFS_MAX_SHARED_XATTRS (128)
 /* h_shared_count between 129 ... 255 are special # */
@@ -152,7 +152,7 @@ struct erofs_xattr_ibody_header {
__u8   h_shared_count;
__u8   h_reserved2[7];
__le32 h_shared_xattrs[0];  /* shared xattr id array */
-} __packed;
+};
 
 /* Name indexes */
 #define EROFS_XATTR_INDEX_USER  1
@@ -169,7 +169,7 @@ struct erofs_xattr_entry {
__le16 e_value_size;/* size of attribute value */
/* followed by e_name and e_value */
char   e_name[0];   /* attribute name */
-} __packed;
+};
 
 static inline unsigned int erofs_xattr_ibody_size(__le16 i_xattr_icount)
 {
@@ -273,8 +273,8 @@ struct z_erofs_vle_decompressed_index {
 * [1] - pointing to the tail cluster
 */
__le16 delta[2];
-   } di_u __packed;
-} __packed;
+   } di_u;
+};
 
 #define Z_EROFS_VLE_LEGACY_INDEX_ALIGN(size) \
(round_up(size, sizeof(struct z_erofs_vle_decompressed_index)) + \
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: exfat: cleanup explicit comparisons to NULL

2019-09-03 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: Comparison to NULL could be written "expr"
  CHECK: Comparison to NULL could be written "!expr"

Signed-off-by: Valentin Vidic 
---
v2: fix gcc warning in strsep call

 drivers/staging/exfat/exfat_core.c  | 34 -
 drivers/staging/exfat/exfat_super.c | 58 ++---
 2 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index da8c58149c35..995358cc7c79 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -100,7 +100,7 @@ void fs_set_vol_flags(struct super_block *sb, u32 new_flag)
p_fs->vol_flag = new_flag;
 
if (p_fs->vol_type == EXFAT) {
-   if (p_fs->pbr_bh == NULL) {
+   if (!p_fs->pbr_bh) {
if (sector_read(sb, p_fs->PBR_sector,
&p_fs->pbr_bh, 1) != FFS_SUCCESS)
return;
@@ -543,7 +543,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
p_fs->vol_amap = 
kmalloc_array(p_fs->map_sectors,
   sizeof(struct 
buffer_head *),
   GFP_KERNEL);
-   if (p_fs->vol_amap == NULL)
+   if (!p_fs->vol_amap)
return FFS_MEMORYERR;
 
sector = START_SECTOR(p_fs->map_clu);
@@ -685,7 +685,7 @@ void sync_alloc_bitmap(struct super_block *sb)
int i;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
 
-   if (p_fs->vol_amap == NULL)
+   if (!p_fs->vol_amap)
return;
 
for (i = 0; i < p_fs->map_sectors; i++)
@@ -714,7 +714,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
 
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
-   if (upcase_table == NULL)
+   if (!upcase_table)
return FFS_MEMORYERR;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
 
@@ -750,11 +750,11 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
} else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
pr_debug("alloc = 0x%X\n", col_index);
upcase_table[col_index] = 
kmalloc_array(UTBL_ROW_COUNT,
sizeof(u16), GFP_KERNEL);
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
ret = FFS_MEMORYERR;
goto error;
}
@@ -794,7 +794,7 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
 
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
-   if (upcase_table == NULL)
+   if (!upcase_table)
return FFS_MEMORYERR;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
 
@@ -812,12 +812,12 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
} else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
pr_debug("alloc = 0x%X\n", col_index);
upcase_table[col_index] = 
kmalloc_array(UTBL_ROW_COUNT,

sizeof(u16),

GFP_KERNEL);
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
ret = FFS_MEMORYERR;
goto error;
}
@@ -1640,7 +1640,7 @@ struct dentry_t *get_entry_with_sector(struct super_block 
*sb, sector_t sector,
 
buf = buf_getblk(sb, sector);
 
-   if (buf == NULL)
+   if (!buf)
return NULL;
 
return (struct dentry_t *)(buf + offset);
@@ -1658,10 +1658,10 @@ struct dentry_t *get_entry_in_dir(struct super_block 
*sb, struct chain_t *p_dir,
 
buf = buf_getblk(sb, sec);
 
-   if (buf == NULL)
+   if (!buf)

Re: [PATCH] staging: exfat: cleanup explicit comparisons to NULL

2019-09-03 Thread Greg Kroah-Hartman
On Tue, Sep 03, 2019 at 07:13:37PM +0200, Valentin Vidic wrote:
> Fixes checkpatch.pl warnings:
> 
>   CHECK: Comparison to NULL could be written "expr"
>   CHECK: Comparison to NULL could be written "!expr"
> 
> Signed-off-by: Valentin Vidic 
> ---
>  drivers/staging/exfat/exfat_core.c  | 34 -
>  drivers/staging/exfat/exfat_super.c | 58 ++---
>  2 files changed, 46 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/staging/exfat/exfat_core.c 
> b/drivers/staging/exfat/exfat_core.c
> index 46b9f4455da1..7b39544cdaf1 100644
> --- a/drivers/staging/exfat/exfat_core.c
> +++ b/drivers/staging/exfat/exfat_core.c
> @@ -100,7 +100,7 @@ void fs_set_vol_flags(struct super_block *sb, u32 
> new_flag)
>   p_fs->vol_flag = new_flag;
>  
>   if (p_fs->vol_type == EXFAT) {
> - if (p_fs->pbr_bh == NULL) {
> + if (!p_fs->pbr_bh) {
>   if (sector_read(sb, p_fs->PBR_sector,
>   &p_fs->pbr_bh, 1) != FFS_SUCCESS)
>   return;
> @@ -543,7 +543,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
>   p_fs->vol_amap = 
> kmalloc_array(p_fs->map_sectors,
>  sizeof(struct 
> buffer_head *),
>  GFP_KERNEL);
> - if (p_fs->vol_amap == NULL)
> + if (!p_fs->vol_amap)
>   return FFS_MEMORYERR;
>  
>   sector = START_SECTOR(p_fs->map_clu);
> @@ -685,7 +685,7 @@ void sync_alloc_bitmap(struct super_block *sb)
>   int i;
>   struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
>  
> - if (p_fs->vol_amap == NULL)
> + if (!p_fs->vol_amap)
>   return;
>  
>   for (i = 0; i < p_fs->map_sectors; i++)
> @@ -714,7 +714,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
> sector_t sector,
>  
>   upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
>   GFP_KERNEL);
> - if (upcase_table == NULL)
> + if (!upcase_table)
>   return FFS_MEMORYERR;
>   memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
>  
> @@ -750,11 +750,11 @@ static s32 __load_upcase_table(struct super_block *sb, 
> sector_t sector,
>   else { /* uni != index , uni != 0x */
>   u16 col_index = get_col_index(index);
>  
> - if (upcase_table[col_index] == NULL) {
> + if (!upcase_table[col_index]) {
>   pr_debug("alloc = 0x%X\n", col_index);
>   upcase_table[col_index] = 
> kmalloc_array(UTBL_ROW_COUNT,
>   sizeof(u16), GFP_KERNEL);
> - if (upcase_table[col_index] == NULL) {
> + if (!upcase_table[col_index]) {
>   ret = FFS_MEMORYERR;
>   goto error;
>   }
> @@ -794,7 +794,7 @@ static s32 __load_default_upcase_table(struct super_block 
> *sb)
>  
>   upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
>   GFP_KERNEL);
> - if (upcase_table == NULL)
> + if (!upcase_table)
>   return FFS_MEMORYERR;
>   memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
>  
> @@ -812,12 +812,12 @@ static s32 __load_default_upcase_table(struct 
> super_block *sb)
>   else { /* uni != index , uni != 0x */
>   u16 col_index = get_col_index(index);
>  
> - if (upcase_table[col_index] == NULL) {
> + if (!upcase_table[col_index]) {
>   pr_debug("alloc = 0x%X\n", col_index);
>   upcase_table[col_index] = 
> kmalloc_array(UTBL_ROW_COUNT,
>   
> sizeof(u16),
>   
> GFP_KERNEL);
> - if (upcase_table[col_index] == NULL) {
> + if (!upcase_table[col_index]) {
>   ret = FFS_MEMORYERR;
>   goto error;
>   }
> @@ -1640,7 +1640,7 @@ struct dentry_t *get_entry_with_sector(struct 
> super_block *sb, sector_t sector,
>  
>   buf = buf_getblk(sb, sector);
>  
> - if (buf == NULL)
> + if (!buf)
>   return NULL;
>  
>   return (struct dentry_t *)(buf + offset);
> @@ -1658,10 +1658,10 @@ struct dentry_t *get_entry_in_dir(struc

[PATCH] staging: exfat: drop local TRUE/FALSE defines

2019-09-03 Thread Valentin Vidic
Replace with bool where it makes sense. Also drop unused local
variable lossy in fat_find_dir_entry.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat.h   |  3 --
 drivers/staging/exfat/exfat_core.c  | 81 +++--
 drivers/staging/exfat/exfat_nls.c   |  2 +-
 drivers/staging/exfat/exfat_super.c | 18 ---
 4 files changed, 53 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 816681d1103a..0aa14dea4e09 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -86,9 +86,6 @@
 #define CLUSTER_16(x)  ((u16)(x))
 #define CLUSTER_32(x)  ((u32)(x))
 
-#define FALSE  0
-#define TRUE   1
-
 #define START_SECTOR(x)
\
sector_t)((x) - 2)) << p_fs->sectors_per_clu_bits) +\
 p_fs->data_start_sector)
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 1246afcffb8d..1630f16459a3 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -705,7 +705,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
struct buffer_head *tmp_bh = NULL;
sector_t end_sector = num_sectors + sector;
 
-   u8  skip = FALSE;
+   boolskip = false;
u32 index = 0;
u16 uni = 0;
u16 **upcase_table;
@@ -742,11 +742,11 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
index += uni;
pr_debug("to 0x%X (amount of 0x%X)\n",
 index, uni);
-   skip = FALSE;
+   skip = false;
} else if (uni == index) {
index++;
} else if (uni == 0x) {
-   skip = TRUE;
+   skip = true;
} else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
@@ -787,7 +787,7 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
u32 j;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
 
-   u8  skip = FALSE;
+   boolskip = false;
u32 index = 0;
u16 uni = 0;
u16 **upcase_table;
@@ -804,11 +804,11 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
pr_debug("skip from 0x%X ", index);
index += uni;
pr_debug("to 0x%X (amount of 0x%X)\n", index, uni);
-   skip = FALSE;
+   skip = false;
} else if (uni == index) {
index++;
} else if (uni == 0x) {
-   skip = TRUE;
+   skip = true;
} else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
@@ -1399,7 +1399,7 @@ void init_dos_entry(struct dos_dentry_t *ep, u32 type, 
u32 start_clu)
 void init_ext_entry(struct ext_dentry_t *ep, s32 order, u8 chksum, u16 
*uniname)
 {
int i;
-   u8 end = FALSE;
+   bool end = false;
 
fat_set_entry_type((struct dentry_t *) ep, TYPE_EXTEND);
ep->order = (u8) order;
@@ -1411,7 +1411,7 @@ void init_ext_entry(struct ext_dentry_t *ep, s32 order, 
u8 chksum, u16 *uniname)
if (!end) {
SET16(ep->unicode_0_4+i, *uniname);
if (*uniname == 0x0)
-   end = TRUE;
+   end = true;
else
uniname++;
} else {
@@ -1423,7 +1423,7 @@ void init_ext_entry(struct ext_dentry_t *ep, s32 order, 
u8 chksum, u16 *uniname)
if (!end) {
SET16_A(ep->unicode_5_10 + i, *uniname);
if (*uniname == 0x0)
-   end = TRUE;
+   end = true;
else
uniname++;
} else {
@@ -1435,7 +1435,7 @@ void init_ext_entry(struct ext_dentry_t *ep, s32 order, 
u8 chksum, u16 *uniname)
if (!end) {
SET16_A(ep->unicode_11_12 + i, *uniname);
if (*uniname == 0x0)
-   end = TRUE;
+   end = true;
else
uniname++;
} else {
@@ -2146,8 +2146,9 @@ s32 fat_find_dir_entry(struct super_block *sb, struct 
chain_t *p_dir,
   struct uni_name_t *p_uniname, s32 num_entries,
   struct dos_na

Re: [PATCH] staging: exfat: cleanup braces for if/else statements

2019-09-03 Thread Greg Kroah-Hartman
On Tue, Sep 03, 2019 at 06:32:49PM +0100, Al Viro wrote:
> On Tue, Sep 03, 2019 at 06:47:32PM +0200, Valentin Vidic wrote:
> > +   } else if (uni == 0x) {
> > skip = TRUE;
> 
> While we are at it, could you get rid of that 'TRUE' macro?
> Or added
> 
> #define THE_TRUTH_AND_THATS_CUTTIN_ME_OWN_THROAT true
> 
> if you want to properly emphasize it...

No, we don't :)

I cleaned up a bunch of those, there are a lot more still left, it is a
mess...
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: exfat: cleanup braces for if/else statements

2019-09-03 Thread Valentin Vidić
On Tue, Sep 03, 2019 at 06:32:49PM +0100, Al Viro wrote:
> On Tue, Sep 03, 2019 at 06:47:32PM +0200, Valentin Vidic wrote:
> > +   } else if (uni == 0x) {
> > skip = TRUE;
> 
> While we are at it, could you get rid of that 'TRUE' macro?

Sure, but maybe in a separate patch since TRUE/FALSE has more
calls than just this.

-- 
Valentin
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: exfat: cleanup braces for if/else statements

2019-09-03 Thread Al Viro
On Tue, Sep 03, 2019 at 06:47:32PM +0200, Valentin Vidic wrote:
> + } else if (uni == 0x) {
>   skip = TRUE;

While we are at it, could you get rid of that 'TRUE' macro?
Or added

#define THE_TRUTH_AND_THATS_CUTTIN_ME_OWN_THROAT true

if you want to properly emphasize it...
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: exfat: cleanup explicit comparisons to NULL

2019-09-03 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: Comparison to NULL could be written "expr"
  CHECK: Comparison to NULL could be written "!expr"

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat_core.c  | 34 -
 drivers/staging/exfat/exfat_super.c | 58 ++---
 2 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 46b9f4455da1..7b39544cdaf1 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -100,7 +100,7 @@ void fs_set_vol_flags(struct super_block *sb, u32 new_flag)
p_fs->vol_flag = new_flag;
 
if (p_fs->vol_type == EXFAT) {
-   if (p_fs->pbr_bh == NULL) {
+   if (!p_fs->pbr_bh) {
if (sector_read(sb, p_fs->PBR_sector,
&p_fs->pbr_bh, 1) != FFS_SUCCESS)
return;
@@ -543,7 +543,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
p_fs->vol_amap = 
kmalloc_array(p_fs->map_sectors,
   sizeof(struct 
buffer_head *),
   GFP_KERNEL);
-   if (p_fs->vol_amap == NULL)
+   if (!p_fs->vol_amap)
return FFS_MEMORYERR;
 
sector = START_SECTOR(p_fs->map_clu);
@@ -685,7 +685,7 @@ void sync_alloc_bitmap(struct super_block *sb)
int i;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
 
-   if (p_fs->vol_amap == NULL)
+   if (!p_fs->vol_amap)
return;
 
for (i = 0; i < p_fs->map_sectors; i++)
@@ -714,7 +714,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
 
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
-   if (upcase_table == NULL)
+   if (!upcase_table)
return FFS_MEMORYERR;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
 
@@ -750,11 +750,11 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
pr_debug("alloc = 0x%X\n", col_index);
upcase_table[col_index] = 
kmalloc_array(UTBL_ROW_COUNT,
sizeof(u16), GFP_KERNEL);
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
ret = FFS_MEMORYERR;
goto error;
}
@@ -794,7 +794,7 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
 
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
-   if (upcase_table == NULL)
+   if (!upcase_table)
return FFS_MEMORYERR;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
 
@@ -812,12 +812,12 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
pr_debug("alloc = 0x%X\n", col_index);
upcase_table[col_index] = 
kmalloc_array(UTBL_ROW_COUNT,

sizeof(u16),

GFP_KERNEL);
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
ret = FFS_MEMORYERR;
goto error;
}
@@ -1640,7 +1640,7 @@ struct dentry_t *get_entry_with_sector(struct super_block 
*sb, sector_t sector,
 
buf = buf_getblk(sb, sector);
 
-   if (buf == NULL)
+   if (!buf)
return NULL;
 
return (struct dentry_t *)(buf + offset);
@@ -1658,10 +1658,10 @@ struct dentry_t *get_entry_in_dir(struct super_block 
*sb, struct chain_t *p_dir,
 
buf = buf_getblk(sb, sec);
 
-   if (buf == NULL)
+   if (!buf)
return NULL;
 
-   i

[PATCH] staging: exfat: fix spelling errors in comments

2019-09-03 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: 'consistancy' may be misspelled - perhaps 'consistency'?
  CHECK: 'stuct' may be misspelled - perhaps 'struct'?

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat_core.c  | 2 +-
 drivers/staging/exfat/exfat_super.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 46b9f4455da1..67e43499d522 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -1754,7 +1754,7 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct 
super_block *sb,
while (num_entries) {
/*
 * instead of copying whole sector, we will check every entry.
-* this will provide minimum stablity and consistancy.
+* this will provide minimum stablity and consistency.
 */
entry_type = p_fs->fs_func->get_entry_type(ep);
 
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 881cd85cf677..56d673ecb70c 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -480,7 +480,7 @@ static int ffsMountVol(struct super_block *sb)
goto out;
}
 
-   /* fill fs_stuct */
+   /* fill fs_struct */
for (i = 0; i < 53; i++)
if (p_pbr->bpb[i])
break;
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: exfat: cleanup braces for if/else statements

2019-09-03 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: Unbalanced braces around else statement
  CHECK: braces {} should be used on all arms of this statement

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat_core.c  | 12 ++--
 drivers/staging/exfat/exfat_super.c | 16 +---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 46b9f4455da1..1246afcffb8d 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -743,11 +743,11 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
pr_debug("to 0x%X (amount of 0x%X)\n",
 index, uni);
skip = FALSE;
-   } else if (uni == index)
+   } else if (uni == index) {
index++;
-   else if (uni == 0x)
+   } else if (uni == 0x) {
skip = TRUE;
-   else { /* uni != index , uni != 0x */
+   } else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
if (upcase_table[col_index] == NULL) {
@@ -805,11 +805,11 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
index += uni;
pr_debug("to 0x%X (amount of 0x%X)\n", index, uni);
skip = FALSE;
-   } else if (uni == index)
+   } else if (uni == index) {
index++;
-   else if (uni == 0x)
+   } else if (uni == 0x) {
skip = TRUE;
-   else { /* uni != index , uni != 0x */
+   } else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
if (upcase_table[col_index] == NULL) {
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 881cd85cf677..e44b860e35e8 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -344,8 +344,10 @@ static int exfat_cmpi(const struct dentry *dentry, 
unsigned int len,
if (t == NULL) {
if (strncasecmp(name->name, str, alen) == 0)
return 0;
-   } else if (nls_strnicmp(t, name->name, str, alen) == 0)
-   return 0;
+   } else {
+   if (nls_strnicmp(t, name->name, str, alen) == 0)
+   return 0;
+   }
}
return 1;
 }
@@ -999,7 +1001,7 @@ static int ffsWriteFile(struct inode *inode, struct 
file_id_t *fid,
   &new_clu);
if (num_alloced == 0)
break;
-   else if (num_alloced < 0) {
+   if (num_alloced < 0) {
ret = FFS_MEDIAERR;
goto out;
}
@@ -1248,9 +1250,9 @@ static int ffsTruncateFile(struct inode *inode, u64 
old_size, u64 new_size)
p_fs->fs_func->set_entry_clu0(ep2, CLUSTER_32(0));
}
 
-   if (p_fs->vol_type != EXFAT)
+   if (p_fs->vol_type != EXFAT) {
buf_modify(sb, sector);
-   else {
+   } else {
update_dir_checksum_with_entry_set(sb, es);
release_entry_set(es);
}
@@ -1561,9 +1563,9 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
fid->attr = attr;
p_fs->fs_func->set_entry_attr(ep, attr);
 
-   if (p_fs->vol_type != EXFAT)
+   if (p_fs->vol_type != EXFAT) {
buf_modify(sb, sector);
-   else {
+   } else {
update_dir_checksum_with_entry_set(sb, es);
release_entry_set(es);
}
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 4.19 127/167] staging: wilc1000: fix error path cleanup in wilc_wlan_initialize()

2019-09-03 Thread Sasha Levin
From: Ajay Singh 

[ Upstream commit 6419f818ababebc1116fb2d0e220bd4fe835d0e3 ]

For the error path in wilc_wlan_initialize(), the resources are not
cleanup in the correct order. Reverted the previous changes and use the
correct order to free during error condition.

Fixes: b46d68825c2d ("staging: wilc1000: remove COMPLEMENT_BOOT")
Cc: 
Signed-off-by: Ajay Singh 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/wilc1000/linux_wlan.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 649caae2b6033..25798119426b3 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -649,17 +649,17 @@ static int wilc_wlan_initialize(struct net_device *dev, 
struct wilc_vif *vif)
goto fail_locks;
}
 
-   if (wl->gpio_irq && init_irq(dev)) {
-   ret = -EIO;
-   goto fail_locks;
-   }
-
ret = wlan_initialize_threads(dev);
if (ret < 0) {
ret = -EIO;
goto fail_wilc_wlan;
}
 
+   if (wl->gpio_irq && init_irq(dev)) {
+   ret = -EIO;
+   goto fail_threads;
+   }
+
if (!wl->dev_irq_num &&
wl->hif_func->enable_interrupt &&
wl->hif_func->enable_interrupt(wl)) {
@@ -715,7 +715,7 @@ static int wilc_wlan_initialize(struct net_device *dev, 
struct wilc_vif *vif)
 fail_irq_init:
if (wl->dev_irq_num)
deinit_irq(dev);
-
+fail_threads:
wlan_deinitialize_threads(dev);
 fail_wilc_wlan:
wilc_wlan_cleanup(dev);
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 0/4] Add binder state and statistics to binderfs

2019-09-03 Thread Hridya Valsaraju
Currently, the only way to access binder state and
statistics is through debugfs. We need a way to
access the same even when debugfs is not mounted.
These patches add a mount option to make this
information available in binderfs without affecting
its presence in debugfs. The following debugfs nodes
will be made available in a binderfs instance when
mounted with the mount option 'stats=global' or 'stats=local'.

 /sys/kernel/debug/binder/failed_transaction_log
 /sys/kernel/debug/binder/proc
 /sys/kernel/debug/binder/state
 /sys/kernel/debug/binder/stats
 /sys/kernel/debug/binder/transaction_log
 /sys/kernel/debug/binder/transactions

Hridya Valsaraju (4):
  binder: add a mount option to show global stats
  binder: Add stats, state and transactions files
  binder: Make transaction_log available in binderfs
  binder: Add binder_proc logging to binderfs

 drivers/android/binder.c  |  95 ++-
 drivers/android/binder_internal.h |  84 ++
 drivers/android/binderfs.c| 255 ++
 3 files changed, 362 insertions(+), 72 deletions(-)

-- 
2.23.0.187.g17f5b7556c-goog

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 00/21] erofs: patchset addressing Christoph's comments

2019-09-03 Thread Gao Xiang
Hi Christoph,

On Tue, Sep 03, 2019 at 08:37:04AM -0700, Christoph Hellwig wrote:
> On Tue, Sep 03, 2019 at 04:17:49PM +0800, Gao Xiang wrote:
> > I implement a prelimitary version, but I have no idea it is a really
> > cleanup for now.
> 
> The fact that this has to guess the block device address_space
> implementation is indeed pretty ugly.  I'd much prefer to just use
> read_cache_page_gfp, and live with the fact that this allocates
> bufferheads behind you for now.  I'll try to speed up my attempts to
> get rid of the buffer heads on the block device mapping instead.

Fully agree with your point. Let me use read_cache_page_gfp
instead for now, hoping block device quickly avoiding from
buffer_heads...

Thanks,
Gao Xiang

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 00/21] erofs: patchset addressing Christoph's comments

2019-09-03 Thread Christoph Hellwig
On Tue, Sep 03, 2019 at 04:17:49PM +0800, Gao Xiang wrote:
> I implement a prelimitary version, but I have no idea it is a really
> cleanup for now.

The fact that this has to guess the block device address_space
implementation is indeed pretty ugly.  I'd much prefer to just use
read_cache_page_gfp, and live with the fact that this allocates
bufferheads behind you for now.  I'll try to speed up my attempts to
get rid of the buffer heads on the block device mapping instead.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v6 01/24] erofs: add on-disk layout

2019-09-03 Thread Pavel Machek
Hi!

> > No. gdb tells you what the actual offsets _are_.
> 
> Ok, reading your reply twice, I think we have different perspectives. I
> don't trust the comments.
> 
> The tool I had in mind is pahole that parses dwarf information about the
> structures, the same as gdb does. The actual value of the struct members
> is the thing that needs to be investigated in memory dumps or disk image
> dumps.
> 
> > > > The expected offset is somewhat valuable, but
> > > > perhaps the form is a bit off given the visual
> > > > run-in to the field types.
> > > > 
> > > > The extra work with this form is manipulating all
> > > > the offsets whenever a structure change occurs.
> > > 
> > > ... while this is error prone.
> > 
> > While the comment tells you what they _should be_.
> 
> That's exactly the source of confusion and bugs. For me an acceptable
> way of asserting that a value has certain offset is a build check, eg.
> like
> 
> BUILD_BUG_ON(strct my_superblock, magic, 16);

Yes, that would work, too. As would documentation file with the disk
structures.

Best regards,
Pavel
-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


signature.asc
Description: Digital signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rts5208: Modified nested if blocks.

2019-09-03 Thread Greg KH
On Tue, Sep 03, 2019 at 02:32:40PM +0530, Prakhar Sinha wrote:
> This patch solves the following checkpatch.pl's messages in
> drivers/staging/rts5208/sd.c
> 
> WARNING: line over 80 characters
> 4517: FILE: drivers/staging/rts5208/sd.c:4517:
> +   sd_card->sd_lock_status &=
> ~(SD_UNLOCK_POW_ON | SD_SDR_RST);
> 
> WARNING: line over 80 characters
> 4518: FILE: drivers/staging/rts5208/sd.c:4518:
> +   goto
> sd_execute_write_cmd_failed;

Please keep the full line without wrapping them in these messages.

And your subject is a big odd, look at the documentation for how to
create a good subject line.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rts5208: Modified nested if blocks.

2019-09-03 Thread Prakhar Sinha
This patch solves the following checkpatch.pl's messages in
drivers/staging/rts5208/sd.c

WARNING: line over 80 characters
4517: FILE: drivers/staging/rts5208/sd.c:4517:
+   sd_card->sd_lock_status &=
~(SD_UNLOCK_POW_ON | SD_SDR_RST);

WARNING: line over 80 characters
4518: FILE: drivers/staging/rts5208/sd.c:4518:
+   goto
sd_execute_write_cmd_failed;

WARNING: line over 80 characters
4522: FILE: drivers/staging/rts5208/sd.c:4522:
+   sd_card->sd_lock_status &= ~(SD_UNLOCK_POW_ON |
SD_SDR_RST);

Signed-off-by: Prakhar Sinha 
---
 drivers/staging/rts5208/sd.c | 26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c
index a06045344301..7d6f2c56e740 100644
--- a/drivers/staging/rts5208/sd.c
+++ b/drivers/staging/rts5208/sd.c
@@ -4505,22 +4505,20 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct 
rtsx_chip *chip)
 
dev_dbg(rtsx_dev(chip), "sd_lock_state = 0x%x, 
sd_card->sd_lock_status = 0x%x\n",
sd_lock_state, sd_card->sd_lock_status);
-   if (sd_lock_state ^ (sd_card->sd_lock_status & SD_LOCKED)) {
+   if (sd_lock_state ^ (sd_card->sd_lock_status & SD_LOCKED))
sd_card->sd_lock_notify = 1;
-   if (sd_lock_state &&
-   (sd_card->sd_lock_status & SD_LOCK_1BIT_MODE)) {
-   sd_card->sd_lock_status |= (
-   SD_UNLOCK_POW_ON | SD_SDR_RST);
-   if (CHK_SD(sd_card)) {
-   retval = reset_sd(chip);
-   if (retval != STATUS_SUCCESS) {
-   sd_card->sd_lock_status &= 
~(SD_UNLOCK_POW_ON | SD_SDR_RST);
-   goto 
sd_execute_write_cmd_failed;
-   }
-   }
-
-   sd_card->sd_lock_status &= ~(SD_UNLOCK_POW_ON | 
SD_SDR_RST);
+   if ((sd_lock_state & !(sd_card->sd_lock_status & SD_LOCKED)) &&
+   (sd_card->sd_lock_status & SD_LOCK_1BIT_MODE)) {
+   sd_card->sd_lock_status |= (SD_UNLOCK_POW_ON |
+   SD_SDR_RST);
+   if (CHK_SD(sd_card) &&
+   reset_sd(chip) != STATUS_SUCCESS) {
+   sd_card->sd_lock_status &= ~(SD_UNLOCK_POW_ON |
+SD_SDR_RST);
+   goto sd_execute_write_cmd_failed;
}
+   sd_card->sd_lock_status &= ~(SD_UNLOCK_POW_ON |
+SD_SDR_RST);
}
}
 
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 00/21] erofs: patchset addressing Christoph's comments

2019-09-03 Thread Gao Xiang
Hi Christoph,

On Mon, Sep 02, 2019 at 11:58:03PM -0700, Christoph Hellwig wrote:
> On Mon, Sep 02, 2019 at 11:50:38PM +0800, Gao Xiang wrote:
> > > > You means killing erofs_get_meta_page or avoid erofs_read_raw_page?
> > > > 
> > > >  - For killing erofs_get_meta_page, here is the current 
> > > > erofs_get_meta_page:
> > > 
> > > > I think it is simple enough. read_cache_page need write a similar
> > > > filler, or read_cache_page_gfp will call .readpage, and then
> > > > introduce buffer_heads, that is what I'd like to avoid now (no need 
> > > > these
> > > > bd_inode buffer_heads in memory...)
> > > 
> > > If using read_cache_page_gfp and ->readpage works, please do.  The
> > > fact that the block device inode uses buffer heads is an implementation
> > > detail that might not last very long and should be invisible to you.
> > > It also means you can get rid of a lot of code that you don't have
> > > to maintain and others don't have to update for global API changes.
> > 
> > I care about those useless buffer_heads in memory for our products...
> > 
> > Since we are nobh filesystem (a little request, could I use it
> > after buffer_heads are fully avoided, I have no idea why I need
> > those buffer_heads in memory But I think bd_inode is good
> > for caching metadata...)
> 
> Then please use read_cache_page with iomap_readpage(s), and write
> comment explaining why your are not using read_cache_page_gfp.

I implement a prelimitary version, but I have no idea it is a really
cleanup for now.

>From 001e3e64c81e4ced0d22b147e6abf90060e704b5 Mon Sep 17 00:00:00 2001
From: Gao Xiang 
Date: Tue, 3 Sep 2019 16:13:00 +0800
Subject: [PATCH] erofs: use iomap_readpage for erofs_get_meta_page

Signed-off-by: Gao Xiang 
---
 fs/erofs/Kconfig |  1 +
 fs/erofs/data.c  | 91 ++--
 2 files changed, 51 insertions(+), 41 deletions(-)

diff --git a/fs/erofs/Kconfig b/fs/erofs/Kconfig
index 9d634d3a1845..c9eeb0bf4737 100644
--- a/fs/erofs/Kconfig
+++ b/fs/erofs/Kconfig
@@ -3,6 +3,7 @@
 config EROFS_FS
tristate "EROFS filesystem support"
depends on BLOCK
+   select FS_IOMAP
help
  EROFS (Enhanced Read-Only File System) is a lightweight
  read-only file system with modern designs (eg. page-sized
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 3881c0689134..34c6e05fab71 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -5,6 +5,9 @@
  * Created by Gao Xiang 
  */
 #include "internal.h"
+#include 
+#include 
+#include 
 #include 
 
 #include 
@@ -51,54 +54,60 @@ static struct bio *erofs_grab_raw_bio(struct super_block 
*sb,
return bio;
 }
 
-struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr)
+static int erofs_meta_iomap_begin(struct inode *inode, loff_t pos,
+ loff_t length, unsigned int flags,
+ struct iomap *iomap)
 {
-   struct inode *const bd_inode = sb->s_bdev->bd_inode;
-   struct address_space *const mapping = bd_inode->i_mapping;
-   /* prefer retrying in the allocator to blindly looping below */
-   const gfp_t gfp = mapping_gfp_constraint(mapping, ~__GFP_FS);
-   struct page *page;
-   int err;
-
-repeat:
-   page = find_or_create_page(mapping, blkaddr, gfp);
-   if (!page)
-   return ERR_PTR(-ENOMEM);
-
-   DBG_BUGON(!PageLocked(page));
-
-   if (!PageUptodate(page)) {
-   struct bio *bio;
+   const unsigned int blkbits = inode->i_blkbits;
+
+   iomap->flags = 0;
+   iomap->bdev = I_BDEV(inode);
+   iomap->offset = round_down(pos, 1 << blkbits);
+   iomap->addr = iomap->offset;
+   iomap->length = round_up(length, 1 << blkbits);
+   iomap->type = IOMAP_MAPPED;
+   return 0;
+}
 
-   bio = erofs_grab_raw_bio(sb, blkaddr, 1, true);
+static const struct iomap_ops erofs_meta_iomap_ops = {
+   .iomap_begin = erofs_meta_iomap_begin,
+};
 
-   if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
-   err = -EFAULT;
-   goto err_out;
-   }
+static int
+erofs_meta_get_block(struct inode *inode, sector_t iblock,
+struct buffer_head *bh, int create)
+{
+   bh->b_bdev = I_BDEV(inode);
+   bh->b_blocknr = iblock;
+   set_buffer_mapped(bh);
+   return 0;
+}
 
-   submit_bio(bio);
-   lock_page(page);
+static int erofs_read_meta_page(void *file, struct page *page)
+{
+   /* in case of getting some pages with buffer_heads */
+   if (i_blocksize(page->mapping->host) == PAGE_SIZE &&
+   !page_has_buffers(page))
+   return iomap_readpage(page, &erofs_meta_iomap_ops);
+
+   /*
+* cannot use blkdev_readpage or blkdev_get_block directly
+* since static in block_dev.c
+*/
+   return mpage_readpage(page, erofs_meta_get_block);
+}
 
-   /* 

Re: [PATCH] staging: rts5208: Fixed checkpatch warning.

2019-09-03 Thread Greg KH
On Sat, Aug 31, 2019 at 01:10:55PM +0530, Prakhar Sinha wrote:
> This patch solves the following checkpatch.pl's messages in
> drivers/staging/rts5208/sd.c
> 
> WARNING: line over 80 characters
> 4517: FILE: drivers/staging/rts5208/sd.c:4517:
> +   sd_card->sd_lock_status &=
> ~(SD_UNLOCK_POW_ON | SD_SDR_RST);
> 
> WARNING: line over 80 characters
> 4518: FILE: drivers/staging/rts5208/sd.c:4518:
> +   goto
> sd_execute_write_cmd_failed;
> 
> WARNING: line over 80 characters
> 4522: FILE: drivers/staging/rts5208/sd.c:4522:
> +   sd_card->sd_lock_status &= ~(SD_UNLOCK_POW_ON 
> |
> SD_SDR_RST);
> 
> Signed-off-by: Prakhar Sinha 
> ---
>  drivers/staging/rts5208/sd.c | 26 --
>  1 file changed, 12 insertions(+), 14 deletions(-)

Same subject line as your previous patch, please fix it up to be unique.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rts5208: Fix checkpath warning

2019-09-03 Thread Greg KH
On Sat, Aug 31, 2019 at 01:02:24PM +0530, P SAI PRASANTH wrote:
> This patch fixes the following checkpath warning
> in file drivers/staging/rts5208/xd.c:1754
> 
> WARNING: line over 80 characters
> +   index, offset, DMA_TO_DEVICE,
> chip->xd_timeout);
> 
> Signed-off-by: P SAI PRASANTH 
> ---
>  drivers/staging/rts5208/xd.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

This had the same subject line as your previous patch, but did different
things.  Please make the subjects unique.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel