Whamcloud - gitweb
LU-1337 llite: kernel 3.1 changes open_to_namei_flags
authorLiu Xuezhao <xuezhao.liu@emc.com>
Tue, 30 Oct 2012 08:45:48 +0000 (16:45 +0800)
committerOleg Drokin <green@whamcloud.com>
Sat, 3 Nov 2012 20:00:38 +0000 (16:00 -0400)
Kernel 3.1 changes the translation from open_flag to namei_flag,
(kernel commit 8a5e929dd2e05ab4d3d89f58c5e8fca596af8f3a).

So after 3.1, kernel's nameidata.intent.open.flags is different
with lustre's lookup_intent.it_flags, as lustre's it_flags'
lower bits equal to FMODE_xxx while kernel doesn't transliterate
lower bits of nameidata.intent.open.flags to FMODE_xxx.

This patch keeps lustre it_flags' semantics and add
ll_namei_to_lookup_intent_flag for translation.

Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
Change-Id: I408685040688bae574d04cf288abb6ca967607df
Reviewed-on: http://review.whamcloud.com/3583
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/linux/lustre_compat25.h
lustre/llite/namei.c

index 9362d9f..6670041 100644 (file)
@@ -691,4 +691,19 @@ static inline bool selinux_is_enabled(void)
 # define lm_compare_owner      fl_compare_owner
 #endif
 
+/*
+ * After 3.1, kernel's nameidata.intent.open.flags is different
+ * with lustre's lookup_intent.it_flags, as lustre's it_flags'
+ * lower bits equal to FMODE_xxx while kernel doesn't transliterate
+ * lower bits of nameidata.intent.open.flags to FMODE_xxx.
+ * */
+#include <linux/version.h>
+static inline int ll_namei_to_lookup_intent_flag(int flag)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
+       flag = (flag & ~O_ACCMODE) | OPEN_FMODE(flag);
+#endif
+       return flag;
+}
+
 #endif /* _COMPAT25_H */
index 0d28211..008ede5 100644 (file)
@@ -552,23 +552,23 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
 struct lookup_intent *ll_convert_intent(struct open_intent *oit,
                                         int lookup_flags)
 {
-        struct lookup_intent *it;
-
-        OBD_ALLOC(it, sizeof(*it));
-        if (!it)
-                return ERR_PTR(-ENOMEM);
-
-        if (lookup_flags & LOOKUP_OPEN) {
-                it->it_op = IT_OPEN;
-                if (lookup_flags & LOOKUP_CREATE)
-                        it->it_op |= IT_CREAT;
-                it->it_create_mode = (oit->create_mode & S_IALLUGO) | S_IFREG;
-                it->it_flags = oit->flags;
-        } else {
-                it->it_op = IT_GETATTR;
-        }
+       struct lookup_intent *it;
+
+       OBD_ALLOC(it, sizeof(*it));
+       if (!it)
+               return ERR_PTR(-ENOMEM);
+
+       if (lookup_flags & LOOKUP_OPEN) {
+               it->it_op = IT_OPEN;
+               if (lookup_flags & LOOKUP_CREATE)
+                       it->it_op |= IT_CREAT;
+               it->it_create_mode = (oit->create_mode & S_IALLUGO) | S_IFREG;
+               it->it_flags = ll_namei_to_lookup_intent_flag(oit->flags);
+       } else {
+               it->it_op = IT_GETATTR;
+       }
 
-        return it;
+       return it;
 }
 
 static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,