*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, Whamcloud, Inc.
+ * Copyright (c) 2012, 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#define DEBUG_SUBSYSTEM S_LOG
-#ifdef __KERNEL__
+#include <linux/list.h>
#include <libcfs/libcfs.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd_class.h>
#include <lustre_log.h>
#include <lustre_net.h>
-#include <libcfs/list.h>
#define LLOG_CLIENT_ENTRY(ctxt, imp) do { \
- cfs_mutex_lock(&ctxt->loc_mutex); \
+ mutex_lock(&ctxt->loc_mutex); \
if (ctxt->loc_imp) { \
imp = class_import_get(ctxt->loc_imp); \
} else { \
"but I'll try again next time. Not fatal.\n", \
ctxt->loc_idx); \
imp = NULL; \
- cfs_mutex_unlock(&ctxt->loc_mutex); \
+ mutex_unlock(&ctxt->loc_mutex); \
return (-EINVAL); \
} \
- cfs_mutex_unlock(&ctxt->loc_mutex); \
+ mutex_unlock(&ctxt->loc_mutex); \
} while(0)
#define LLOG_CLIENT_EXIT(ctxt, imp) do { \
- cfs_mutex_lock(&ctxt->loc_mutex); \
+ mutex_lock(&ctxt->loc_mutex); \
if (ctxt->loc_imp != imp) \
CWARN("loc_imp has changed from %p to %p\n", \
ctxt->loc_imp, imp); \
class_import_put(imp); \
- cfs_mutex_unlock(&ctxt->loc_mutex); \
+ mutex_unlock(&ctxt->loc_mutex); \
} while(0)
/* This is a callback from the llog_* functions.
}
static int llog_client_destroy(const struct lu_env *env,
- struct llog_handle *loghandle)
+ struct llog_handle *loghandle,
+ struct thandle *th)
{
struct obd_import *imp;
struct ptlrpc_request *req = NULL;
if (hdr == NULL)
GOTO(out, rc =-EFAULT);
- memcpy(handle->lgh_hdr, hdr, sizeof (*hdr));
- handle->lgh_last_idx = handle->lgh_hdr->llh_tail.lrt_index;
-
- /* sanity checks */
- llh_hdr = &handle->lgh_hdr->llh_hdr;
- if (llh_hdr->lrh_type != LLOG_HDR_MAGIC) {
- CERROR("bad log header magic: %#x (expecting %#x)\n",
- llh_hdr->lrh_type, LLOG_HDR_MAGIC);
- rc = -EIO;
- } else if (llh_hdr->lrh_len != LLOG_CHUNK_SIZE) {
- CERROR("incorrectly sized log header: %#x "
- "(expecting %#x)\n",
- llh_hdr->lrh_len, LLOG_CHUNK_SIZE);
- CERROR("you may need to re-run lconf --write_conf.\n");
- rc = -EIO;
- }
- EXIT;
+ if (handle->lgh_hdr_size < hdr->llh_hdr.lrh_len)
+ GOTO(out, rc = -EFAULT);
+
+ memcpy(handle->lgh_hdr, hdr, hdr->llh_hdr.lrh_len);
+ handle->lgh_last_idx = LLOG_HDR_TAIL(handle->lgh_hdr)->lrt_index;
+
+ /* sanity checks */
+ llh_hdr = &handle->lgh_hdr->llh_hdr;
+ if (llh_hdr->lrh_type != LLOG_HDR_MAGIC) {
+ CERROR("bad log header magic: %#x (expecting %#x)\n",
+ llh_hdr->lrh_type, LLOG_HDR_MAGIC);
+ rc = -EIO;
+ } else if (llh_hdr->lrh_len !=
+ LLOG_HDR_TAIL(handle->lgh_hdr)->lrt_len ||
+ (llh_hdr->lrh_len & (llh_hdr->lrh_len - 1)) != 0 ||
+ llh_hdr->lrh_len < LLOG_MIN_CHUNK_SIZE ||
+ llh_hdr->lrh_len > handle->lgh_hdr_size) {
+ CERROR("incorrectly sized log header: %#x, "
+ "expecting %#x (power of two > 8192)\n",
+ llh_hdr->lrh_len,
+ LLOG_HDR_TAIL(handle->lgh_hdr)->lrt_len);
+ CERROR("you may need to re-run lconf --write_conf.\n");
+ rc = -EIO;
+ }
+ EXIT;
out:
ptlrpc_req_finished(req);
err_exit: