Whamcloud - gitweb
LU-2019 llite: update i_flags in ll_iocontrol properly
[fs/lustre-release.git] / lustre / llite / llite_lib.c
index 7305317..2cb5910 100644 (file)
@@ -63,10 +63,8 @@ DEFINE_SPINLOCK(ll_sb_lock);
 
 #ifndef MS_HAS_NEW_AOPS
 extern struct address_space_operations ll_aops;
-extern struct address_space_operations ll_dir_aops;
 #else
 extern struct address_space_operations_ext ll_aops;
-extern struct address_space_operations_ext ll_dir_aops;
 #endif
 
 #ifndef log2
@@ -75,8 +73,9 @@ extern struct address_space_operations_ext ll_dir_aops;
 
 static struct ll_sb_info *ll_init_sbi(void)
 {
-        struct ll_sb_info *sbi = NULL;
-        unsigned long pages;
+       struct ll_sb_info *sbi = NULL;
+       unsigned long pages;
+       unsigned long lru_page_max;
         struct sysinfo si;
         class_uuid_t uuid;
         int i;
@@ -96,13 +95,20 @@ static struct ll_sb_info *ll_init_sbi(void)
         pages = si.totalram - si.totalhigh;
         if (pages >> (20 - CFS_PAGE_SHIFT) < 512) {
 #ifdef HAVE_BGL_SUPPORT
-                sbi->ll_async_page_max = pages / 4;
+               lru_page_max = pages / 4;
 #else
-                sbi->ll_async_page_max = pages / 2;
+               lru_page_max = pages / 2;
 #endif
-        } else {
-                sbi->ll_async_page_max = (pages / 4) * 3;
-        }
+       } else {
+               lru_page_max = (pages / 4) * 3;
+       }
+
+       /* initialize lru data */
+       cfs_atomic_set(&sbi->ll_lru.ccl_users, 0);
+       sbi->ll_lru.ccl_page_max = lru_page_max;
+       cfs_atomic_set(&sbi->ll_lru.ccl_page_left, lru_page_max);
+       cfs_spin_lock_init(&sbi->ll_lru.ccl_lock);
+       CFS_INIT_LIST_HEAD(&sbi->ll_lru.ccl_list);
 
         sbi->ll_ra_info.ra_max_pages_per_file = min(pages / 32,
                                            SBI_DEFAULT_READAHEAD_MAX);
@@ -469,7 +475,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
         CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid));
 
         sb->s_op = &lustre_super_operations;
-#if THREAD_SIZE >= 8192 /*b=17630*/ && !defined(HAVE_FSTYPE_MOUNT) /*LU-812*/
+#if THREAD_SIZE >= 8192 /*b=17630*/
         sb->s_export_op = &lustre_export_operations;
 #endif
 
@@ -545,7 +551,11 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                                  NULL);
         cl_sb_init(sb);
 
-        sb->s_root = d_alloc_root(root);
+       err = obd_set_info_async(NULL, sbi->ll_dt_exp, sizeof(KEY_LRU_SET),
+                                KEY_LRU_SET, sizeof(sbi->ll_lru),
+                                &sbi->ll_lru, NULL);
+
+       sb->s_root = d_alloc_root(root);
 #ifdef HAVE_DCACHE_LOCK
        sb->s_root->d_op = &ll_d_root_ops;
 #else
@@ -564,7 +574,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
         uuid = obd_get_uuid(sbi->ll_md_exp);
         if (uuid != NULL)
                 sb->s_dev = get_uuid2int(uuid->uuid, strlen(uuid->uuid));
-        sbi->ll_mnt = mnt;
 
         if (data != NULL)
                 OBD_FREE_PTR(data);
@@ -912,7 +921,6 @@ void ll_lli_init(struct ll_inode_info *lli)
                 cfs_mutex_init(&lli->lli_readdir_mutex);
                 lli->lli_opendir_key = NULL;
                 lli->lli_sai = NULL;
-                lli->lli_sa_pos = 0;
                 lli->lli_def_acl = NULL;
                 cfs_spin_lock_init(&lli->lli_sa_lock);
                 lli->lli_opendir_pid = 0;
@@ -997,7 +1005,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
            Use the address of the super itself.*/
         cfg->cfg_instance = sb;
         cfg->cfg_uuid = lsi->lsi_llsbi->ll_sb_uuid;
-
+       cfg->cfg_callback = class_config_llog_handler;
         /* set up client obds */
         err = lustre_process_log(sb, profilenm, cfg);
         if (err < 0) {
@@ -1845,7 +1853,6 @@ void ll_read_inode2(struct inode *inode, void *opaque)
         } else if (S_ISDIR(inode->i_mode)) {
                 inode->i_op = &ll_dir_inode_operations;
                 inode->i_fop = &ll_dir_operations;
-                inode->i_mapping->a_ops = (struct address_space_operations *)&ll_dir_aops;
                 EXIT;
         } else if (S_ISLNK(inode->i_mode)) {
                 inode->i_op = &ll_fast_symlink_inode_operations;
@@ -1853,8 +1860,8 @@ void ll_read_inode2(struct inode *inode, void *opaque)
         } else {
                 inode->i_op = &ll_special_inode_operations;
 
-                init_special_inode(inode, inode->i_mode,
-                                   kdev_t_to_nr(inode->i_rdev));
+               init_special_inode(inode, inode->i_mode,
+                                  inode->i_rdev);
 
                 EXIT;
         }
