4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/obdclass/llog_lvfs.c
38 * OST<->MDS recovery logging infrastructure.
39 * Invariants in implementation:
40 * - we do not share logs among different OST<->MDS connections, so that
41 * if an OST or MDS fails it need only look at log(s) relevant to itself
43 * Author: Andreas Dilger <adilger@clusterfs.com>
46 #define DEBUG_SUBSYSTEM S_LOG
50 #include <obd_class.h>
51 #include <lustre_log.h>
53 #include <linux/list.h>
55 #include <lustre_fsfilt.h>
56 #include <lustre_disk.h>
57 #include "llog_internal.h"
59 #if defined(LLOG_LVFS)
61 static int llog_lvfs_pad(struct obd_device *obd, struct l_file *file,
64 struct llog_rec_hdr rec = { 0 };
65 struct llog_rec_tail tail;
68 LASSERT(len >= LLOG_MIN_REC_SIZE && (len & 0x7) == 0);
70 tail.lrt_len = rec.lrh_len = len;
71 tail.lrt_index = rec.lrh_index = index;
72 rec.lrh_type = LLOG_PAD_MAGIC;
74 rc = fsfilt_write_record(obd, file, &rec, sizeof(rec), &file->f_pos, 0);
76 CERROR("error writing padding record: rc %d\n", rc);
80 file->f_pos += len - sizeof(rec) - sizeof(tail);
81 rc = fsfilt_write_record(obd, file, &tail, sizeof(tail),&file->f_pos,0);
83 CERROR("error writing padding record: rc %d\n", rc);
91 static int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file,
92 struct llog_rec_hdr *rec, void *buf, loff_t off)
95 struct llog_rec_tail end;
96 loff_t saved_off = file->f_pos;
97 int buflen = rec->lrh_len;
102 CWARN("0-length record\n");
105 rc = fsfilt_write_record(obd, file, rec, buflen,&file->f_pos,0);
107 CERROR("error writing log record: rc %d\n", rc);
114 rec->lrh_len = sizeof(*rec) + buflen + sizeof(end);
115 rc = fsfilt_write_record(obd, file, rec, sizeof(*rec), &file->f_pos, 0);
117 CERROR("error writing log hdr: rc %d\n", rc);
121 rc = fsfilt_write_record(obd, file, buf, buflen, &file->f_pos, 0);
123 CERROR("error writing log buffer: rc %d\n", rc);
127 end.lrt_len = rec->lrh_len;
128 end.lrt_index = rec->lrh_index;
129 rc = fsfilt_write_record(obd, file, &end, sizeof(end), &file->f_pos, 0);
131 CERROR("error writing log tail: rc %d\n", rc);
137 if (saved_off > file->f_pos)
138 file->f_pos = saved_off;
143 static int llog_lvfs_read_blob(struct obd_device *obd, struct l_file *file,
144 void *buf, int size, loff_t off)
149 rc = fsfilt_read_record(obd, file, buf, size, &offset);
151 CERROR("error reading log record: rc %d\n", rc);
157 static int llog_lvfs_read_header(const struct lu_env *env,
158 struct llog_handle *handle)
160 struct obd_device *obd;
163 LASSERT(sizeof(*handle->lgh_hdr) == LLOG_CHUNK_SIZE);
165 obd = handle->lgh_ctxt->loc_exp->exp_obd;
167 if (i_size_read(handle->lgh_file->f_dentry->d_inode) == 0) {
168 CDEBUG(D_HA, "not reading header from 0-byte log\n");
172 rc = llog_lvfs_read_blob(obd, handle->lgh_file, handle->lgh_hdr,
175 CERROR("error reading log header from %.*s\n",
176 handle->lgh_file->f_dentry->d_name.len,
177 handle->lgh_file->f_dentry->d_name.name);
179 struct llog_rec_hdr *llh_hdr = &handle->lgh_hdr->llh_hdr;
181 if (LLOG_REC_HDR_NEEDS_SWABBING(llh_hdr))
182 lustre_swab_llog_hdr(handle->lgh_hdr);
184 if (llh_hdr->lrh_type != LLOG_HDR_MAGIC) {
185 CERROR("bad log %.*s header magic: %#x (expected %#x)\n",
186 handle->lgh_file->f_dentry->d_name.len,
187 handle->lgh_file->f_dentry->d_name.name,
188 llh_hdr->lrh_type, LLOG_HDR_MAGIC);
190 } else if (llh_hdr->lrh_len != LLOG_CHUNK_SIZE) {
191 CERROR("incorrectly sized log %.*s header: %#x "
193 handle->lgh_file->f_dentry->d_name.len,
194 handle->lgh_file->f_dentry->d_name.name,
195 llh_hdr->lrh_len, LLOG_CHUNK_SIZE);
196 CERROR("you may need to re-run lconf --write_conf.\n");
201 handle->lgh_last_idx = handle->lgh_hdr->llh_tail.lrt_index;
202 handle->lgh_file->f_pos = i_size_read(handle->lgh_file->f_dentry->d_inode);
207 /* returns negative in on error; 0 if success && reccookie == 0; 1 otherwise */
208 /* appends if idx == -1, otherwise overwrites record idx. */
209 static int llog_lvfs_write_rec(const struct lu_env *env,
210 struct llog_handle *loghandle,
211 struct llog_rec_hdr *rec,
212 struct llog_cookie *reccookie, int cookiecount,
213 void *buf, int idx, struct thandle *th)
215 struct llog_log_hdr *llh;
216 int reclen = rec->lrh_len, index, rc;
217 struct llog_rec_tail *lrt;
218 struct obd_device *obd;
222 llh = loghandle->lgh_hdr;
223 file = loghandle->lgh_file;
224 obd = loghandle->lgh_ctxt->loc_exp->exp_obd;
226 /* record length should not bigger than LLOG_CHUNK_SIZE */
228 rc = (reclen > LLOG_CHUNK_SIZE - sizeof(struct llog_rec_hdr) -
229 sizeof(struct llog_rec_tail)) ? -E2BIG : 0;
231 rc = (reclen > LLOG_CHUNK_SIZE) ? -E2BIG : 0;
236 /* write_blob adds header and tail to lrh_len. */
237 reclen = sizeof(*rec) + rec->lrh_len +
238 sizeof(struct llog_rec_tail);
243 /* no header: only allowed to insert record 1 */
244 if (idx != 1 && !i_size_read(file->f_dentry->d_inode)) {
245 CERROR("idx != -1 in empty log\n");
249 if (idx && llh->llh_size && llh->llh_size != rec->lrh_len)
252 if (!ext2_test_bit(idx, llh->llh_bitmap))
253 CERROR("Modify unset record %u\n", idx);
254 if (idx != rec->lrh_index)
255 CERROR("Index mismatch %d %u\n", idx, rec->lrh_index);
257 rc = llog_lvfs_write_blob(obd, file, &llh->llh_hdr, NULL, 0);
258 /* we are done if we only write the header or on error */
263 /* We assume that caller has set lgh_cur_* */
264 saved_offset = loghandle->lgh_cur_offset;
266 "modify record "DOSTID": idx:%d/%u/%d, len:%u "
268 POSTID(&loghandle->lgh_id.lgl_oi), idx, rec->lrh_index,
269 loghandle->lgh_cur_idx, rec->lrh_len,
270 (long long)(saved_offset - sizeof(*llh)));
271 if (rec->lrh_index != loghandle->lgh_cur_idx) {
272 CERROR("modify idx mismatch %u/%d\n",
273 idx, loghandle->lgh_cur_idx);
277 /* Assumes constant lrh_len */
278 saved_offset = sizeof(*llh) + (idx - 1) * reclen;
281 rc = llog_lvfs_write_blob(obd, file, rec, buf, saved_offset);
282 if (rc == 0 && reccookie) {
283 reccookie->lgc_lgl = loghandle->lgh_id;
284 reccookie->lgc_index = idx;
290 /* Make sure that records don't cross a chunk boundary, so we can
291 * process them page-at-a-time if needed. If it will cross a chunk
292 * boundary, write in a fake (but referenced) entry to pad the chunk.
294 * We know that llog_current_log() will return a loghandle that is
295 * big enough to hold reclen, so all we care about is padding here.
297 left = LLOG_CHUNK_SIZE - (file->f_pos & (LLOG_CHUNK_SIZE - 1));
299 /* NOTE: padding is a record, but no bit is set */
300 if (left != 0 && left != reclen &&
301 left < (reclen + LLOG_MIN_REC_SIZE)) {
302 index = loghandle->lgh_last_idx + 1;
303 rc = llog_lvfs_pad(obd, file, left, index);
306 loghandle->lgh_last_idx++; /*for pad rec*/
308 /* if it's the last idx in log file, then return -ENOSPC */
309 if (loghandle->lgh_last_idx >= LLOG_BITMAP_SIZE(llh) - 1)
311 loghandle->lgh_last_idx++;
312 index = loghandle->lgh_last_idx;
313 LASSERT(index < LLOG_BITMAP_SIZE(llh));
314 rec->lrh_index = index;
316 lrt = (struct llog_rec_tail *)
317 ((char *)rec + rec->lrh_len - sizeof(*lrt));
318 lrt->lrt_len = rec->lrh_len;
319 lrt->lrt_index = rec->lrh_index;
321 /*The caller should make sure only 1 process access the lgh_last_idx,
322 *Otherwise it might hit the assert.*/
323 LASSERT(index < LLOG_BITMAP_SIZE(llh));
324 spin_lock(&loghandle->lgh_hdr_lock);
325 if (ext2_set_bit(index, llh->llh_bitmap)) {
326 CERROR("argh, index %u already set in log bitmap?\n", index);
327 spin_unlock(&loghandle->lgh_hdr_lock);
328 LBUG(); /* should never happen */
331 spin_unlock(&loghandle->lgh_hdr_lock);
332 llh->llh_tail.lrt_index = index;
334 rc = llog_lvfs_write_blob(obd, file, &llh->llh_hdr, NULL, 0);
338 rc = llog_lvfs_write_blob(obd, file, rec, buf, file->f_pos);
342 CDEBUG(D_RPCTRACE, "added record "DOSTID": idx: %u, %u \n",
343 POSTID(&loghandle->lgh_id.lgl_oi), index, rec->lrh_len);
344 if (rc == 0 && reccookie) {
345 reccookie->lgc_lgl = loghandle->lgh_id;
346 reccookie->lgc_index = index;
347 if ((rec->lrh_type == MDS_UNLINK_REC) ||
348 (rec->lrh_type == MDS_SETATTR64_REC))
349 reccookie->lgc_subsys = LLOG_MDS_OST_ORIG_CTXT;
350 else if (rec->lrh_type == OST_SZ_REC)
351 reccookie->lgc_subsys = LLOG_SIZE_ORIG_CTXT;
353 reccookie->lgc_subsys = -1;
356 if (rc == 0 && rec->lrh_type == LLOG_GEN_REC)
362 /* We can skip reading at least as many log blocks as the number of
363 * minimum sized log records we are skipping. If it turns out
364 * that we are not far enough along the log (because the
365 * actual records are larger than minimum size) we just skip
366 * some more records. */
368 static void llog_skip_over(__u64 *off, int curr, int goal)
372 *off = (*off + (goal-curr-1) * LLOG_MIN_REC_SIZE) &
373 ~(LLOG_CHUNK_SIZE - 1);
378 * - cur_offset to the furthest point read in the log file
379 * - cur_idx to the log index preceeding cur_offset
380 * returns -EIO/-EINVAL on error
382 static int llog_lvfs_next_block(const struct lu_env *env,
383 struct llog_handle *loghandle, int *cur_idx,
384 int next_idx, __u64 *cur_offset, void *buf,
389 if (len == 0 || len & (LLOG_CHUNK_SIZE - 1))
392 CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off "LPU64")\n",
393 next_idx, *cur_idx, *cur_offset);
395 while (*cur_offset < i_size_read(loghandle->lgh_file->f_dentry->d_inode)) {
396 struct llog_rec_hdr *rec, *last_rec;
397 struct llog_rec_tail *tail;
401 llog_skip_over(cur_offset, *cur_idx, next_idx);
403 /* read up to next LLOG_CHUNK_SIZE block */
405 llen = LLOG_CHUNK_SIZE - (*cur_offset & (LLOG_CHUNK_SIZE - 1));
406 rc = fsfilt_read_record(loghandle->lgh_ctxt->loc_exp->exp_obd,
407 loghandle->lgh_file, buf, llen,
410 CERROR("Cant read llog block at log id "DOSTID
411 "/%u offset "LPU64"\n",
412 POSTID(&loghandle->lgh_id.lgl_oi),
413 loghandle->lgh_id.lgl_ogen,
418 /* put number of bytes read into rc to make code simpler */
419 rc = *cur_offset - ppos;
421 /* signal the end of the valid buffer to llog_process */
422 memset(buf + rc, 0, len - rc);
425 if (rc == 0) /* end of file, nothing to do */
428 if (rc < sizeof(*tail)) {
429 CERROR("Invalid llog block at log id "DOSTID"/%u offset"
430 LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi),
431 loghandle->lgh_id.lgl_ogen, *cur_offset);
436 if (LLOG_REC_HDR_NEEDS_SWABBING(rec))
437 lustre_swab_llog_rec(rec);
439 tail = (struct llog_rec_tail *)(buf + rc -
440 sizeof(struct llog_rec_tail));
442 /* get the last record in block */
443 last_rec = (struct llog_rec_hdr *)(buf + rc -
444 le32_to_cpu(tail->lrt_len));
446 if (LLOG_REC_HDR_NEEDS_SWABBING(last_rec))
447 lustre_swab_llog_rec(last_rec);
448 LASSERT(last_rec->lrh_index == tail->lrt_index);
450 *cur_idx = tail->lrt_index;
452 /* this shouldn't happen */
453 if (tail->lrt_index == 0) {
454 CERROR("Invalid llog tail at log id "DOSTID"/%u offset "
455 LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi),
456 loghandle->lgh_id.lgl_ogen, *cur_offset);
459 if (tail->lrt_index < next_idx)
462 /* sanity check that the start of the new buffer is no farther
463 * than the record that we wanted. This shouldn't happen. */
464 if (rec->lrh_index > next_idx) {
465 CERROR("missed desired record? %u > %u\n",
466 rec->lrh_index, next_idx);
474 static int llog_lvfs_prev_block(const struct lu_env *env,
475 struct llog_handle *loghandle,
476 int prev_idx, void *buf, int len)
481 if (len == 0 || len & (LLOG_CHUNK_SIZE - 1))
484 CDEBUG(D_OTHER, "looking for log index %u\n", prev_idx);
486 cur_offset = LLOG_CHUNK_SIZE;
487 llog_skip_over(&cur_offset, 0, prev_idx);
489 while (cur_offset < i_size_read(loghandle->lgh_file->f_dentry->d_inode)) {
490 struct llog_rec_hdr *rec, *last_rec;
491 struct llog_rec_tail *tail;
492 loff_t ppos = cur_offset;
494 rc = fsfilt_read_record(loghandle->lgh_ctxt->loc_exp->exp_obd,
495 loghandle->lgh_file, buf, len,
498 CERROR("Cant read llog block at log id "DOSTID
499 "/%u offset "LPU64"\n",
500 POSTID(&loghandle->lgh_id.lgl_oi),
501 loghandle->lgh_id.lgl_ogen,
506 /* put number of bytes read into rc to make code simpler */
507 rc = cur_offset - ppos;
509 if (rc == 0) /* end of file, nothing to do */
512 if (rc < sizeof(*tail)) {
513 CERROR("Invalid llog block at log id "DOSTID"/%u offset"
514 LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi),
515 loghandle->lgh_id.lgl_ogen, cur_offset);
520 if (LLOG_REC_HDR_NEEDS_SWABBING(rec))
521 lustre_swab_llog_rec(rec);
523 tail = (struct llog_rec_tail *)(buf + rc -
524 sizeof(struct llog_rec_tail));
526 /* get the last record in block */
527 last_rec = (struct llog_rec_hdr *)(buf + rc -
528 le32_to_cpu(tail->lrt_len));
530 if (LLOG_REC_HDR_NEEDS_SWABBING(last_rec))
531 lustre_swab_llog_rec(last_rec);
532 LASSERT(last_rec->lrh_index == tail->lrt_index);
534 /* this shouldn't happen */
535 if (tail->lrt_index == 0) {
536 CERROR("Invalid llog tail at log id "DOSTID"/%u offset"
537 LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi),
538 loghandle->lgh_id.lgl_ogen, cur_offset);
541 if (tail->lrt_index < prev_idx)
544 /* sanity check that the start of the new buffer is no farther
545 * than the record that we wanted. This shouldn't happen. */
546 if (rec->lrh_index > prev_idx) {
547 CERROR("missed desired record? %u > %u\n",
548 rec->lrh_index, prev_idx);
556 static struct file *llog_filp_open(char *dir, char *name, int flags, int mode)
562 OBD_ALLOC(logname, PATH_MAX);
564 return ERR_PTR(-ENOMEM);
566 len = snprintf(logname, PATH_MAX, "%s/%s", dir, name);
567 if (len >= PATH_MAX - 1) {
568 filp = ERR_PTR(-ENAMETOOLONG);
570 filp = l_filp_open(logname, flags, mode);
571 if (IS_ERR(filp) && PTR_ERR(filp) != -ENOENT)
572 CERROR("logfile creation %s: %ld\n", logname,
575 OBD_FREE(logname, PATH_MAX);
579 static int llog_lvfs_open(const struct lu_env *env, struct llog_handle *handle,
580 struct llog_logid *logid, char *name,
581 enum llog_open_param open_param)
583 struct llog_ctxt *ctxt = handle->lgh_ctxt;
584 struct l_dentry *dchild = NULL;
585 struct obd_device *obd;
589 LASSERT(ctxt->loc_exp);
590 LASSERT(ctxt->loc_exp->exp_obd);
591 obd = ctxt->loc_exp->exp_obd;
595 dchild = obd_lvfs_fid2dentry(ctxt->loc_exp, &logid->lgl_oi,
597 if (IS_ERR(dchild)) {
598 rc = PTR_ERR(dchild);
599 CERROR("%s: error looking up logfile #"DOSTID "#%08x:"
600 " rc = %d\n", ctxt->loc_obd->obd_name,
601 POSTID(&logid->lgl_oi), logid->lgl_ogen, rc);
604 if (dchild->d_inode == NULL) {
607 CERROR("%s: nonexistent llog #"DOSTID"#%08x:"
608 "rc = %d\n", ctxt->loc_obd->obd_name,
609 POSTID(&logid->lgl_oi), logid->lgl_ogen, rc);
612 handle->lgh_file = l_dentry_open(&obd->obd_lvfs_ctxt, dchild,
613 O_RDWR | O_LARGEFILE);
615 if (IS_ERR(handle->lgh_file)) {
616 rc = PTR_ERR(handle->lgh_file);
617 handle->lgh_file = NULL;
618 CERROR("%s: error opening llog #"DOSTID"#%08x:"
619 "rc = %d\n", ctxt->loc_obd->obd_name,
620 POSTID(&logid->lgl_oi), logid->lgl_ogen, rc);
623 handle->lgh_id = *logid;
625 handle->lgh_file = llog_filp_open(MOUNT_CONFIGS_DIR, name,
626 O_RDWR | O_LARGEFILE, 0644);
627 if (IS_ERR(handle->lgh_file)) {
628 rc = PTR_ERR(handle->lgh_file);
629 handle->lgh_file = NULL;
630 if (rc == -ENOENT && open_param == LLOG_OPEN_NEW) {
631 OBD_ALLOC(handle->lgh_name, strlen(name) + 1);
632 if (handle->lgh_name)
633 strcpy(handle->lgh_name, name);
635 GOTO(out, rc = -ENOMEM);
641 lustre_build_llog_lvfs_oid(&handle->lgh_id,
642 handle->lgh_file->f_dentry->d_inode->i_ino,
643 handle->lgh_file->f_dentry->d_inode->i_generation);
646 LASSERTF(open_param == LLOG_OPEN_NEW, "%#x\n", open_param);
647 handle->lgh_file = NULL;
650 /* No new llog is expected but doesn't exist */
651 if (open_param != LLOG_OPEN_NEW && handle->lgh_file == NULL)
652 GOTO(out_name, rc = -ENOENT);
656 if (handle->lgh_name != NULL)
657 OBD_FREE(handle->lgh_name, strlen(name) + 1);
662 static int llog_lvfs_exist(struct llog_handle *handle)
664 return (handle->lgh_file != NULL);
667 /* This is a callback from the llog_* functions.
668 * Assumes caller has already pushed us into the kernel context. */
669 static int llog_lvfs_create(const struct lu_env *env,
670 struct llog_handle *handle,
673 struct llog_ctxt *ctxt = handle->lgh_ctxt;
674 struct obd_device *obd;
675 struct l_dentry *dchild = NULL;
677 struct obdo *oa = NULL;
679 int open_flags = O_RDWR | O_CREAT | O_LARGEFILE;
682 LASSERT(ctxt->loc_exp);
683 obd = ctxt->loc_exp->exp_obd;
684 LASSERT(handle->lgh_file == NULL);
686 if (handle->lgh_name) {
687 file = llog_filp_open(MOUNT_CONFIGS_DIR, handle->lgh_name,
690 return PTR_ERR(file);
692 lustre_build_llog_lvfs_oid(&handle->lgh_id,
693 file->f_dentry->d_inode->i_ino,
694 file->f_dentry->d_inode->i_generation);
695 handle->lgh_file = file;
701 ostid_set_seq_llog(&oa->o_oi);
702 oa->o_valid = OBD_MD_FLGENER | OBD_MD_FLGROUP;
704 rc = obd_create(NULL, ctxt->loc_exp, oa, NULL, NULL);
708 /* FIXME: rationalize the misuse of o_generation in
709 * this API along with mds_obd_{create,destroy}.
710 * Hopefully it is only an internal API issue. */
711 #define o_generation o_parent_oid
712 dchild = obd_lvfs_fid2dentry(ctxt->loc_exp, &oa->o_oi,
715 GOTO(out, rc = PTR_ERR(dchild));
717 file = l_dentry_open(&obd->obd_lvfs_ctxt, dchild, open_flags);
720 GOTO(out, rc = PTR_ERR(file));
721 handle->lgh_id.lgl_oi = oa->o_oi;
722 handle->lgh_id.lgl_ogen = oa->o_generation;
723 handle->lgh_file = file;
730 static int llog_lvfs_close(const struct lu_env *env,
731 struct llog_handle *handle)
735 if (handle->lgh_file == NULL)
737 rc = filp_close(handle->lgh_file, 0);
739 CERROR("%s: error closing llog #"DOSTID"#%08x: "
740 "rc = %d\n", handle->lgh_ctxt->loc_obd->obd_name,
741 POSTID(&handle->lgh_id.lgl_oi),
742 handle->lgh_id.lgl_ogen, rc);
743 handle->lgh_file = NULL;
744 if (handle->lgh_name) {
745 OBD_FREE(handle->lgh_name, strlen(handle->lgh_name) + 1);
746 handle->lgh_name = NULL;
751 static int llog_lvfs_destroy(const struct lu_env *env,
752 struct llog_handle *handle)
754 struct dentry *fdentry;
756 struct obd_device *obd = handle->lgh_ctxt->loc_exp->exp_obd;
762 dir = MOUNT_CONFIGS_DIR;
764 LASSERT(handle->lgh_file);
765 fdentry = handle->lgh_file->f_dentry;
766 inode = fdentry->d_parent->d_inode;
767 if (strcmp(fdentry->d_parent->d_name.name, dir) == 0) {
768 struct lvfs_run_ctxt saved;
769 struct vfsmount *mnt = mntget(handle->lgh_file->f_vfsmnt);
771 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
773 rc = llog_lvfs_close(env, handle);
775 mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT);
776 rc = ll_vfs_unlink(inode, fdentry, mnt);
777 mutex_unlock(&inode->i_mutex);
782 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
790 oa->o_oi = handle->lgh_id.lgl_oi;
791 oa->o_generation = handle->lgh_id.lgl_ogen;
793 oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLGENER;
795 rc = llog_lvfs_close(env, handle);
799 th = fsfilt_start_log(obd, inode, FSFILT_OP_UNLINK, NULL, 1);
801 CERROR("fsfilt_start failed: %ld\n", PTR_ERR(th));
802 GOTO(out, rc = PTR_ERR(th));
805 rc = obd_destroy(NULL, handle->lgh_ctxt->loc_exp, oa,
806 NULL, NULL, NULL, NULL);
808 rc1 = fsfilt_commit(obd, inode, th, 0);
809 if (rc == 0 && rc1 != 0)
816 static int llog_lvfs_declare_create(const struct lu_env *env,
817 struct llog_handle *res,
823 static int llog_lvfs_declare_write_rec(const struct lu_env *env,
824 struct llog_handle *loghandle,
825 struct llog_rec_hdr *rec,
826 int idx, struct thandle *th)
831 struct llog_operations llog_lvfs_ops = {
832 .lop_write_rec = llog_lvfs_write_rec,
833 .lop_next_block = llog_lvfs_next_block,
834 .lop_prev_block = llog_lvfs_prev_block,
835 .lop_read_header = llog_lvfs_read_header,
836 .lop_create = llog_lvfs_create,
837 .lop_destroy = llog_lvfs_destroy,
838 .lop_close = llog_lvfs_close,
839 .lop_open = llog_lvfs_open,
840 .lop_exist = llog_lvfs_exist,
841 .lop_declare_create = llog_lvfs_declare_create,
842 .lop_declare_write_rec = llog_lvfs_declare_write_rec,
844 EXPORT_SYMBOL(llog_lvfs_ops);
845 #else /* !__KERNEL__ */
846 struct llog_operations llog_lvfs_ops = {};