Re: [PATCH 2/7] omfs: add inode routines

Previous thread: [PATCH 6/7] omfs: add checksumming routines by Bob Copeland on Saturday, April 12, 2008 - 6:58 pm. (2 messages)

Next thread: 現在註冊就送1,000點註冊 by 潘玉龍 on Saturday, April 12, 2008 - 7:40 pm. (1 message)
To: <linux-kernel@...>
Cc: <linux-fsdevel@...>, <akpm@...>, Bob Copeland <me@...>
Date: Saturday, April 12, 2008 - 6:58 pm

Add basic superblock and inode handling routines for OMFS

Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
fs/omfs/inode.c | 439 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 439 insertions(+), 0 deletions(-)
create mode 100644 fs/omfs/inode.c

diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
new file mode 100644
index 0000000..92d794f
--- /dev/null
+++ b/fs/omfs/inode.c
@@ -0,0 +1,439 @@
+/*
+ * Optimized MPEG FS - inode and super operations.
+ * Copyright (C) 2006 Bob Copeland <me@bobcopeland.com>
+ * Released under GPL v2.
+ */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/fs.h>
+#include <linux/vfs.h>
+#include <linux/buffer_head.h>
+#include <linux/vmalloc.h>
+#include "omfs.h"
+
+MODULE_AUTHOR("Bob Copeland <me@bobcopeland.com>");
+MODULE_DESCRIPTION("OMFS (ReplayTV/Karma) Filesystem for Linux");
+MODULE_LICENSE("GPL");
+
+struct inode *omfs_new_inode(struct inode *dir, int mode)
+{
+ struct inode *inode;
+ u64 new_block;
+ int res;
+ int len;
+ struct omfs_sb_info *sbi = OMFS_SB(dir->i_sb);
+
+ inode = new_inode(dir->i_sb);
+ if (!inode)
+ return ERR_PTR(-ENOMEM);
+
+ res = omfs_allocate_range(dir->i_sb, sbi->s_mirrors, sbi->s_mirrors,
+ &new_block, &len);
+ if (res)
+ return ERR_PTR(res);
+
+ inode->i_ino = new_block;
+ inode->i_mode = mode;
+ inode->i_uid = current->fsuid;
+ inode->i_gid = current->fsgid;
+ inode->i_blocks = 0;
+ inode->i_mapping->a_ops = &omfs_aops;
+
+ inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+ switch (mode & S_IFMT) {
+ case S_IFDIR:
+ inode->i_op = &omfs_dir_inops;
+ inode->i_fop = &omfs_dir_operations;
+ inode->i_size = sbi->s_sys_blocksize;
+ inode->i_nlink++;
+ break;
+ case S_IFREG:
+ inode->i_op = &omfs_file_inops;
+ inode->i_fop ...

To: Bob Copeland <me@...>
Cc: <linux-kernel@...>, <linux-fsdevel@...>, <akpm@...>
Date: Tuesday, April 15, 2008 - 2:30 pm

can be omfs_sb->s_magic != cpu_to_be32(OMFS_MAGIC)

this code leaks omfs_sbi_info (sbi)
--

To: Marcin Slusarz <marcin.slusarz@...>
Cc: <linux-kernel@...>, <linux-fsdevel@...>, <akpm@...>
Date: Tuesday, April 15, 2008 - 7:56 pm

Yup, I saw that too. I dropped these and added the labels per Miklos'

This one I'm not seeing. FS core calls put_super if ret is nonzero so
this should be ok?

Thanks!
--
Bob Copeland %% www.bobcopeland.com

--

To: Bob Copeland <me@...>
Cc: <linux-kernel@...>, <linux-fsdevel@...>, <akpm@...>
Date: Wednesday, April 16, 2008 - 2:31 pm

Yep, you are right. Sorry for the noise.
I was mislead by other filesystems code.

Marcin
--

To: <hch@...>
Cc: <linux-kernel@...>, <linux-fsdevel@...>, <akpm@...>, <me@...>
Date: Tuesday, April 15, 2008 - 2:03 pm

Hmm, looks like error handling needs a makeover if this is really to
become example code. See comments inline.

Somebody said this is fun? Please do a proper review of this patchset
then, thank you. ("Political" eh? Now I think *that* is really
insulting to Andrew)

This form is preferred:

ret = -EIO;
if (!bh)

Ditto. If err is the same as assigned previously it doesn't need to

Should be:

if (!bh)
goto iget_failed;
...

iget_failed:
iget_failed(inode);

This is weird. This should be done by jumping to the proper label
--

To: Miklos Szeredi <miklos@...>
Cc: <hch@...>, <linux-kernel@...>, <linux-fsdevel@...>, <akpm@...>
Date: Tuesday, April 15, 2008 - 2:33 pm

It was - if sync fails, it should still try writing the mirrors. Plus

Hrm, brelse(NULL) is allowed so the check is suspect anyway. I did
this in a couple of other places, so I'll fix those up too.

Thanks!

--
Bob Copeland %% www.bobcopeland.com
--

To: Bob Copeland <me@...>
Cc: <linux-kernel@...>, <linux-fsdevel@...>, <akpm@...>, Bob Copeland <me@...>
Date: Sunday, April 13, 2008 - 5:17 am

Several of these look like they should be checked before use elsewhere in
the code (eg blocksize is fed into shifts later)

--

To: Bob Copeland <me@...>
Cc: <linux-kernel@...>, <linux-fsdevel@...>, <akpm@...>
Date: Sunday, April 13, 2008 - 4:05 am

This if check is no needed, as your fill_super method never returns
success without setting it up.

--

Previous thread: [PATCH 6/7] omfs: add checksumming routines by Bob Copeland on Saturday, April 12, 2008 - 6:58 pm. (2 messages)

Next thread: 現在註冊就送1,000點註冊 by 潘玉龍 on Saturday, April 12, 2008 - 7:40 pm. (1 message)