Whamcloud - gitweb
LU-1757 brw: add short io osc/ost transfer.
[fs/lustre-release.git] / lustre / llite / llite_lib.c
index ba305aa..6071d49 100644 (file)
 #endif
 #include <linux/security.h>
 
-#include <uapi/linux/lustre_ioctl.h>
+#include <uapi/linux/lustre/lustre_ioctl.h>
 #include <lustre_ha.h>
 #include <lustre_dlm.h>
 #include <lprocfs_status.h>
 #include <lustre_disk.h>
-#include <uapi/linux/lustre_param.h>
+#include <uapi/linux/lustre/lustre_param.h>
 #include <lustre_log.h>
 #include <cl_object.h>
 #include <obd_cksum.h>
@@ -99,8 +99,7 @@ static struct ll_sb_info *ll_init_sbi(void)
        sbi->ll_ra_info.ra_max_pages_per_file = min(pages / 32,
                                           SBI_DEFAULT_READAHEAD_MAX);
        sbi->ll_ra_info.ra_max_pages = sbi->ll_ra_info.ra_max_pages_per_file;
-       sbi->ll_ra_info.ra_max_read_ahead_whole_pages =
-                                          SBI_DEFAULT_READAHEAD_WHOLE_MAX;
+       sbi->ll_ra_info.ra_max_read_ahead_whole_pages = -1;
 
         ll_generate_random_uuid(uuid);
         class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
@@ -196,7 +195,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 RETURN(-ENOMEM);
         }
 
-        /* indicate the features supported by this client */
+       /* indicate MDT features supported by this client */
         data->ocd_connect_flags = OBD_CONNECT_IBITS    | OBD_CONNECT_NODEVOH  |
                                   OBD_CONNECT_ATTRFID  |
                                   OBD_CONNECT_VERSION  | OBD_CONNECT_BRW_SIZE |
@@ -259,7 +258,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
        if (sbi->ll_flags & LL_SBI_ALWAYS_PING)
                data->ocd_connect_flags &= ~OBD_CONNECT_PINGLESS;
 
-#ifdef HAVE_SECURITY_DENTRY_INIT_SECURITY
+#if defined(HAVE_SECURITY_DENTRY_INIT_SECURITY) && defined(CONFIG_SECURITY)
        data->ocd_connect_flags2 |= OBD_CONNECT2_FILE_SECCTX;
 #endif /* HAVE_SECURITY_DENTRY_INIT_SECURITY */
 
@@ -388,6 +387,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
         * back its backend blocksize for grant calculation purpose */
        data->ocd_grant_blkbits = PAGE_SHIFT;
 
+       /* indicate OST features supported by this client */
        data->ocd_connect_flags = OBD_CONNECT_GRANT | OBD_CONNECT_VERSION |
                                  OBD_CONNECT_REQPORTAL | OBD_CONNECT_BRW_SIZE |
                                  OBD_CONNECT_CANCELSET | OBD_CONNECT_FID |
@@ -399,9 +399,26 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                                  OBD_CONNECT_JOBSTATS | OBD_CONNECT_LVB_TYPE |
                                  OBD_CONNECT_LAYOUTLOCK |
                                  OBD_CONNECT_PINGLESS | OBD_CONNECT_LFSCK |
-                                 OBD_CONNECT_BULK_MBITS;
+                                 OBD_CONNECT_BULK_MBITS | OBD_CONNECT_SHORTIO |
+                                 OBD_CONNECT_FLAGS2;
+
+/* The client currently advertises support for OBD_CONNECT_LOCKAHEAD_OLD so it
+ * can interoperate with an older version of lockahead which was released prior
+ * to landing in master. This support will be dropped when 2.13 development
+ * starts.  At the point, we should not just drop the connect flag (below), we
+ * should also remove the support in the code.
+ *
+ * Removing it means a few things:
+ * 1. Remove this section here
+ * 2. Remove CEF_NONBLOCK in ll_file_lockahead()
+ * 3. Remove function exp_connect_lockahead_old
+ * 4. Remove LDLM_FL_LOCKAHEAD_OLD_RESERVED in lustre_dlm_flags.h
+ * */
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 12, 50, 0)
+       data->ocd_connect_flags |= OBD_CONNECT_LOCKAHEAD_OLD;
+#endif
 
-       data->ocd_connect_flags2 = 0;
+       data->ocd_connect_flags2 = OBD_CONNECT2_LOCKAHEAD;
 
        if (!OBD_FAIL_CHECK(OBD_FAIL_OSC_CONNECT_GRANT_PARAM))
                data->ocd_connect_flags |= OBD_CONNECT_GRANT_PARAM;
@@ -449,6 +466,12 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
 
        sbi->ll_dt_exp->exp_connect_data = *data;
 
