* [patch set 4.19.6] BFS updates
@ 2018-12-02 21:01 Tigran Aivazian
2018-12-02 21:42 ` Tigran Aivazian
0 siblings, 1 reply; 4+ messages in thread
From: Tigran Aivazian @ 2018-12-02 21:01 UTC (permalink / raw)
To: torvalds, LKML
[-- Attachment #1: Type: text/plain, Size: 223 bytes --]
Hi Linus,
I attached two incremental patches for BFS:
1. Make inode bitmap allocation static (applies on top of 4.19.6)
2. Strengthen the superblock sanity checking code (applies on top of 1. above)
Kind regards,
Tigran
[-- Attachment #2: bfs-4.19.6-1-of-2-static-inode-bitmap.patch --]
[-- Type: text/x-patch, Size: 3479 bytes --]
From: Tigran Aivazian <aivazian.tigran@gmail.com>
Subject: [PATCH 4.19.6 1/2] BFS updates
Make in-core inode bitmap static part of superblock info structure an.
print a warning when mounting a BFS filesystem created with "-N 512"
option as only 510 files can be created in the root directory.
Signed-off-by: Tigran Aivazian <aivazian.tigran@gmail.com>
---
bfs.h | 9 ++++++++-
inode.c | 27 +++++++++++----------------
2 files changed, 19 insertions(+), 17 deletions(-)
--- fs/bfs/bfs.h.0 2018-12-02 20:33:02.252710291 +0000
+++ fs/bfs/bfs.h 2018-12-02 20:34:34.041246489 +0000
@@ -8,6 +8,13 @@
#include <linux/bfs_fs.h>
+/* In theory BFS supports up to 512 inodes, numbered from 2 (for /) up to 513 inclusive.
+ In actual fact, attempting to create the 512th inode (i.e. inode No. 513 or file No. 511)
+ will fail with ENOSPC in bfs_add_entry(): the root directory cannot contain so many entries, counting '..'.
+ So, mkfs.bfs(8) should really limit its -N option to 511 and not 512. For now, we just print a warning
+ if a filesystem is mounted with such "impossible to fill up" number of inodes */
+#define BFS_MAX_LASTI 513
+
/*
* BFS file system in-core superblock info
*/
@@ -17,7 +24,7 @@
unsigned long si_freei;
unsigned long si_lf_eblk;
unsigned long si_lasti;
- unsigned long *si_imap;
+ DECLARE_BITMAP(si_imap, BFS_MAX_LASTI+1);
struct mutex bfs_lock;
};
--- fs/bfs/inode.c.0 2018-12-02 20:34:03.211740877 +0000
+++ fs/bfs/inode.c 2018-12-02 20:36:54.508963813 +0000
@@ -214,7 +214,6 @@
return;
mutex_destroy(&info->bfs_lock);
- kfree(info->si_imap);
kfree(info);
s->s_fs_info = NULL;
}
@@ -322,7 +321,7 @@
struct buffer_head *bh, *sbh;
struct bfs_super_block *bfs_sb;
struct inode *inode;
- unsigned i, imap_len;
+ unsigned i;
struct bfs_sb_info *info;
int ret = -EINVAL;
unsigned long i_sblock, i_eblock, i_eoff, s_size;
@@ -356,13 +355,11 @@
goto out1;
}
- info->si_lasti = (le32_to_cpu(bfs_sb->s_start) - BFS_BSIZE) /
- sizeof(struct bfs_inode)
- + BFS_ROOT_INO - 1;
- imap_len = (info->si_lasti / 8) + 1;
- info->si_imap = kzalloc(imap_len, GFP_KERNEL | __GFP_NOWARN);
- if (!info->si_imap) {
- printf("Cannot allocate %u bytes\n", imap_len);
+ info->si_lasti = (le32_to_cpu(bfs_sb->s_start) - BFS_BSIZE) / sizeof(struct bfs_inode) + BFS_ROOT_INO - 1;
+ if (info->si_lasti == BFS_MAX_LASTI)
+ printf("WARNING: filesystem %s was created with 512 inodes, the real maximum is 511, mounting anyway\n", s->s_id);
+ else if (info->si_lasti > BFS_MAX_LASTI) {
+ printf("Impossible last inode number %lu > %d on %s\n", info->si_lasti, BFS_MAX_LASTI, s->s_id);
goto out1;
}
for (i = 0; i < BFS_ROOT_INO; i++)
@@ -372,12 +369,12 @@
inode = bfs_iget(s, BFS_ROOT_INO);
if (IS_ERR(inode)) {
ret = PTR_ERR(inode);
- goto out2;
+ goto out1;
}
s->s_root = d_make_root(inode);
if (!s->s_root) {
ret = -ENOMEM;
- goto out2;
+ goto out1;
}
info->si_blocks = (le32_to_cpu(bfs_sb->s_end) + 1) >> BFS_BSIZE_BITS;
@@ -391,7 +388,7 @@
if (!bh) {
printf("Last block not available: %lu\n", info->si_blocks - 1);
ret = -EIO;
- goto out3;
+ goto out2;
}
brelse(bh);
@@ -429,7 +426,7 @@
brelse(bh);
ret = -EIO;
- goto out3;
+ goto out2;
}
if (!di->i_ino) {
@@ -448,11 +445,9 @@
bfs_dump_imap("read_super", s);
return 0;
-out3:
+out2:
dput(s->s_root);
s->s_root = NULL;
-out2:
- kfree(info->si_imap);
out1:
brelse(sbh);
out:
[-- Attachment #3: bfs-4.19.6-2-of-2-strengthen-sanity-checking.patch --]
[-- Type: text/x-patch, Size: 744 bytes --]
From: Tigran Aivazian <aivazian.tigran@gmail.com>
Subject: [PATCH 4.19.6 2/2] BFS updates
Strengthen the superblock sanity checking (supersedes the code
that went into 4.19.6).
Signed-off-by: Tigran Aivazian <aivazian.tigran@gmail.com>
---
inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- fs/bfs/inode.c.0 2018-12-02 20:49:00.525461354 +0000
+++ fs/bfs/inode.c 2018-12-02 20:49:51.054686779 +0000
@@ -350,7 +350,7 @@
s->s_magic = BFS_MAGIC;
if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end) ||
- le32_to_cpu(bfs_sb->s_start) < BFS_BSIZE) {
+ le32_to_cpu(bfs_sb->s_start) < sizeof(struct bfs_super_block) + sizeof(struct bfs_dirent)) {
printf("Superblock is corrupted\n");
goto out1;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch set 4.19.6] BFS updates
2018-12-02 21:01 [patch set 4.19.6] BFS updates Tigran Aivazian
@ 2018-12-02 21:42 ` Tigran Aivazian
2018-12-03 9:55 ` Tigran Aivazian
0 siblings, 1 reply; 4+ messages in thread
From: Tigran Aivazian @ 2018-12-02 21:42 UTC (permalink / raw)
To: torvalds, LKML
just wanted to add: although the subject says "4.19.6" the patches
apply perfectly to the top of "torvalds/linux" tree from github.
On Sun, 2 Dec 2018 at 21:01, Tigran Aivazian <aivazian.tigran@gmail.com> wrote:
>
> Hi Linus,
>
> I attached two incremental patches for BFS:
>
> 1. Make inode bitmap allocation static (applies on top of 4.19.6)
> 2. Strengthen the superblock sanity checking code (applies on top of 1. above)
>
> Kind regards,
> Tigran
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch set 4.19.6] BFS updates
2018-12-02 21:42 ` Tigran Aivazian
@ 2018-12-03 9:55 ` Tigran Aivazian
2018-12-03 10:26 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Tigran Aivazian @ 2018-12-03 9:55 UTC (permalink / raw)
To: torvalds, LKML, stable, gregkh
[-- Attachment #1: Type: text/plain, Size: 756 bytes --]
Re-sending the patches with the "Cc: stable@vger.kernel.org" included
in the sign-off area, as per Option 1 of the rules Greg referred me
to. I hope that now I have done everything by the rules.
On Sun, 2 Dec 2018 at 21:42, Tigran Aivazian <aivazian.tigran@gmail.com> wrote:
>
> just wanted to add: although the subject says "4.19.6" the patches
> apply perfectly to the top of "torvalds/linux" tree from github.
> On Sun, 2 Dec 2018 at 21:01, Tigran Aivazian <aivazian.tigran@gmail.com> wrote:
> >
> > Hi Linus,
> >
> > I attached two incremental patches for BFS:
> >
> > 1. Make inode bitmap allocation static (applies on top of 4.19.6)
> > 2. Strengthen the superblock sanity checking code (applies on top of 1. above)
> >
> > Kind regards,
> > Tigran
[-- Attachment #2: bfs-4.19.6-1-of-2-static-inode-bitmap.patch --]
[-- Type: text/x-patch, Size: 3506 bytes --]
From: Tigran Aivazian <aivazian.tigran@gmail.com>
Subject: [PATCH 4.19.6 1/2] BFS updates
Make in-core inode bitmap static part of superblock info structure an.
print a warning when mounting a BFS filesystem created with "-N 512"
option as only 510 files can be created in the root directory.
Signed-off-by: Tigran Aivazian <aivazian.tigran@gmail.com>
Cc: stable@vger.kernel.org
---
bfs.h | 9 ++++++++-
inode.c | 27 +++++++++++----------------
2 files changed, 19 insertions(+), 17 deletions(-)
--- fs/bfs/bfs.h.0 2018-12-02 20:33:02.252710291 +0000
+++ fs/bfs/bfs.h 2018-12-02 20:34:34.041246489 +0000
@@ -8,6 +8,13 @@
#include <linux/bfs_fs.h>
+/* In theory BFS supports up to 512 inodes, numbered from 2 (for /) up to 513 inclusive.
+ In actual fact, attempting to create the 512th inode (i.e. inode No. 513 or file No. 511)
+ will fail with ENOSPC in bfs_add_entry(): the root directory cannot contain so many entries, counting '..'.
+ So, mkfs.bfs(8) should really limit its -N option to 511 and not 512. For now, we just print a warning
+ if a filesystem is mounted with such "impossible to fill up" number of inodes */
+#define BFS_MAX_LASTI 513
+
/*
* BFS file system in-core superblock info
*/
@@ -17,7 +24,7 @@
unsigned long si_freei;
unsigned long si_lf_eblk;
unsigned long si_lasti;
- unsigned long *si_imap;
+ DECLARE_BITMAP(si_imap, BFS_MAX_LASTI+1);
struct mutex bfs_lock;
};
--- fs/bfs/inode.c.0 2018-12-02 20:34:03.211740877 +0000
+++ fs/bfs/inode.c 2018-12-02 20:36:54.508963813 +0000
@@ -214,7 +214,6 @@
return;
mutex_destroy(&info->bfs_lock);
- kfree(info->si_imap);
kfree(info);
s->s_fs_info = NULL;
}
@@ -322,7 +321,7 @@
struct buffer_head *bh, *sbh;
struct bfs_super_block *bfs_sb;
struct inode *inode;
- unsigned i, imap_len;
+ unsigned i;
struct bfs_sb_info *info;
int ret = -EINVAL;
unsigned long i_sblock, i_eblock, i_eoff, s_size;
@@ -356,13 +355,11 @@
goto out1;
}
- info->si_lasti = (le32_to_cpu(bfs_sb->s_start) - BFS_BSIZE) /
- sizeof(struct bfs_inode)
- + BFS_ROOT_INO - 1;
- imap_len = (info->si_lasti / 8) + 1;
- info->si_imap = kzalloc(imap_len, GFP_KERNEL | __GFP_NOWARN);
- if (!info->si_imap) {
- printf("Cannot allocate %u bytes\n", imap_len);
+ info->si_lasti = (le32_to_cpu(bfs_sb->s_start) - BFS_BSIZE) / sizeof(struct bfs_inode) + BFS_ROOT_INO - 1;
+ if (info->si_lasti == BFS_MAX_LASTI)
+ printf("WARNING: filesystem %s was created with 512 inodes, the real maximum is 511, mounting anyway\n", s->s_id);
+ else if (info->si_lasti > BFS_MAX_LASTI) {
+ printf("Impossible last inode number %lu > %d on %s\n", info->si_lasti, BFS_MAX_LASTI, s->s_id);
goto out1;
}
for (i = 0; i < BFS_ROOT_INO; i++)
@@ -372,12 +369,12 @@
inode = bfs_iget(s, BFS_ROOT_INO);
if (IS_ERR(inode)) {
ret = PTR_ERR(inode);
- goto out2;
+ goto out1;
}
s->s_root = d_make_root(inode);
if (!s->s_root) {
ret = -ENOMEM;
- goto out2;
+ goto out1;
}
info->si_blocks = (le32_to_cpu(bfs_sb->s_end) + 1) >> BFS_BSIZE_BITS;
@@ -391,7 +388,7 @@
if (!bh) {
printf("Last block not available: %lu\n", info->si_blocks - 1);
ret = -EIO;
- goto out3;
+ goto out2;
}
brelse(bh);
@@ -429,7 +426,7 @@
brelse(bh);
ret = -EIO;
- goto out3;
+ goto out2;
}
if (!di->i_ino) {
@@ -448,11 +445,9 @@
bfs_dump_imap("read_super", s);
return 0;
-out3:
+out2:
dput(s->s_root);
s->s_root = NULL;
-out2:
- kfree(info->si_imap);
out1:
brelse(sbh);
out:
[-- Attachment #3: bfs-4.19.6-2-of-2-strengthen-sanity-checking.patch --]
[-- Type: text/x-patch, Size: 771 bytes --]
From: Tigran Aivazian <aivazian.tigran@gmail.com>
Subject: [PATCH 4.19.6 2/2] BFS updates
Strengthen the superblock sanity checking (supersedes the code
that went into 4.19.6).
Signed-off-by: Tigran Aivazian <aivazian.tigran@gmail.com>
Cc: stable@vger.kernel.org
---
inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- fs/bfs/inode.c.0 2018-12-02 20:49:00.525461354 +0000
+++ fs/bfs/inode.c 2018-12-02 20:49:51.054686779 +0000
@@ -350,7 +350,7 @@
s->s_magic = BFS_MAGIC;
if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end) ||
- le32_to_cpu(bfs_sb->s_start) < BFS_BSIZE) {
+ le32_to_cpu(bfs_sb->s_start) < sizeof(struct bfs_super_block) + sizeof(struct bfs_dirent)) {
printf("Superblock is corrupted\n");
goto out1;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch set 4.19.6] BFS updates
2018-12-03 9:55 ` Tigran Aivazian
@ 2018-12-03 10:26 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2018-12-03 10:26 UTC (permalink / raw)
To: Tigran Aivazian; +Cc: torvalds, LKML, stable
On Mon, Dec 03, 2018 at 09:55:23AM +0000, Tigran Aivazian wrote:
> Re-sending the patches with the "Cc: stable@vger.kernel.org" included
> in the sign-off area, as per Option 1 of the rules Greg referred me
> to. I hope that now I have done everything by the rules.
As you want to replace an existing patch in linux-next that is in
Andrew's trees, you need to cc: him :)
Also, you need to send each patch as an individual email, like
Documentation/SubmittingPatches says to do.
This shouldn't be any different from submitting any other patch.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-03 10:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-02 21:01 [patch set 4.19.6] BFS updates Tigran Aivazian
2018-12-02 21:42 ` Tigran Aivazian
2018-12-03 9:55 ` Tigran Aivazian
2018-12-03 10:26 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.