Subject: Re: linux-next: Tree for April 1 [BROKEN ubifs when CONFIG_DEBUG_SECTION_MISMATCH=y]s

From: Sedat Dilek <[email-masked]>
Date: Mon, 4 Apr 2011 01:07:10 +0200

On Mon, Apr 4, 2011 at 12:36 AM, Jens Axboe <[email-masked]> wrote:
> On 2011-04-04 00:33, Sedat Dilek wrote:
>> On Mon, Apr 4, 2011 at 12:21 AM, Jens Axboe <[email-masked]> wrote:
>>> On 2011-04-04 00:19, Sedat Dilek wrote:
>>>> On Mon, Apr 4, 2011 at 12:16 AM, Jens Axboe <[email-masked]> wrote:
>>>>> On 2011-04-02 13:02, Sedat Dilek wrote:
>>>>>> On Sat, Apr 2, 2011 at 12:14 PM, Sedat Dilek <[email-masked]> wrote:
>>>>>>> On Sat, Apr 2, 2011 at 2:20 AM, Stephen Rothwell <[email-masked]> wrote:
>>>>>>>> cc'ing Jens ...
>>>>>>>>
>>>>>>>> On Fri, 1 Apr 2011 20:22:41 +0200 Sedat Dilek <[email-masked]> wrote:
>>>>>>>>>
>>>>>>>>> On Fri, Apr 1, 2011 at 7:02 PM, Artem Bityutskiy <[email-masked]> wrote:
>>>>>>>>>> On Fri, 2011-04-01 at 18:10 +0200, Sedat Dilek wrote:
>>>>>>>>>>> On Fri, Apr 1, 2011 at 6:06 PM, Stephen Rothwell <[email-masked]> wrote:
>>>>>>>>>>>> Cc'ing Artem,
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, 1 Apr 2011 17:55:52 +0200 Sedat Dilek <[email-masked]> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> With CONFIG_DEBUG_SECTION_MISMATCH=y set, I see in my build.log:
>>>>>>>>>>>>> ...
>>>>>>>>>>>>> MODPOST 2742 modules
>>>>>>>>>>>>> ...
>>>>>>>>>>>>> ERROR: "empty_aops" [fs/ubifs/ubifs.ko] undefined!
>>>>>>>>>>>>> make[5]: *** [__modpost] Error 1
>>>>>>>>>>>>> make[4]: *** [modules] Error 2
>>>>>>>>>>>>> make[3]: *** [sub-make] Error 2
>>>>>>>>>>>>> make[2]: *** [all] Error 2
>>>>>>>>>>>>> make[2]: Leaving directory
>>>>>>>>>>>>> `/home/sd/src/linux-2.6/linux-2.6.39-rc1/debian/build/build_i386_none_686-iniza'
>>>>>>>>>>>>>
>>>>>> [...]
>>>>>>> Just FYI:
>>>>>>> I contacted Jens last night and he refreshed his for-linus GIT branch.
>>>>>>> Adding missing include <linux/fs.h> did not fix the issue.
>>>>>>> I am trying with the attached one.
>>>>>>>
>>>>>>> - Sedat -
>>>>>>>
>>>>>>
>>>>>> I have split the single patch into two, first reflects ther build-error.
>>>>>> The second considers {inode,file}_operations have also undefined
>>>>>> functions by using "unified" empty_{iops,fops} as used in other fs/*
>>>>>> files.
>>>>>
>>>>> What are these patches against? Not for-next nor my for-linus.
>>>>>
>>>>
>>>> I tested with linux-next (next-20110401) as base and pulled-in your
>>>> for-linus GIT branch.
>>>
>>> Then perhaps there was some merge error. There's no empty_aops defined
>>> in my tree in nilfs_mapping_init(), for instance.
>>>
>>> Are you using an old for-linus?
>>>
>>
>> I dropped the idea of exporting empty_aops via include/linux/fs.h (&
>> changes in fs/inode.c) as it did not work as intended.
>> As an alternative I used empty_{aops,iops,fops} only in
>> fs/nilfs2/page.c and fs/ubifs/xattr.c where it is only needed (for
>> example for aops: static const struct address_space_operations
>> empty_aops {}; etc.)
>
> I'm asking one thing, you are replying with something else. The patches
> you sent do NOT apply to for-linus.
>

Oh, I forgot the revert patch.
Here all 3 patches.

- Sedat -
From afdbad282827cd5efe4832189c87985383e1a0b7 Mon Sep 17 00:00:00 2001
From: Sedat Dilek <[email-masked]>
Date: Mon, 4 Apr 2011 01:02:55 +0200
Subject: [PATCH 1/3] Revert "fs: export empty_aops"

This reverts commit 52dc75abbfc8c352875d8e9a9006b325c136bd58.

Signed-off-by: Sedat Dilek <[email-masked]>
---
 fs/inode.c         |    8 +-------
 fs/nilfs2/page.c   |    2 ++
 fs/ubifs/xattr.c   |    4 ++--
 include/linux/fs.h |    2 --
 4 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/fs/inode.c b/fs/inode.c
index b818730..5f4e11a 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -125,13 +125,6 @@ __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_wb_list_lock);
 static DECLARE_RWSEM(iprune_sem);
 
 /*
- * Empty aops. Can be used for the cases where the user does not
- * define any of the address_space operations.
- */
-const struct address_space_operations empty_aops = {
-};
-
-/*
  * Statistics gathering..
  */
 struct inodes_stat_t inodes_stat;
@@ -183,6 +176,7 @@ int proc_nr_inodes(ctl_table *table, int write,
  */
 int inode_init_always(struct super_block *sb, struct inode *inode)
 {
+	static const struct address_space_operations empty_aops;
 	static const struct inode_operations empty_iops;
 	static const struct file_operations empty_fops;
 	struct address_space *const mapping = &inode->i_data;
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 1168059..9d2dc6b 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -495,6 +495,8 @@ unsigned nilfs_page_count_clean_buffers(struct page *page,
 void nilfs_mapping_init(struct address_space *mapping,
 			struct backing_dev_info *bdi)
 {
+	static const struct address_space_operations empty_aops;
+
 	mapping->host = NULL;
 	mapping->flags = 0;
 	mapping_set_gfp_mask(mapping, GFP_NOFS);
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 3299f46..c74400f 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -56,7 +56,6 @@
  */
 
 #include "ubifs.h"
-#include <linux/fs.h>
 #include <linux/slab.h>
 #include <linux/xattr.h>
 #include <linux/posix_acl_xattr.h>
@@ -81,6 +80,7 @@ enum {
 };
 
 static const struct inode_operations none_inode_operations;
+static const struct address_space_operations none_address_operations;
 static const struct file_operations none_file_operations;
 
 /**
@@ -130,7 +130,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
 	}
 
 	/* Re-define all operations to be "nothing" */
-	inode->i_mapping->a_ops = &empty_aops;
+	inode->i_mapping->a_ops = &none_address_operations;
 	inode->i_op = &none_inode_operations;
 	inode->i_fop = &none_file_operations;
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 1b95af3..52f283c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -613,8 +613,6 @@ struct address_space_operations {
 	int (*error_remove_page)(struct address_space *, struct page *);
 };
 
-extern const struct address_space_operations empty_aops;
-
 /*
  * pagecache_write_begin/pagecache_write_end must be used by general code
  * to write into the pagecache.
-- 
1.7.4.3

From 43587cc5bdd66bd3cea9c55baae1fdcbd3f9f758 Mon Sep 17 00:00:00 2001
From: Sedat Dilek <[email-masked]>
Date: Sat, 2 Apr 2011 12:28:37 +0200
Subject: [PATCH 2/3] nilfs2,ubifs: Fix error empty_aops undefined

With the ->sync_page() hook gone, we have a few users that
add their own static address_space_operations without any
functions defined.

This patch fixes the following issues:
ERROR: "empty_aops" [fs/ubifs/ubifs.ko] undefined!
ERROR: "empty_aops" [fs/nilfs2/nilfs2.ko] undefined!

Note: "fs: export empty_aops" patch needs to be reverted first!

Signed-off-by: Sedat Dilek <[email-masked]>
---
 fs/nilfs2/page.c |    2 +-
 fs/ubifs/xattr.c |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 9d2dc6b..e7df3f9 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -495,7 +495,7 @@ unsigned nilfs_page_count_clean_buffers(struct page *page,
 void nilfs_mapping_init(struct address_space *mapping,
 			struct backing_dev_info *bdi)
 {
-	static const struct address_space_operations empty_aops;
+	static const struct address_space_operations empty_aops = {};
 
 	mapping->host = NULL;
 	mapping->flags = 0;
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index c74400f..29d5681 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -80,7 +80,6 @@ enum {
 };
 
 static const struct inode_operations none_inode_operations;
-static const struct address_space_operations none_address_operations;
 static const struct file_operations none_file_operations;
 
 /**
@@ -100,6 +99,7 @@ static const struct file_operations none_file_operations;
 static int create_xattr(struct ubifs_info *c, struct inode *host,
 			const struct qstr *nm, const void *value, int size)
 {
+	static const struct address_space_operations empty_aops = {};
 	int err;
 	struct inode *inode;
 	struct ubifs_inode *ui, *host_ui = ubifs_inode(host);
@@ -130,7 +130,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
 	}
 
 	/* Re-define all operations to be "nothing" */
-	inode->i_mapping->a_ops = &none_address_operations;
+	inode->i_mapping->a_ops = &empty_aops;
 	inode->i_op = &none_inode_operations;
 	inode->i_fop = &none_file_operations;
 
-- 
1.7.4.3

From 4cc523d660d5c9476ad5e6af9ff155551e72a2dc Mon Sep 17 00:00:00 2001
From: Sedat Dilek <[email-masked]>
Date: Sat, 2 Apr 2011 12:33:44 +0200
Subject: [PATCH 3/3] ubifs: Move {inode,file}_operations to create_xattr() and use empty_{iops,fops}

Consider inode_operations and file_operations have also no
functions defined and move them to create_xattr().
Transform to empty_{iops,fops} (see fs/inode.c and fs/open.c).

Signed-off-by: Sedat Dilek <[email-masked]>
---
 fs/ubifs/xattr.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 29d5681..d237c4f 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -79,9 +79,6 @@ enum {
 	SECURITY_XATTR,
 };
 
-static const struct inode_operations none_inode_operations;
-static const struct file_operations none_file_operations;
-
 /**
  * create_xattr - create an extended attribute.
  * @c: UBIFS file-system description object
@@ -100,6 +97,8 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
 			const struct qstr *nm, const void *value, int size)
 {
 	static const struct address_space_operations empty_aops = {};
+	static const struct inode_operations empty_iops = {};
+	static const struct file_operations empty_fops = {};
 	int err;
 	struct inode *inode;
 	struct ubifs_inode *ui, *host_ui = ubifs_inode(host);
@@ -131,8 +130,8 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
 
 	/* Re-define all operations to be "nothing" */
 	inode->i_mapping->a_ops = &empty_aops;
-	inode->i_op = &none_inode_operations;
-	inode->i_fop = &none_file_operations;
+	inode->i_op = &empty_iops;
+	inode->i_fop = &empty_fops;
 
 	inode->i_flags |= S_SYNC | S_NOATIME | S_NOCMTIME | S_NOQUOTA;
 	ui = ubifs_inode(inode);
-- 
1.7.4.3