+       /* Don't change value if it was specified in the config log */
+       if (sbi->ll_ra_info.ra_max_read_ahead_whole_pages == -1)
+               sbi->ll_ra_info.ra_max_read_ahead_whole_pages =
+                       max_t(unsigned long, SBI_DEFAULT_READAHEAD_WHOLE_MAX,
+                             (data->ocd_brw_size >> PAGE_SHIFT));
+
        err = obd_fid_init(sbi->ll_dt_exp->exp_obd, sbi->ll_dt_exp,
                           LUSTRE_SEQ_METADATA);
        if (err) {
@@ -925,14 +948,41 @@ void ll_lli_init(struct ll_inode_info *lli)
        memset(lli->lli_jobid, 0, LUSTRE_JOBID_SIZE);
 }
 
-static inline int ll_bdi_register(struct backing_dev_info *bdi)
+#ifndef HAVE_SUPER_SETUP_BDI_NAME
+
+#define LSI_BDI_INITIALIZED    0x00400000
+
+#ifndef HAVE_BDI_CAP_MAP_COPY
+# define BDI_CAP_MAP_COPY      0
+#endif
+
+#define MAX_STRING_SIZE 128
+
+static int super_setup_bdi_name(struct super_block *sb, char *fmt, ...)
 {
-       static atomic_t ll_bdi_num = ATOMIC_INIT(0);
+       struct  lustre_sb_info *lsi = s2lsi(sb);
+       char buf[MAX_STRING_SIZE];
+       va_list args;
+       int err;
+
+       err = bdi_init(&lsi->lsi_bdi);
+       if (err)
+               return err;
 
-       bdi->name = "lustre";
-       return bdi_register(bdi, NULL, "lustre-%d",
-                           atomic_inc_return(&ll_bdi_num));
+       lsi->lsi_flags |= LSI_BDI_INITIALIZED;
+       lsi->lsi_bdi.capabilities = BDI_CAP_MAP_COPY;
+       lsi->lsi_bdi.name = "lustre";
+       va_start(args, fmt);
+       vsnprintf(buf, MAX_STRING_SIZE, fmt, args);
+       va_end(args);
+       err = bdi_register(&lsi->lsi_bdi, NULL, "%s", buf);
+       va_end(args);
+       if (!err)
+               sb->s_bdi = &lsi->lsi_bdi;
+
+       return err;
 }
+#endif /* !HAVE_SUPER_SETUP_BDI_NAME */
 
 int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
 {
@@ -969,20 +1019,10 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
        if (err)
                GOTO(out_free, err);
 
-       err = bdi_init(&lsi->lsi_bdi);
-       if (err)
-               GOTO(out_free, err);
-       lsi->lsi_flags |= LSI_BDI_INITIALIZED;
-#ifdef HAVE_BDI_CAP_MAP_COPY
-       lsi->lsi_bdi.capabilities = BDI_CAP_MAP_COPY;
-#else
-       lsi->lsi_bdi.capabilities = 0;
-#endif
-       err = ll_bdi_register(&lsi->lsi_bdi);
+       err = super_setup_bdi_name(sb, "lustre-%p", sb);
        if (err)
                GOTO(out_free, err);
 
-       sb->s_bdi = &lsi->lsi_bdi;
 #ifndef HAVE_DCACHE_LOCK
        /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */
        sb->s_d_op = &ll_d_ops;
@@ -1124,10 +1164,12 @@ void ll_put_super(struct super_block *sb)
         if (profilenm)
                 class_del_profile(profilenm);
 
+#ifndef HAVE_SUPER_SETUP_BDI_NAME
        if (lsi->lsi_flags & LSI_BDI_INITIALIZED) {
                bdi_destroy(&lsi->lsi_bdi);
                lsi->lsi_flags &= ~LSI_BDI_INITIALIZED;
        }
+#endif
 
         ll_free_sbi(sb);
         lsi->lsi_llsbi = NULL;
@@ -1571,17 +1613,17 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
         /* We mark all of the fields "set" so MDS/OST does not re-set them */
        if (!(attr->ia_valid & ATTR_CTIME_SET) &&
            (attr->ia_valid & ATTR_CTIME)) {
-               attr->ia_ctime = CURRENT_TIME;
+               attr->ia_ctime = current_time(inode);
                 attr->ia_valid |= ATTR_CTIME_SET;
         }
        if (!(attr->ia_valid & ATTR_ATIME_SET) &&
            (attr->ia_valid & ATTR_ATIME)) {
-               attr->ia_atime = CURRENT_TIME;
+               attr->ia_atime = current_time(inode);
                 attr->ia_valid |= ATTR_ATIME_SET;
         }
        if (!(attr->ia_valid & ATTR_MTIME_SET) &&
            (attr->ia_valid & ATTR_MTIME)) {
-               attr->ia_mtime = CURRENT_TIME;
+               attr->ia_mtime = current_time(inode);
                 attr->ia_valid |= ATTR_MTIME_SET;
         }