}
EXPORT_SYMBOL(lustre_shrink_msg);
+static int lustre_grow_msg_v2(struct lustre_msg_v2 *msg, __u32 segment,
+ unsigned int newlen)
+{
+ char *tail = NULL, *newpos;
+ int tail_len = 0, n;
+
+ LASSERT(msg);
+ LASSERT(msg->lm_bufcount > segment);
+ LASSERT(msg->lm_buflens[segment] <= newlen);
+
+ if (msg->lm_buflens[segment] == newlen)
+ goto out;
+
+ if (msg->lm_bufcount > segment + 1) {
+ tail = lustre_msg_buf_v2(msg, segment + 1, 0);
+ for (n = segment + 1; n < msg->lm_bufcount; n++)
+ tail_len += cfs_size_round(msg->lm_buflens[n]);
+ }
+
+ msg->lm_buflens[segment] = newlen;
+
+ if (tail && tail_len) {
+ newpos = lustre_msg_buf_v2(msg, segment + 1, 0);
+ memmove(newpos, tail, tail_len);
+ }
+out:
+ return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
+}
+
+/*
+ * for @msg, grow @segment to size @newlen.
+ * Always move higher buffer forward.
+ *
+ * return new msg size after growing.
+ *
+ * CAUTION:
+ * - caller must make sure there is enough space in allocated message buffer
+ * - caller should NOT keep pointers to msg buffers which higher than @segment
+ * after call shrink.
+ */
+int lustre_grow_msg(struct lustre_msg *msg, int segment, unsigned int newlen)
+{
+ switch (msg->lm_magic) {
+ case LUSTRE_MSG_MAGIC_V2:
+ return lustre_grow_msg_v2(msg, segment, newlen);
+ default:
+ LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ }
+}
+EXPORT_SYMBOL(lustre_grow_msg);
+
void lustre_free_reply_state(struct ptlrpc_reply_state *rs)
{
PTLRPC_RS_DEBUG_LRU_DEL(rs);
"msg %p buffer[%d] len %d\n", m, index, blen);
return NULL;
}
+ if (blen > PTLRPC_MAX_BUFLEN) {
+ CERROR("buffer length of msg %p buffer[%d] is invalid(%d)\n",
+ m, index, blen);
+ return NULL;
+ }
if (max_len == 0) {
if (slen != blen - 1) {
__swab32s(&fm_extent->fe_device);
}
+static void lustre_swab_fiemap_hdr(struct fiemap *fiemap)
+{
+ __swab64s(&fiemap->fm_start);
+ __swab64s(&fiemap->fm_length);
+ __swab32s(&fiemap->fm_flags);
+ __swab32s(&fiemap->fm_mapped_extents);
+ __swab32s(&fiemap->fm_extent_count);
+ __swab32s(&fiemap->fm_reserved);
+}
+
void lustre_swab_fiemap(struct fiemap *fiemap)
{
__u32 i;
- __swab64s(&fiemap->fm_start);
- __swab64s(&fiemap->fm_length);
- __swab32s(&fiemap->fm_flags);
- __swab32s(&fiemap->fm_mapped_extents);
- __swab32s(&fiemap->fm_extent_count);
- __swab32s(&fiemap->fm_reserved);
+ lustre_swab_fiemap_hdr(fiemap);
for (i = 0; i < fiemap->fm_mapped_extents; i++)
lustre_swab_fiemap_extent(&fiemap->fm_extents[i]);
}
+void lustre_swab_fiemap_info_key(struct ll_fiemap_info_key *fiemap_info)
+{
+ lustre_swab_obdo(&fiemap_info->lfik_oa);
+ lustre_swab_fiemap_hdr(&fiemap_info->lfik_fiemap);
+}
+
void lustre_swab_idx_info(struct idx_info *ii)
{
__swab32s(&ii->ii_magic);