Whamcloud - gitweb
LU-9183 llite: handle xattr with the xattr_handler infrastructure
[fs/lustre-release.git] / lustre / llite / namei.c
index c8bfe98..a2f2dee 100644 (file)
@@ -804,7 +804,7 @@ out_release:
 
 #else /* !HAVE_IOP_ATOMIC_OPEN */
 static struct lookup_intent *
-ll_convert_intent(struct open_intent *oit, int lookup_flags)
+ll_convert_intent(struct open_intent *oit, int lookup_flags, bool is_readonly)
 {
        struct lookup_intent *it;
 
@@ -814,10 +814,12 @@ ll_convert_intent(struct open_intent *oit, int lookup_flags)
 
        if (lookup_flags & LOOKUP_OPEN) {
                it->it_op = IT_OPEN;
-               if (lookup_flags & LOOKUP_CREATE)
+               /* Avoid file creation for ro bind mount point(is_readonly) */
+               if ((lookup_flags & LOOKUP_CREATE) && !is_readonly)
                        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);
+               it->it_flags = ll_namei_to_lookup_intent_flag(oit->flags &
+                                               ~(is_readonly ? O_CREAT : 0));
                it->it_flags &= ~MDS_OPEN_FL_INTERNAL;
        } else {
                it->it_op = IT_GETATTR;
@@ -851,7 +853,9 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
                                              MAY_WRITE | MAY_EXEC) == 0))
                                RETURN(NULL);
 
-                       it = ll_convert_intent(&nd->intent.open, nd->flags);
+                       it = ll_convert_intent(&nd->intent.open, nd->flags,
+                               (nd->path.mnt->mnt_flags & MNT_READONLY) ||
+                               (nd->path.mnt->mnt_sb->s_flags & MS_RDONLY));
                        if (IS_ERR(it))
                                RETURN((struct dentry *)it);
                }
@@ -1491,10 +1495,12 @@ const struct inode_operations ll_dir_inode_operations = {
        .setattr            = ll_setattr,
        .getattr            = ll_getattr,
        .permission         = ll_inode_permission,
+#ifdef HAVE_IOP_XATTR
        .setxattr           = ll_setxattr,
        .getxattr           = ll_getxattr,
-       .listxattr          = ll_listxattr,
        .removexattr        = ll_removexattr,
+#endif
+       .listxattr          = ll_listxattr,
 #ifdef HAVE_IOP_GET_ACL
        .get_acl            = ll_get_acl,
 #endif
@@ -1504,11 +1510,13 @@ const struct inode_operations ll_special_inode_operations = {
        .setattr        = ll_setattr,
        .getattr        = ll_getattr,
        .permission     = ll_inode_permission,
-       .setxattr       = ll_setxattr,
-       .getxattr       = ll_getxattr,
-       .listxattr      = ll_listxattr,
+#ifdef HAVE_IOP_XATTR
+       .setxattr       = ll_setxattr,
+       .getxattr       = ll_getxattr,
        .removexattr    = ll_removexattr,
+#endif
+       .listxattr      = ll_listxattr,
 #ifdef HAVE_IOP_GET_ACL
-       .get_acl            = ll_get_acl,
+       .get_acl        = ll_get_acl,
 #endif
 };