Whamcloud - gitweb
LU-6698 kernel: kernel update RHEL 6.6 [2.6.32-504.23.4.el6]
[fs/lustre-release.git] / lustre / obdclass / linkea.c
index 8c580f0..910efb9 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2013, Intel Corporation.
+ * Copyright (c) 2013, 2014, Intel Corporation.
  * Use is subject to license terms.
  *
  * Author: Di Wang <di.wang@intel.com>
@@ -33,7 +33,7 @@
 
 int linkea_data_new(struct linkea_data *ldata, struct lu_buf *buf)
 {
-       ldata->ld_buf = lu_buf_check_and_alloc(buf, CFS_PAGE_SIZE);
+       ldata->ld_buf = lu_buf_check_and_alloc(buf, PAGE_CACHE_SIZE);
        if (ldata->ld_buf->lb_buf == NULL)
                return -ENOMEM;
        ldata->ld_leh = ldata->ld_buf->lb_buf;
@@ -72,16 +72,18 @@ EXPORT_SYMBOL(linkea_init);
  * Numbers are always big-endian
  * \retval record length
  */
-static int linkea_entry_pack(struct link_ea_entry *lee,
-                            const struct lu_name *lname,
-                            const struct lu_fid *pfid)
+int linkea_entry_pack(struct link_ea_entry *lee, const struct lu_name *lname,
+                     const struct lu_fid *pfid)
 {
        struct lu_fid   tmpfid;
        int             reclen;
 
-       fid_cpu_to_be(&tmpfid, pfid);
+       tmpfid = *pfid;
+       if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_MUL_REF))
+               tmpfid.f_oid--;
        if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LINKEA_CRASH))
                tmpfid.f_ver = ~0;
+       fid_cpu_to_be(&tmpfid, &tmpfid);
        memcpy(&lee->lee_parent_fid, &tmpfid, sizeof(tmpfid));
        memcpy(lee->lee_name, lname->ln_name, lname->ln_namelen);
        reclen = sizeof(struct link_ea_entry) + lname->ln_namelen;
@@ -90,6 +92,7 @@ static int linkea_entry_pack(struct link_ea_entry *lee,
        lee->lee_reclen[1] = reclen & 0xff;
        return reclen;
 }
+EXPORT_SYMBOL(linkea_entry_pack);
 
 void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen,
                         struct lu_name *lname, struct lu_fid *pfid)
@@ -97,8 +100,10 @@ void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen,
        *reclen = (lee->lee_reclen[0] << 8) | lee->lee_reclen[1];
        memcpy(pfid, &lee->lee_parent_fid, sizeof(*pfid));
        fid_be_to_cpu(pfid, pfid);
-       lname->ln_name = lee->lee_name;
-       lname->ln_namelen = *reclen - sizeof(struct link_ea_entry);
+       if (lname != NULL) {
+               lname->ln_name = lee->lee_name;
+               lname->ln_namelen = *reclen - sizeof(struct link_ea_entry);
+       }
 }
 EXPORT_SYMBOL(linkea_entry_unpack);
 
@@ -145,6 +150,10 @@ void linkea_del_buf(struct linkea_data *ldata, const struct lu_name *lname)
                (char *)ldata->ld_lee);
        CDEBUG(D_INODE, "Old link_ea name '%.*s' is removed\n",
               lname->ln_namelen, lname->ln_name);
+
+       if ((char *)ldata->ld_lee >= ((char *)ldata->ld_leh +
+                                     ldata->ld_leh->leh_len))
+               ldata->ld_lee = NULL;
 }
 EXPORT_SYMBOL(linkea_del_buf);
 
@@ -187,6 +196,7 @@ int linkea_links_find(struct linkea_data *ldata, const struct lu_name *lname,
                CDEBUG(D_INODE, "Old link_ea name '%.*s' not found\n",
                       lname->ln_namelen, lname->ln_name);
                ldata->ld_lee = NULL;
+               ldata->ld_reclen = 0;
                return -ENOENT;
        }
        return 0;