Whamcloud - gitweb
LU-5342 lmv: fix some byte order issues
[fs/lustre-release.git] / lustre / llite / dir.c
index bfc75ea..0233cce 100644 (file)
  * After client receives reply, several pages will be integrated into dir page
  * in PAGE_CACHE_SIZE (if PAGE_CACHE_SIZE greater than LU_PAGE_SIZE), and the
  * lu_dirpage for this integrated page will be adjusted. See
- * lmv_adjust_dirpages().
+ * mdc_adjust_dirpages().
  *
  */
 struct page *ll_get_dir_page(struct inode *dir, struct md_op_data *op_data,
@@ -246,8 +246,14 @@ int ll_dir_read(struct inode *inode, __u64 *ppos, struct md_op_data *op_data,
                         * to access the 'ent' through its 'lde_name',
                         * so the parameter 'name' for 'filldir()' must
                         * be part of the 'ent'. */
+#ifdef HAVE_DIR_CONTEXT
+                       ctx->pos = lhash;
+                       done = !dir_emit(ctx, ent->lde_name, namelen, ino,
+                                        type);
+#else
                        done = filldir(cookie, ent->lde_name, namelen, lhash,
                                       ino, type);
+#endif
                }
 
                if (done) {
@@ -277,8 +283,11 @@ int ll_dir_read(struct inode *inode, __u64 *ppos, struct md_op_data *op_data,
                                               &chain);
                }
        }
-
+#ifdef HAVE_DIR_CONTEXT
+       ctx->pos = pos;
+#else
        *ppos = pos;
+#endif
        ll_dir_chain_fini(&chain);
        RETURN(rc);
 }
@@ -386,7 +395,7 @@ static int ll_send_mgc_param(struct obd_export *mgc, char *string)
         if (!msp)
                 return -ENOMEM;
 
-        strncpy(msp->mgs_param, string, MGS_PARAM_MAXLEN);
+       strlcpy(msp->mgs_param, string, sizeof(msp->mgs_param));
         rc = obd_set_info_async(NULL, mgc, sizeof(KEY_SET_INFO), KEY_SET_INFO,
                                 sizeof(struct mgs_send_param), msp, NULL);
         if (rc)
@@ -1252,15 +1261,15 @@ lmv_out_free:
                tmp->lum_stripe_count = 0;
                tmp->lum_stripe_offset = mdt_index;
                for (i = 0; i < stripe_count; i++) {
-                       struct lu_fid   *fid;
+                       struct lu_fid   fid;
 
-                       fid = &lmm->lmv_md_v1.lmv_stripe_fids[i];
-                       mdt_index = ll_get_mdt_idx_by_fid(sbi, fid);
+                       fid_le_to_cpu(&fid, &lmm->lmv_md_v1.lmv_stripe_fids[i]);
+                       mdt_index = ll_get_mdt_idx_by_fid(sbi, &fid);
                        if (mdt_index < 0)
                                GOTO(out_tmp, rc = mdt_index);
 
                        tmp->lum_objects[i].lum_mds = mdt_index;
-                       tmp->lum_objects[i].lum_fid = *fid;
+                       tmp->lum_objects[i].lum_fid = fid;
                        tmp->lum_stripe_count++;
                }
 
@@ -1641,11 +1650,28 @@ out_rmdir:
                 rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg,
                                     sizeof(struct ioc_changelog));
                 RETURN(rc);
-        case OBD_IOC_FID2PATH:
+       case OBD_IOC_FID2PATH:
                RETURN(ll_fid2path(inode, (void *)arg));
+       case LL_IOC_FID2MDTIDX: {
+               struct obd_export *exp = ll_i2mdexp(inode);
+               struct lu_fid     fid;
+               __u32             index;
+
+               if (copy_from_user(&fid, (const struct lu_fid __user *)arg,
+                                  sizeof(fid)))
+                       RETURN(-EFAULT);
+
+               /* Call mdc_iocontrol */
+               rc = obd_iocontrol(LL_IOC_FID2MDTIDX, exp, sizeof(fid), &fid,
+                                  &index);
+               if (rc != 0)
+                       RETURN(rc);
+
+               RETURN(index);
+       }
        case LL_IOC_HSM_REQUEST: {
                struct hsm_user_request *hur;
-               int                      totalsize;
+               ssize_t                  totalsize;
 
                OBD_ALLOC_PTR(hur);
                if (hur == NULL)
@@ -1660,6 +1686,8 @@ out_rmdir:
                /* Compute the whole struct size */
                totalsize = hur_len(hur);
                OBD_FREE_PTR(hur);
+               if (totalsize < 0)
+                       RETURN(-E2BIG);
 
                /* Final size will be more than double totalsize */
                if (totalsize >= MDS_MAXREQSIZE / 3)