mirror of
https://github.com/psankar/simplefs.git
synced 2025-07-21 13:04:27 +02:00
Start implementing verbose logging depends on macros. (SIMPLEFS_DEBUG)
In many cases we don't need such verbose loggin, just add macros to print loggin only if SIMPLEFS_DEBUG isset. And it will be installed by default. (in Makefile)
This commit is contained in:
parent
f9aa71628d
commit
2d95ccf1a3
1
Makefile
1
Makefile
@ -1,5 +1,6 @@
|
|||||||
obj-m := simplefs.o
|
obj-m := simplefs.o
|
||||||
simplefs-objs := simple.o
|
simplefs-objs := simple.o
|
||||||
|
ccflags-y := -DSIMPLEFS_DEBUG
|
||||||
|
|
||||||
all: ko mkfs-simplefs
|
all: ko mkfs-simplefs
|
||||||
|
|
||||||
|
27
simple.c
27
simple.c
@ -66,8 +66,7 @@ void simplefs_inode_add(struct super_block *vsb, struct simplefs_inode *inode)
|
|||||||
struct simplefs_inode *inode_iterator;
|
struct simplefs_inode *inode_iterator;
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&simplefs_inodes_mgmt_lock)) {
|
if (mutex_lock_interruptible(&simplefs_inodes_mgmt_lock)) {
|
||||||
printk(KERN_ERR "Failed to acquire mutex lock %s +%d\n",
|
sfs_trace("Failed to acquire mutex lock\n");
|
||||||
__FILE__, __LINE__);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +75,7 @@ void simplefs_inode_add(struct super_block *vsb, struct simplefs_inode *inode)
|
|||||||
inode_iterator = (struct simplefs_inode *)bh->b_data;
|
inode_iterator = (struct simplefs_inode *)bh->b_data;
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&simplefs_sb_lock)) {
|
if (mutex_lock_interruptible(&simplefs_sb_lock)) {
|
||||||
printk(KERN_ERR "Failed to acquire mutex lock %s +%d\n",
|
sfs_trace("Failed to acquire mutex lock\n");
|
||||||
__FILE__, __LINE__);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +108,7 @@ int simplefs_sb_get_a_freeblock(struct super_block *vsb, uint64_t * out)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&simplefs_sb_lock)) {
|
if (mutex_lock_interruptible(&simplefs_sb_lock)) {
|
||||||
printk(KERN_ERR "Failed to acquire mutex lock %s +%d\n",
|
sfs_trace("Failed to acquire mutex lock\n");
|
||||||
__FILE__, __LINE__);
|
|
||||||
ret = -EINTR;
|
ret = -EINTR;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
@ -148,8 +145,7 @@ static int simplefs_sb_get_objects_count(struct super_block *vsb,
|
|||||||
struct simplefs_super_block *sb = SIMPLEFS_SB(vsb);
|
struct simplefs_super_block *sb = SIMPLEFS_SB(vsb);
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&simplefs_inodes_mgmt_lock)) {
|
if (mutex_lock_interruptible(&simplefs_inodes_mgmt_lock)) {
|
||||||
printk(KERN_ERR "Failed to acquire mutex lock %s +%d\n",
|
sfs_trace("Failed to acquire mutex lock\n");
|
||||||
__FILE__, __LINE__);
|
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
}
|
}
|
||||||
*out = sb->inodes_count;
|
*out = sb->inodes_count;
|
||||||
@ -368,8 +364,7 @@ ssize_t simplefs_write(struct file * filp, const char __user * buf, size_t len,
|
|||||||
* a shorter buffer */
|
* a shorter buffer */
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&simplefs_inodes_mgmt_lock)) {
|
if (mutex_lock_interruptible(&simplefs_inodes_mgmt_lock)) {
|
||||||
printk(KERN_ERR "Failed to acquire mutex lock %s +%d\n",
|
sfs_trace("Failed to acquire mutex lock\n");
|
||||||
__FILE__, __LINE__);
|
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
}
|
}
|
||||||
/* Save the modified inode */
|
/* Save the modified inode */
|
||||||
@ -378,8 +373,7 @@ ssize_t simplefs_write(struct file * filp, const char __user * buf, size_t len,
|
|||||||
sfs_inode->file_size = *ppos;
|
sfs_inode->file_size = *ppos;
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&simplefs_sb_lock)) {
|
if (mutex_lock_interruptible(&simplefs_sb_lock)) {
|
||||||
printk(KERN_ERR "Failed to acquire mutex lock %s +%d\n",
|
sfs_trace("Failed to acquire mutex lock\n");
|
||||||
__FILE__, __LINE__);
|
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,8 +446,7 @@ static int simplefs_create_fs_object(struct inode *dir, struct dentry *dentry,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&simplefs_directory_children_update_lock)) {
|
if (mutex_lock_interruptible(&simplefs_directory_children_update_lock)) {
|
||||||
printk(KERN_ERR "Failed to acquire mutex lock %s +%d\n",
|
sfs_trace("Failed to acquire mutex lock\n");
|
||||||
__FILE__, __LINE__);
|
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
}
|
}
|
||||||
sb = dir->i_sb;
|
sb = dir->i_sb;
|
||||||
@ -544,8 +537,7 @@ static int simplefs_create_fs_object(struct inode *dir, struct dentry *dentry,
|
|||||||
|
|
||||||
if (mutex_lock_interruptible(&simplefs_inodes_mgmt_lock)) {
|
if (mutex_lock_interruptible(&simplefs_inodes_mgmt_lock)) {
|
||||||
mutex_unlock(&simplefs_directory_children_update_lock);
|
mutex_unlock(&simplefs_directory_children_update_lock);
|
||||||
printk(KERN_ERR "Failed to acquire mutex lock %s +%d\n",
|
sfs_trace("Failed to acquire mutex lock\n");
|
||||||
__FILE__, __LINE__);
|
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,8 +546,7 @@ static int simplefs_create_fs_object(struct inode *dir, struct dentry *dentry,
|
|||||||
if (mutex_lock_interruptible(&simplefs_sb_lock)) {
|
if (mutex_lock_interruptible(&simplefs_sb_lock)) {
|
||||||
mutex_unlock(&simplefs_inodes_mgmt_lock);
|
mutex_unlock(&simplefs_inodes_mgmt_lock);
|
||||||
mutex_unlock(&simplefs_directory_children_update_lock);
|
mutex_unlock(&simplefs_directory_children_update_lock);
|
||||||
printk(KERN_ERR "Failed to acquire mutex lock %s +%d\n",
|
sfs_trace("Failed to acquire mutex lock\n");
|
||||||
__FILE__, __LINE__);
|
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
simple.h
15
simple.h
@ -1,8 +1,23 @@
|
|||||||
|
|
||||||
|
|
||||||
#define SIMPLEFS_MAGIC 0x10032013
|
#define SIMPLEFS_MAGIC 0x10032013
|
||||||
#define SIMPLEFS_DEFAULT_BLOCK_SIZE 4096
|
#define SIMPLEFS_DEFAULT_BLOCK_SIZE 4096
|
||||||
#define SIMPLEFS_FILENAME_MAXLEN 255
|
#define SIMPLEFS_FILENAME_MAXLEN 255
|
||||||
#define SIMPLEFS_START_INO 10
|
#define SIMPLEFS_START_INO 10
|
||||||
|
|
||||||
|
#ifdef SIMPLEFS_DEBUG
|
||||||
|
#define sfs_trace(fmt, ...) { \
|
||||||
|
printk(KERN_ERR "[simplefs] %s +%d:" fmt, \
|
||||||
|
__FILE__, __LINE__, ##__VA_ARGS__); \
|
||||||
|
}
|
||||||
|
#define sfs_debug(level, fmt, ...) { \
|
||||||
|
printk(level "[simplefs]:" fmt, ##__VA_ARGS__); \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define sfs_trace(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
|
||||||
|
#define sfs_debug(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Hard-coded inode number for the root directory */
|
/* Hard-coded inode number for the root directory */
|
||||||
const int SIMPLEFS_ROOTDIR_INODE_NUMBER = 1;
|
const int SIMPLEFS_ROOTDIR_INODE_NUMBER = 1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user