@@ -1957,17 +1964,17 @@ int ll_iocontrol(struct inode *inode, struct file *file,
                if (rc)
                        RETURN(rc);
 
-               OBDO_ALLOC(oinfo.oi_oa);
-               if (!oinfo.oi_oa)
-                       RETURN(-ENOMEM);
+               inode->i_flags = ll_ext_to_inode_flags(flags);
 
                lsm = ccc_inode_lsm_get(inode);
-               if (lsm == NULL) {
-                       inode->i_flags = ll_ext_to_inode_flags(flags);
-                       OBDO_FREE(oinfo.oi_oa);
+               if (lsm == NULL)
                        RETURN(0);
-               }
 
+               OBDO_ALLOC(oinfo.oi_oa);
+               if (!oinfo.oi_oa) {
+                       ccc_inode_lsm_put(inode, lsm);
+                       RETURN(-ENOMEM);
+               }
                oinfo.oi_md = lsm;
                 oinfo.oi_oa->o_id = lsm->lsm_object_id;
                 oinfo.oi_oa->o_seq = lsm->lsm_object_seq;
@@ -2162,12 +2169,9 @@ int ll_prep_inode(struct inode **inode,
        ibits = MDS_INODELOCK_LAYOUT;
        if (S_ISREG(md.body->mode) && sbi->ll_flags & LL_SBI_LAYOUT_LOCK &&
            md.lsm != NULL && !ll_have_md_lock(*inode, &ibits, LCK_MINMODE)) {
-               char *fsname = ll_get_fsname(*inode);
                CERROR("%s: inode "DFID" (%p) layout lock not granted.\n",
-                       fsname, PFID(ll_inode2fid(*inode)),
-                       *inode);
-               if (fsname)
-                       OBD_FREE(fsname, MGS_PARAM_MAXLEN);
+                       ll_get_fsname(sb, NULL, 0),
+                       PFID(ll_inode2fid(*inode)), *inode);
        }
 
 out:
@@ -2182,6 +2186,7 @@ int ll_obd_statfs(struct inode *inode, void *arg)
         char *buf = NULL;
         struct obd_ioctl_data *data = NULL;
         __u32 type;
+       __u32 flags;
         int len = 0, rc;
 
         if (!inode || !(sbi = ll_i2sbi(inode)))
@@ -2203,14 +2208,15 @@ int ll_obd_statfs(struct inode *inode, void *arg)
                 GOTO(out_statfs, rc = -EINVAL);
 
         memcpy(&type, data->ioc_inlbuf1, sizeof(__u32));
-        if (type == LL_STATFS_LMV)
+       if (type & LL_STATFS_LMV)
                 exp = sbi->ll_md_exp;
-        else if (type == LL_STATFS_LOV)
+       else if (type & LL_STATFS_LOV)
                 exp = sbi->ll_dt_exp;
         else
                 GOTO(out_statfs, rc = -ENODEV);
 
-        rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL);
+       flags = (type & LL_STATFS_NODELAY) ? OBD_STATFS_NODELAY : 0;
+       rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, &flags);
         if (rc)
                 GOTO(out_statfs, rc);
 out_statfs:
@@ -2366,3 +2372,36 @@ int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg)
 
         RETURN(0);
 }
+
+/**
+ * Get lustre file system name by \a sbi. If \a buf is provided(non-NULL), the
+ * fsname will be returned in this buffer; otherwise, a static buffer will be
+ * used to store the fsname and returned to caller.
+ */
+char *ll_get_fsname(struct super_block *sb, char *buf, int buflen)
+{
+       static char fsname_static[MTI_NAME_MAXLEN];
+       struct lustre_sb_info *lsi = s2lsi(sb);
+       char *ptr;
+       int len;
+
+       if (buf == NULL) {
+               /* this means the caller wants to use static buffer
+                * and it doesn't care about race. Usually this is
+                * in error reporting path */
+               buf = fsname_static;
+               buflen = sizeof(fsname_static);
+       }
+
+       len = strlen(lsi->lsi_lmd->lmd_profile);
+       ptr = strrchr(lsi->lsi_lmd->lmd_profile, '-');
+       if (ptr && (strcmp(ptr, "-client") == 0))
+               len -= 7;
+
+       if (unlikely(len >= buflen))
+               len = buflen - 1;
+       strncpy(buf, lsi->lsi_lmd->lmd_profile, len);
+       buf[len] = '\0';
+
+       return buf;
+}