1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001-2003 Cluster File Systems, Inc.
5 * Author: Andreas Dilger <adilger@clusterfs.com>
7 * This file is part of the Lustre file system, http://www.lustre.org
8 * Lustre is a trademark of Cluster File Systems, Inc.
10 * You may have signed or agreed to another license before downloading
11 * this software. If so, you are bound by the terms and conditions
12 * of that agreement, and the following does not apply to you. See the
13 * LICENSE file included with this distribution for more information.
15 * If you did not agree to a different license, then this copy of Lustre
16 * is open source software; you can redistribute it and/or modify it
17 * under the terms of version 2 of the GNU General Public License as
18 * published by the Free Software Foundation.
20 * In either case, Lustre is distributed in the hope that it will be
21 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
22 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * license text for more details.
25 * OST<->MDS recovery logging infrastructure.
27 * Invariants in implementation:
28 * - we do not share logs among different OST<->MDS connections, so that
29 * if an OST or MDS fails it need only look at log(s) relevant to itself
32 #define DEBUG_SUBSYSTEM S_LOG
39 #include <liblustre.h>
43 #include <obd_class.h>
44 #include <lustre_log.h>
46 #include <libcfs/list.h>
48 #include <lustre_fsfilt.h>
49 #include <lustre_disk.h>
50 #include "llog_internal.h"
52 #if defined(__KERNEL__) && defined(LLOG_LVFS)
54 static int llog_lvfs_pad(struct obd_device *obd, struct l_file *file,
57 struct llog_rec_hdr rec = { 0 };
58 struct llog_rec_tail tail;
62 LASSERT(len >= LLOG_MIN_REC_SIZE && (len & 0x7) == 0);
64 tail.lrt_len = rec.lrh_len = len;
65 tail.lrt_index = rec.lrh_index = index;
66 rec.lrh_type = LLOG_PAD_MAGIC;
68 rc = fsfilt_write_record(obd, file, &rec, sizeof(rec), &file->f_pos, 0);
70 CERROR("error writing padding record: rc %d\n", rc);
74 file->f_pos += len - sizeof(rec) - sizeof(tail);
75 rc = fsfilt_write_record(obd, file, &tail, sizeof(tail),&file->f_pos,0);
77 CERROR("error writing padding record: rc %d\n", rc);
85 static int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file,
86 struct llog_rec_hdr *rec, void *buf, loff_t off)
89 struct llog_rec_tail end;
90 loff_t saved_off = file->f_pos;
91 int buflen = rec->lrh_len;
97 rc = fsfilt_write_record(obd, file, rec, buflen,&file->f_pos,0);
99 CERROR("error writing log record: rc %d\n", rc);
106 rec->lrh_len = sizeof(*rec) + buflen + sizeof(end);
107 rc = fsfilt_write_record(obd, file, rec, sizeof(*rec), &file->f_pos, 0);
109 CERROR("error writing log hdr: rc %d\n", rc);
113 rc = fsfilt_write_record(obd, file, buf, buflen, &file->f_pos, 0);
115 CERROR("error writing log buffer: rc %d\n", rc);
119 end.lrt_len = rec->lrh_len;
120 end.lrt_index = rec->lrh_index;
121 rc = fsfilt_write_record(obd, file, &end, sizeof(end), &file->f_pos, 0);
123 CERROR("error writing log tail: rc %d\n", rc);
129 if (saved_off > file->f_pos)
130 file->f_pos = saved_off;
135 static int llog_lvfs_read_blob(struct obd_device *obd, struct l_file *file,
136 void *buf, int size, loff_t off)
142 rc = fsfilt_read_record(obd, file, buf, size, &offset);
144 CERROR("error reading log record: rc %d\n", rc);
150 static int llog_lvfs_read_header(struct llog_handle *handle)
152 struct obd_device *obd;
156 LASSERT(sizeof(*handle->lgh_hdr) == LLOG_CHUNK_SIZE);
158 obd = handle->lgh_ctxt->loc_exp->exp_obd;
160 if (handle->lgh_file->f_dentry->d_inode->i_size == 0) {
161 CDEBUG(D_HA, "not reading header from 0-byte log\n");
165 rc = llog_lvfs_read_blob(obd, handle->lgh_file, handle->lgh_hdr,
168 CERROR("error reading log header from %.*s\n",
169 handle->lgh_file->f_dentry->d_name.len,
170 handle->lgh_file->f_dentry->d_name.name);
172 struct llog_rec_hdr *llh_hdr = &handle->lgh_hdr->llh_hdr;
174 if (LLOG_REC_HDR_NEEDS_SWABBING(llh_hdr))
175 lustre_swab_llog_hdr(handle->lgh_hdr);
177 if (llh_hdr->lrh_type != LLOG_HDR_MAGIC) {
178 CERROR("bad log %.*s header magic: %#x (expected %#x)\n",
179 handle->lgh_file->f_dentry->d_name.len,
180 handle->lgh_file->f_dentry->d_name.name,
181 llh_hdr->lrh_type, LLOG_HDR_MAGIC);
183 } else if (llh_hdr->lrh_len != LLOG_CHUNK_SIZE) {
184 CERROR("incorrectly sized log %.*s header: %#x "
186 handle->lgh_file->f_dentry->d_name.len,
187 handle->lgh_file->f_dentry->d_name.name,
188 llh_hdr->lrh_len, LLOG_CHUNK_SIZE);
189 CERROR("you may need to re-run lconf --write_conf.\n");
194 handle->lgh_last_idx = handle->lgh_hdr->llh_tail.lrt_index;
195 handle->lgh_file->f_pos = handle->lgh_file->f_dentry->d_inode->i_size;
200 /* returns negative in on error; 0 if success && reccookie == 0; 1 otherwise */
201 /* appends if idx == -1, otherwise overwrites record idx. */
202 static int llog_lvfs_write_rec(struct llog_handle *loghandle,
203 struct llog_rec_hdr *rec,
204 struct llog_cookie *reccookie, int cookiecount,
207 struct llog_log_hdr *llh;
208 int reclen = rec->lrh_len, index, rc;
209 struct llog_rec_tail *lrt;
210 struct obd_device *obd;
215 llh = loghandle->lgh_hdr;
216 file = loghandle->lgh_file;
217 obd = loghandle->lgh_ctxt->loc_exp->exp_obd;
219 /* record length should not bigger than LLOG_CHUNK_SIZE */
221 rc = (reclen > LLOG_CHUNK_SIZE - sizeof(struct llog_rec_hdr) -
222 sizeof(struct llog_rec_tail)) ? -E2BIG : 0;
224 rc = (reclen > LLOG_CHUNK_SIZE) ? -E2BIG : 0;
229 /* write_blob adds header and tail to lrh_len. */
230 reclen = sizeof(*rec) + rec->lrh_len +
231 sizeof(struct llog_rec_tail);
236 /* no header: only allowed to insert record 1 */
237 if (idx != 1 && !file->f_dentry->d_inode->i_size) {
238 CERROR("idx != -1 in empty log\n");
242 if (idx && llh->llh_size && llh->llh_size != rec->lrh_len)
245 if (!ext2_test_bit(idx, llh->llh_bitmap))
246 CERROR("Modify unset record %u\n", idx);
247 if (idx != rec->lrh_index)
248 CERROR("Index mismatch %d %u\n", idx, rec->lrh_index);
250 rc = llog_lvfs_write_blob(obd, file, &llh->llh_hdr, NULL, 0);
251 /* we are done if we only write the header or on error */
255 /* Assumes constant lrh_len */
256 saved_offset = sizeof(*llh) + (idx - 1) * reclen;
259 struct llog_rec_hdr check;
261 /* We assume that caller has set lgh_cur_* */
262 saved_offset = loghandle->lgh_cur_offset;
264 "modify record "LPX64": idx:%d/%u/%d, len:%u "
266 loghandle->lgh_id.lgl_oid, idx, rec->lrh_index,
267 loghandle->lgh_cur_idx,
268 rec->lrh_len, saved_offset - sizeof(*llh));
269 if (rec->lrh_index != loghandle->lgh_cur_idx) {
270 CERROR("modify idx mismatch %u/%d\n",
271 idx, loghandle->lgh_cur_idx);
274 #if 1 /* FIXME remove this safety check at some point */
275 /* Verify that the record we're modifying is the
277 rc = llog_lvfs_read_blob(obd, file, &check,
278 sizeof(check), saved_offset);
279 if (check.lrh_index != idx || check.lrh_len != reclen) {
280 CERROR("Bad modify idx %u/%u size %u/%u (%d)\n",
281 idx, check.lrh_index, reclen,
288 rc = llog_lvfs_write_blob(obd, file, rec, buf, saved_offset);
289 if (rc == 0 && reccookie) {
290 reccookie->lgc_lgl = loghandle->lgh_id;
291 reccookie->lgc_index = idx;
297 /* Make sure that records don't cross a chunk boundary, so we can
298 * process them page-at-a-time if needed. If it will cross a chunk
299 * boundary, write in a fake (but referenced) entry to pad the chunk.
301 * We know that llog_current_log() will return a loghandle that is
302 * big enough to hold reclen, so all we care about is padding here.
304 left = LLOG_CHUNK_SIZE - (file->f_pos & (LLOG_CHUNK_SIZE - 1));
306 /* NOTE: padding is a record, but no bit is set */
307 if (left != 0 && left != reclen &&
308 left < (reclen + LLOG_MIN_REC_SIZE)) {
309 loghandle->lgh_last_idx++;
310 rc = llog_lvfs_pad(obd, file, left, loghandle->lgh_last_idx);
313 /* if it's the last idx in log file, then return -ENOSPC */
314 if (loghandle->lgh_last_idx == LLOG_BITMAP_SIZE(llh) - 1)
318 loghandle->lgh_last_idx++;
319 index = loghandle->lgh_last_idx;
320 LASSERT(index < LLOG_BITMAP_SIZE(llh));
321 rec->lrh_index = index;
323 lrt = (struct llog_rec_tail *)
324 ((char *)rec + rec->lrh_len - sizeof(*lrt));
325 lrt->lrt_len = rec->lrh_len;
326 lrt->lrt_index = rec->lrh_index;
328 if (ext2_set_bit(index, llh->llh_bitmap)) {
329 CERROR("argh, index %u already set in log bitmap?\n", index);
330 LBUG(); /* should never happen */
333 llh->llh_tail.lrt_index = index;
335 rc = llog_lvfs_write_blob(obd, file, &llh->llh_hdr, NULL, 0);
339 rc = llog_lvfs_write_blob(obd, file, rec, buf, file->f_pos);
343 CDEBUG(D_HA, "added record "LPX64": idx: %u, %u bytes\n",
344 loghandle->lgh_id.lgl_oid, index, rec->lrh_len);
345 if (rc == 0 && reccookie) {
346 reccookie->lgc_lgl = loghandle->lgh_id;
347 reccookie->lgc_index = index;
348 if ((rec->lrh_type == MDS_UNLINK_REC) ||
349 (rec->lrh_type == MDS_SETATTR_REC))
350 reccookie->lgc_subsys = LLOG_MDS_OST_ORIG_CTXT;
351 else if (rec->lrh_type == OST_SZ_REC)
352 reccookie->lgc_subsys = LLOG_SIZE_ORIG_CTXT;
353 else if (rec->lrh_type == OST_RAID1_REC)
354 reccookie->lgc_subsys = LLOG_RD1_ORIG_CTXT;
356 reccookie->lgc_subsys = -1;
359 if (rc == 0 && rec->lrh_type == LLOG_GEN_REC)
365 /* We can skip reading at least as many log blocks as the number of
366 * minimum sized log records we are skipping. If it turns out
367 * that we are not far enough along the log (because the
368 * actual records are larger than minimum size) we just skip
369 * some more records. */
371 static void llog_skip_over(__u64 *off, int curr, int goal)
375 *off = (*off + (goal-curr-1) * LLOG_MIN_REC_SIZE) &
376 ~(LLOG_CHUNK_SIZE - 1);
381 * - cur_offset to the furthest point read in the log file
382 * - cur_idx to the log index preceeding cur_offset
383 * returns -EIO/-EINVAL on error
385 static int llog_lvfs_next_block(struct llog_handle *loghandle, int *cur_idx,
386 int next_idx, __u64 *cur_offset, void *buf,
392 if (len == 0 || len & (LLOG_CHUNK_SIZE - 1))
395 CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off "LPU64")\n",
396 next_idx, *cur_idx, *cur_offset);
398 while (*cur_offset < loghandle->lgh_file->f_dentry->d_inode->i_size) {
399 struct llog_rec_hdr *rec;
400 struct llog_rec_tail *tail;
403 llog_skip_over(cur_offset, *cur_idx, next_idx);
406 rc = fsfilt_read_record(loghandle->lgh_ctxt->loc_exp->exp_obd,
407 loghandle->lgh_file, buf, len,
410 CERROR("Cant read llog block at log id "LPU64
411 "/%u offset "LPU64"\n",
412 loghandle->lgh_id.lgl_oid,
413 loghandle->lgh_id.lgl_ogen,
418 /* put number of bytes read into rc to make code simpler */
419 rc = ppos - *cur_offset;
423 /* signal the end of the valid buffer to llog_process */
424 memset(buf + rc, 0, len - rc);
427 if (rc == 0) /* end of file, nothing to do */
430 if (rc < sizeof(*tail)) {
431 CERROR("Invalid llog block at log id "LPU64"/%u offset "
432 LPU64"\n", loghandle->lgh_id.lgl_oid,
433 loghandle->lgh_id.lgl_ogen, *cur_offset);
438 tail = (struct llog_rec_tail *)((char *)buf + rc -
439 sizeof(struct llog_rec_tail));
441 if (LLOG_REC_HDR_NEEDS_SWABBING(rec)) {
442 lustre_swab_llog_rec(rec, tail);
445 *cur_idx = tail->lrt_index;
447 /* this shouldn't happen */
448 if (tail->lrt_index == 0) {
449 CERROR("Invalid llog tail at log id "LPU64"/%u offset "
450 LPU64"\n", loghandle->lgh_id.lgl_oid,
451 loghandle->lgh_id.lgl_ogen, *cur_offset);
454 if (tail->lrt_index < next_idx)
457 /* sanity check that the start of the new buffer is no farther
458 * than the record that we wanted. This shouldn't happen. */
459 if (rec->lrh_index > next_idx) {
460 CERROR("missed desired record? %u > %u\n",
461 rec->lrh_index, next_idx);
469 static int llog_lvfs_prev_block(struct llog_handle *loghandle,
470 int prev_idx, void *buf, int len)
476 if (len == 0 || len & (LLOG_CHUNK_SIZE - 1))
479 CDEBUG(D_OTHER, "looking for log index %u n", prev_idx);
481 cur_offset = LLOG_CHUNK_SIZE;
482 llog_skip_over(&cur_offset, 0, prev_idx);
484 while (cur_offset < loghandle->lgh_file->f_dentry->d_inode->i_size) {
485 struct llog_rec_hdr *rec;
486 struct llog_rec_tail *tail;
491 rc = fsfilt_read_record(loghandle->lgh_ctxt->loc_exp->exp_obd,
492 loghandle->lgh_file, buf, len,
495 CERROR("Cant read llog block at log id "LPU64
496 "/%u offset "LPU64"\n",
497 loghandle->lgh_id.lgl_oid,
498 loghandle->lgh_id.lgl_ogen,
503 /* put number of bytes read into rc to make code simpler */
504 rc = ppos - cur_offset;
507 if (rc == 0) /* end of file, nothing to do */
510 if (rc < sizeof(*tail)) {
511 CERROR("Invalid llog block at log id "LPU64"/%u offset "
512 LPU64"\n", loghandle->lgh_id.lgl_oid,
513 loghandle->lgh_id.lgl_ogen, cur_offset);
517 tail = buf + rc - sizeof(struct llog_rec_tail);
519 /* this shouldn't happen */
520 if (tail->lrt_index == 0) {
521 CERROR("Invalid llog tail at log id "LPU64"/%u offset "
522 LPU64"\n", loghandle->lgh_id.lgl_oid,
523 loghandle->lgh_id.lgl_ogen, cur_offset);
526 if (le32_to_cpu(tail->lrt_index) < prev_idx)
529 /* sanity check that the start of the new buffer is no farther
530 * than the record that we wanted. This shouldn't happen. */
532 if (le32_to_cpu(rec->lrh_index) > prev_idx) {
533 CERROR("missed desired record? %u > %u\n",
534 le32_to_cpu(rec->lrh_index), prev_idx);
542 static struct file *llog_filp_open(char *dir, char *name, int flags, int mode)
548 OBD_ALLOC(logname, PATH_MAX);
550 return ERR_PTR(-ENOMEM);
552 len = snprintf(logname, PATH_MAX, "%s/%s", dir, name);
553 if (len >= PATH_MAX - 1) {
554 filp = ERR_PTR(-ENAMETOOLONG);
556 filp = l_filp_open(logname, flags, mode);
558 CERROR("logfile creation %s: %ld\n", logname,
561 OBD_FREE(logname, PATH_MAX);
565 /* This is a callback from the llog_* functions.
566 * Assumes caller has already pushed us into the kernel context. */
567 static int llog_lvfs_create(struct llog_ctxt *ctxt, struct llog_handle **res,
568 struct llog_logid *logid, char *name)
570 struct llog_handle *handle;
571 struct obd_device *obd;
572 struct l_dentry *dchild = NULL;
573 struct obdo *oa = NULL;
574 int rc = 0, cleanup_phase = 1;
575 int open_flags = O_RDWR | O_CREAT | O_LARGEFILE;
578 handle = llog_alloc_handle();
584 LASSERT(ctxt->loc_exp);
585 obd = ctxt->loc_exp->exp_obd;
588 dchild = obd_lvfs_fid2dentry(ctxt->loc_exp, logid->lgl_oid,
589 logid->lgl_ogen, logid->lgl_ogr);
591 if (IS_ERR(dchild)) {
592 rc = PTR_ERR(dchild);
593 CERROR("error looking up logfile "LPX64":0x%x: rc %d\n",
594 logid->lgl_oid, logid->lgl_ogen, rc);
599 if (dchild->d_inode == NULL) {
601 CERROR("nonexistent log file "LPX64":"LPX64": rc %d\n",
602 logid->lgl_oid, logid->lgl_ogr, rc);
606 handle->lgh_file = l_dentry_open(&obd->obd_lvfs_ctxt, dchild,
607 O_RDWR | O_LARGEFILE);
608 if (IS_ERR(handle->lgh_file)) {
609 rc = PTR_ERR(handle->lgh_file);
610 CERROR("error opening logfile "LPX64"0x%x: rc %d\n",
611 logid->lgl_oid, logid->lgl_ogen, rc);
615 /* assign the value of lgh_id for handle directly */
616 handle->lgh_id = *logid;
620 if (strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME) == 0) {
621 handle->lgh_file = llog_filp_open(MDT_LOGS_DIR, name,
625 handle->lgh_file = llog_filp_open(MOUNT_CONFIGS_DIR,
629 if (IS_ERR(handle->lgh_file))
630 GOTO(cleanup, rc = PTR_ERR(handle->lgh_file));
632 handle->lgh_id.lgl_ogr = 1;
633 handle->lgh_id.lgl_oid =
634 handle->lgh_file->f_dentry->d_inode->i_ino;
635 handle->lgh_id.lgl_ogen =
636 handle->lgh_file->f_dentry->d_inode->i_generation;
640 GOTO(cleanup, rc = -ENOMEM);
642 oa->o_gr = FILTER_GROUP_LLOG;
643 oa->o_valid = OBD_MD_FLGENER | OBD_MD_FLGROUP;
645 rc = obd_create(ctxt->loc_exp, oa, NULL, NULL);
649 dchild = obd_lvfs_fid2dentry(ctxt->loc_exp, oa->o_id,
650 oa->o_generation, oa->o_gr);
653 GOTO(cleanup, rc = PTR_ERR(dchild));
655 handle->lgh_file = l_dentry_open(&obd->obd_lvfs_ctxt, dchild,
657 if (IS_ERR(handle->lgh_file))
658 GOTO(cleanup, rc = PTR_ERR(handle->lgh_file));
660 handle->lgh_id.lgl_ogr = oa->o_gr;
661 handle->lgh_id.lgl_oid = oa->o_id;
662 handle->lgh_id.lgl_ogen = oa->o_generation;
665 handle->lgh_ctxt = ctxt;
671 switch (cleanup_phase) {
675 llog_free_handle(handle);
680 static int llog_lvfs_close(struct llog_handle *handle)
685 rc = filp_close(handle->lgh_file, 0);
687 CERROR("error closing log: rc %d\n", rc);
691 static int llog_lvfs_destroy(struct llog_handle *handle)
693 struct dentry *fdentry;
695 struct obd_device *obd = handle->lgh_ctxt->loc_exp->exp_obd;
701 if (strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME) == 0)
705 dir = MOUNT_CONFIGS_DIR;
707 fdentry = handle->lgh_file->f_dentry;
708 if (strcmp(fdentry->d_parent->d_name.name, dir) == 0) {
709 struct inode *inode = fdentry->d_parent->d_inode;
710 struct lvfs_run_ctxt saved;
712 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
714 rc = llog_lvfs_close(handle);
717 LOCK_INODE_MUTEX(inode);
718 rc = vfs_unlink(inode, fdentry);
719 UNLOCK_INODE_MUTEX(inode);
723 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
731 oa->o_id = handle->lgh_id.lgl_oid;
732 oa->o_gr = handle->lgh_id.lgl_ogr;
733 oa->o_generation = handle->lgh_id.lgl_ogen;
734 oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLGENER;
736 rc = llog_lvfs_close(handle);
740 rc = obd_destroy(handle->lgh_ctxt->loc_exp, oa, NULL, NULL, NULL);
746 /* reads the catalog list */
747 int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
748 char *name, int count, struct llog_catid *idarray)
750 struct lvfs_run_ctxt saved;
753 int size = sizeof(*idarray) * count;
760 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
761 file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700);
762 if (!file || IS_ERR(file)) {
764 CERROR("OBD filter: cannot open/create %s: rc = %d\n",
769 if (!S_ISREG(file->f_dentry->d_inode->i_mode)) {
770 CERROR("%s is not a regular file!: mode = %o\n", name,
771 file->f_dentry->d_inode->i_mode);
772 GOTO(out, rc = -ENOENT);
775 CDEBUG(D_CONFIG, "cat list: disk size=%d, read=%d\n",
776 (int)file->f_dentry->d_inode->i_size, size);
778 rc = fsfilt_read_record(disk_obd, file, idarray, size, &off);
780 CERROR("OBD filter: error reading %s: rc %d\n", name, rc);
786 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
787 if (file && !IS_ERR(file))
788 rc = filp_close(file, 0);
791 EXPORT_SYMBOL(llog_get_cat_list);
793 /* writes the cat list */
794 int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
795 char *name, int count, struct llog_catid *idarray)
797 struct lvfs_run_ctxt saved;
800 int size = sizeof(*idarray) * count;
806 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
807 file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700);
808 if (!file || IS_ERR(file)) {
810 CERROR("OBD filter: cannot open/create %s: rc = %d\n",
815 if (!S_ISREG(file->f_dentry->d_inode->i_mode)) {
816 CERROR("%s is not a regular file!: mode = %o\n", name,
817 file->f_dentry->d_inode->i_mode);
818 GOTO(out, rc = -ENOENT);
821 rc = fsfilt_write_record(disk_obd, file, idarray, size, &off, 1);
823 CDEBUG(D_INODE,"OBD filter: error reading %s: rc %d\n",
829 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
830 if (file && !IS_ERR(file))
831 rc = filp_close(file, 0);
835 struct llog_operations llog_lvfs_ops = {
836 lop_write_rec: llog_lvfs_write_rec,
837 lop_next_block: llog_lvfs_next_block,
838 lop_prev_block: llog_lvfs_prev_block,
839 lop_read_header: llog_lvfs_read_header,
840 lop_create: llog_lvfs_create,
841 lop_destroy: llog_lvfs_destroy,
842 lop_close: llog_lvfs_close,
843 // lop_cancel: llog_lvfs_cancel,
846 EXPORT_SYMBOL(llog_lvfs_ops);
848 #else /* !__KERNEL__ */
850 static int llog_lvfs_read_header(struct llog_handle *handle)
856 static int llog_lvfs_write_rec(struct llog_handle *loghandle,
857 struct llog_rec_hdr *rec,
858 struct llog_cookie *reccookie, int cookiecount,
865 static int llog_lvfs_next_block(struct llog_handle *loghandle, int *cur_idx,
866 int next_idx, __u64 *cur_offset, void *buf,
873 static int llog_lvfs_prev_block(struct llog_handle *loghandle,
874 int prev_idx, void *buf, int len)
880 static int llog_lvfs_create(struct llog_ctxt *ctxt, struct llog_handle **res,
881 struct llog_logid *logid, char *name)
887 static int llog_lvfs_close(struct llog_handle *handle)
893 static int llog_lvfs_destroy(struct llog_handle *handle)
899 int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
900 char *name, int count, struct llog_catid *idarray)
906 int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
907 char *name, int count, struct llog_catid *idarray)
913 struct llog_operations llog_lvfs_ops = {
914 lop_write_rec: llog_lvfs_write_rec,
915 lop_next_block: llog_lvfs_next_block,
916 lop_prev_block: llog_lvfs_prev_block,
917 lop_read_header: llog_lvfs_read_header,
918 lop_create: llog_lvfs_create,
919 lop_destroy: llog_lvfs_destroy,
920 lop_close: llog_lvfs_close,
921 // lop_cancel: llog_lvfs_cancel,