Whamcloud - gitweb
parallel llog init
[fs/lustre-release.git] / lustre / ptlrpc / llog_server.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/ptlrpc/llog_server.c
37  *
38  * remote api for llog - server side
39  *
40  * Author: Andreas Dilger <adilger@clusterfs.com>
41  */
42
43 #define DEBUG_SUBSYSTEM S_LOG
44
45 #ifndef EXPORT_SYMTAB
46 #define EXPORT_SYMTAB
47 #endif
48
49 #ifndef __KERNEL__
50 #include <liblustre.h>
51 #endif
52
53 #include <obd_class.h>
54 #include <lustre_log.h>
55 #include <lustre_net.h>
56 #include <libcfs/list.h>
57 #include <lustre_fsfilt.h>
58
59 #if defined(__KERNEL__) && defined(LUSTRE_LOG_SERVER)
60
61 int llog_origin_handle_create(struct ptlrpc_request *req)
62 {
63         struct obd_export    *exp = req->rq_export;
64         struct obd_device    *obd = exp->exp_obd;
65         struct obd_device    *disk_obd;
66         struct llog_handle   *loghandle;
67         struct llogd_body    *body;
68         struct lvfs_run_ctxt  saved;
69         struct llog_logid    *logid = NULL;
70         struct llog_ctxt     *ctxt;
71         char                 *name = NULL;
72         int                   rc, rc2;
73         ENTRY;
74
75         body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
76         if (body == NULL)
77                 RETURN(-EFAULT);
78
79         if (body->lgd_logid.lgl_oid > 0)
80                 logid = &body->lgd_logid;
81
82         if (req_capsule_field_present(&req->rq_pill, &RMF_NAME, RCL_CLIENT)) {
83                 name = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
84                 if (name == NULL)
85                         RETURN(-EFAULT);
86                 CDEBUG(D_INFO, "opening log %s\n", name);
87         }
88
89         ctxt = llog_get_context(obd, body->lgd_ctxt_idx);
90         if (ctxt == NULL)
91                 RETURN(-EINVAL);
92         disk_obd = ctxt->loc_exp->exp_obd;
93         push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
94
95         rc = llog_create(ctxt, &loghandle, logid, name);
96         if (rc)
97                 GOTO(out_pop, rc);
98
99         rc = req_capsule_server_pack(&req->rq_pill);
100         if (rc)
101                 GOTO(out_close, rc = -ENOMEM);
102
103         body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
104         body->lgd_logid = loghandle->lgh_id;
105
106 out_close:
107         rc2 = llog_close(loghandle);
108         if (!rc)
109                 rc = rc2;
110 out_pop:
111         pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
112         llog_ctxt_put(ctxt);
113         RETURN(rc);
114 }
115
116 int llog_origin_handle_destroy(struct ptlrpc_request *req)
117 {
118         struct obd_export    *exp = req->rq_export;
119         struct obd_device    *obd = exp->exp_obd;
120         struct obd_device    *disk_obd;
121         struct llog_handle   *loghandle;
122         struct llogd_body    *body;
123         struct lvfs_run_ctxt  saved;
124         struct llog_logid    *logid = NULL;
125         struct llog_ctxt     *ctxt;
126         __u32                 flags;
127         int                   rc;
128         ENTRY;
129
130         body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
131         if (body == NULL)
132                 RETURN(-EFAULT);
133
134         if (body->lgd_logid.lgl_oid > 0)
135                 logid = &body->lgd_logid;
136
137         ctxt = llog_get_context(obd, body->lgd_ctxt_idx);
138         if (ctxt == NULL)
139                 RETURN(-EINVAL);
140
141         disk_obd = ctxt->loc_exp->exp_obd;
142         push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
143
144         rc = llog_create(ctxt, &loghandle, logid, NULL);
145         if (rc)
146                 GOTO(out_pop, rc);
147
148         rc = req_capsule_server_pack(&req->rq_pill);
149         if (rc)
150                 GOTO(out_close, rc = -ENOMEM);
151
152         body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
153         body->lgd_logid = loghandle->lgh_id;
154         flags = body->lgd_llh_flags;
155         rc = llog_init_handle(loghandle, LLOG_F_IS_PLAIN, NULL);
156         if (rc)
157                 GOTO(out_close, rc);
158         rc = llog_destroy(loghandle);
159         if (rc)
160                 GOTO(out_close, rc);
161         llog_free_handle(loghandle);
162
163 out_close:
164         if (rc)
165                 llog_close(loghandle);
166 out_pop:
167         pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
168         llog_ctxt_put(ctxt);
169         RETURN(rc);
170 }
171
172 int llog_origin_handle_next_block(struct ptlrpc_request *req)
173 {
174         struct obd_export   *exp = req->rq_export;
175         struct obd_device   *obd = exp->exp_obd;
176         struct obd_device   *disk_obd;
177         struct llog_handle  *loghandle;
178         struct llogd_body   *body;
179         struct llogd_body   *repbody;
180         struct lvfs_run_ctxt saved;
181         struct llog_ctxt    *ctxt;
182         __u32                flags;
183         __u8                *buf;
184         void                *ptr;
185         int                  rc, rc2;
186         ENTRY;
187
188         body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
189         if (body == NULL)
190                 RETURN(-EFAULT);
191
192         OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
193         if (!buf)
194                 RETURN(-ENOMEM);
195
196         ctxt = llog_get_context(obd, body->lgd_ctxt_idx);
197         if (ctxt == NULL)
198                 GOTO(out_free, rc = -EINVAL);
199         disk_obd = ctxt->loc_exp->exp_obd;
200         push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
201
202         rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL);
203         if (rc)
204                 GOTO(out_pop, rc);
205
206         flags = body->lgd_llh_flags;
207         rc = llog_init_handle(loghandle, flags, NULL);
208         if (rc)
209                 GOTO(out_close, rc);
210
211         memset(buf, 0, LLOG_CHUNK_SIZE);
212         rc = llog_next_block(loghandle, &body->lgd_saved_index,
213                              body->lgd_index,
214                              &body->lgd_cur_offset, buf, LLOG_CHUNK_SIZE);
215         if (rc)
216                 GOTO(out_close, rc);
217
218         req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_SERVER,
219                              LLOG_CHUNK_SIZE);
220         rc = req_capsule_server_pack(&req->rq_pill);
221         if (rc)
222                 GOTO(out_close, rc = -ENOMEM);
223
224         repbody = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
225         *repbody = *body;
226
227         ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA);
228         memcpy(ptr, buf, LLOG_CHUNK_SIZE);
229
230 out_close:
231         rc2 = llog_close(loghandle);
232         if (!rc)
233                 rc = rc2;
234
235 out_pop:
236         pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
237         llog_ctxt_put(ctxt);
238 out_free:
239         OBD_FREE(buf, LLOG_CHUNK_SIZE);
240         RETURN(rc);
241 }
242
243 int llog_origin_handle_prev_block(struct ptlrpc_request *req)
244 {
245         struct obd_export    *exp = req->rq_export;
246         struct obd_device    *obd = exp->exp_obd;
247         struct llog_handle   *loghandle;
248         struct llogd_body    *body;
249         struct llogd_body    *repbody;
250         struct obd_device    *disk_obd;
251         struct lvfs_run_ctxt  saved;
252         struct llog_ctxt     *ctxt;
253         __u32                 flags;
254         __u8                 *buf;
255         void                 *ptr;
256         int                   rc, rc2;
257         ENTRY;
258
259         body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
260         if (body == NULL)
261                 RETURN(-EFAULT);
262
263         OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
264         if (!buf)
265                 RETURN(-ENOMEM);
266
267         ctxt = llog_get_context(obd, body->lgd_ctxt_idx);
268         LASSERT(ctxt != NULL);
269         disk_obd = ctxt->loc_exp->exp_obd;
270         push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
271
272         rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL);
273         if (rc)
274                 GOTO(out_pop, rc);
275
276         flags = body->lgd_llh_flags;
277         rc = llog_init_handle(loghandle, flags, NULL);
278         if (rc)
279                 GOTO(out_close, rc);
280
281         memset(buf, 0, LLOG_CHUNK_SIZE);
282         rc = llog_prev_block(loghandle, body->lgd_index,
283                              buf, LLOG_CHUNK_SIZE);
284         if (rc)
285                 GOTO(out_close, rc);
286
287         req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_SERVER,
288                              LLOG_CHUNK_SIZE);
289         rc = req_capsule_server_pack(&req->rq_pill);
290         if (rc)
291                 GOTO(out_close, rc = -ENOMEM);
292
293         repbody = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
294         *repbody = *body;
295
296         ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA);
297         memcpy(ptr, buf, LLOG_CHUNK_SIZE);
298
299 out_close:
300         rc2 = llog_close(loghandle);
301         if (!rc)
302                 rc = rc2;
303
304 out_pop:
305         pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
306         llog_ctxt_put(ctxt);
307         OBD_FREE(buf, LLOG_CHUNK_SIZE);
308         RETURN(rc);
309 }
310
311 int llog_origin_handle_read_header(struct ptlrpc_request *req)
312 {
313         struct obd_export    *exp = req->rq_export;
314         struct obd_device    *obd = exp->exp_obd;
315         struct obd_device    *disk_obd;
316         struct llog_handle   *loghandle;
317         struct llogd_body    *body;
318         struct llog_log_hdr  *hdr;
319         struct lvfs_run_ctxt  saved;
320         struct llog_ctxt     *ctxt;
321         __u32                 flags;
322         int                   rc, rc2;
323         ENTRY;
324
325         body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
326         if (body == NULL)
327                 RETURN(-EFAULT);
328
329         ctxt = llog_get_context(obd, body->lgd_ctxt_idx);
330         if (ctxt == NULL)
331                 RETURN(-EINVAL);
332         disk_obd = ctxt->loc_exp->exp_obd;
333         push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
334
335         rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL);
336         if (rc)
337                 GOTO(out_pop, rc);
338
339         /* init_handle reads the header */
340         flags = body->lgd_llh_flags;
341         rc = llog_init_handle(loghandle, flags, NULL);
342         if (rc)
343                 GOTO(out_close, rc);
344
345         rc = req_capsule_server_pack(&req->rq_pill);
346         if (rc)
347                 GOTO(out_close, rc = -ENOMEM);
348
349         hdr = req_capsule_server_get(&req->rq_pill, &RMF_LLOG_LOG_HDR);
350         *hdr = *loghandle->lgh_hdr;
351
352 out_close:
353         rc2 = llog_close(loghandle);
354         if (!rc)
355                 rc = rc2;
356 out_pop:
357         pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
358         llog_ctxt_put(ctxt);
359         RETURN(rc);
360 }
361
362 int llog_origin_handle_close(struct ptlrpc_request *req)
363 {
364         int rc;
365
366         rc = 0;
367
368         RETURN(rc);
369 }
370
371 int llog_origin_handle_cancel(struct ptlrpc_request *req)
372 {
373         struct obd_device *obd = req->rq_export->exp_obd;
374         struct obd_device *disk_obd;
375         struct llog_cookie *logcookies;
376         struct llog_ctxt *ctxt = NULL;
377         int num_cookies, rc = 0, err, i;
378         struct lvfs_run_ctxt saved;
379         struct llog_handle *cathandle;
380         struct inode *inode;
381         void *handle;
382         ENTRY;
383
384         logcookies = req_capsule_client_get(&req->rq_pill, &RMF_LOGCOOKIES);
385         num_cookies = req_capsule_get_size(&req->rq_pill, &RMF_LOGCOOKIES,
386                                            RCL_CLIENT) / sizeof(*logcookies);
387         if (logcookies == NULL || num_cookies == 0) {
388                 DEBUG_REQ(D_HA, req, "no cookies sent");
389                 RETURN(-EFAULT);
390         }
391
392         ctxt = llog_get_context(obd, logcookies->lgc_subsys);
393         if (ctxt == NULL) {
394                 CWARN("llog subsys not setup or already cleanup\n");
395                 RETURN(-ENOENT);
396         }
397
398         disk_obd = ctxt->loc_exp->exp_obd;
399         push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
400         for (i = 0; i < num_cookies; i++, logcookies++) {
401                 cathandle = ctxt->loc_handle;
402                 LASSERT(cathandle != NULL);
403                 inode = cathandle->lgh_file->f_dentry->d_inode;
404
405                 handle = fsfilt_start_log(disk_obd, inode,
406                                           FSFILT_OP_CANCEL_UNLINK, NULL, 1);
407                 if (IS_ERR(handle)) {
408                         CERROR("fsfilt_start failed: %ld\n", PTR_ERR(handle));
409                         GOTO(pop_ctxt, rc = PTR_ERR(handle));
410                 }
411
412                 rc = llog_cat_cancel_records(cathandle, 1, logcookies);
413
414                 err = fsfilt_commit(disk_obd, inode, handle, 0);
415                 if (err) {
416                         CERROR("error committing transaction: %d\n", err);
417                         if (!rc)
418                                 rc = err;
419                         GOTO(pop_ctxt, rc);
420                 }
421         }
422 pop_ctxt:
423         pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
424         if (rc)
425                 CERROR("cancel %d llog-records failed: %d\n", num_cookies, rc);
426         else
427                 CDEBUG(D_RPCTRACE, "cancel %d llog-records\n", num_cookies);
428
429         llog_ctxt_put(ctxt);
430         RETURN(rc);
431 }
432 EXPORT_SYMBOL(llog_origin_handle_cancel);
433
434 static int llog_catinfo_config(struct obd_device *obd, char *buf, int buf_len,
435                                char *client)
436 {
437         struct mds_obd       *mds = &obd->u.mds;
438         struct llog_ctxt     *ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
439         struct lvfs_run_ctxt  saved;
440         struct llog_handle   *handle = NULL;
441         char                  name[4][64];
442         int                   rc, i, l, remains = buf_len;
443         char                 *out = buf;
444
445         if (ctxt == NULL || mds == NULL)
446                 GOTO(release_ctxt, rc = -EOPNOTSUPP);
447
448         push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
449
450         sprintf(name[0], "%s", mds->mds_profile);
451         sprintf(name[1], "%s-clean", mds->mds_profile);
452         sprintf(name[2], "%s", client);
453         sprintf(name[3], "%s-clean", client);
454
455         for (i = 0; i < 4; i++) {
456                 int index, uncanceled = 0;
457                 rc = llog_create(ctxt, &handle, NULL, name[i]);
458                 if (rc)
459                         GOTO(out_pop, rc);
460                 rc = llog_init_handle(handle, 0, NULL);
461                 if (rc) {
462                         llog_close(handle);
463                         GOTO(out_pop, rc = -ENOENT);
464                 }
465
466                 for (index = 1; index < (LLOG_BITMAP_BYTES * 8); index ++) {
467                         if (ext2_test_bit(index, handle->lgh_hdr->llh_bitmap))
468                                 uncanceled++;
469                 }
470
471                 l = snprintf(out, remains, "[Log Name]: %s\nLog Size: %llu\n"
472                              "Last Index: %d\nUncanceled Records: %d\n\n",
473                              name[i],
474                              i_size_read(handle->lgh_file->f_dentry->d_inode),
475                              handle->lgh_last_idx, uncanceled);
476                 out += l;
477                 remains -= l;
478
479                 llog_close(handle);
480                 if (remains <= 0)
481                         break;
482         }
483 out_pop:
484         pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
485 release_ctxt:
486         llog_ctxt_put(ctxt);
487         RETURN(rc);
488 }
489
490 struct cb_data {
491         struct llog_ctxt *ctxt;
492         char *out;
493         int  remains;
494         int  init;
495 };
496
497 static int llog_catinfo_cb(struct llog_handle *cat,
498                            struct llog_rec_hdr *rec, void *data)
499 {
500         static char *out = NULL;
501         static int remains = 0;
502         struct llog_ctxt *ctxt = NULL;
503         struct llog_handle *handle;
504         struct llog_logid *logid;
505         struct llog_logid_rec *lir;
506         int l, rc, index, count = 0;
507         struct cb_data *cbd = (struct cb_data*)data;
508
509         if (cbd->init) {
510                 out = cbd->out;
511                 remains = cbd->remains;
512                 cbd->init = 0;
513         }
514
515         if (!(cat->lgh_hdr->llh_flags & LLOG_F_IS_CAT))
516                 RETURN(-EINVAL);
517
518         if (!cbd->ctxt)
519                 RETURN(-EINVAL);
520         
521         lir = (struct llog_logid_rec *)rec;
522         logid = &lir->lid_id;
523         rc = llog_create(ctxt, &handle, logid, NULL);
524         if (rc)
525                 RETURN(-EINVAL);
526         rc = llog_init_handle(handle, 0, NULL);
527         if (rc)
528                 GOTO(out_close, rc);
529
530         for (index = 1; index < (LLOG_BITMAP_BYTES * 8); index++) {
531                 if (ext2_test_bit(index, handle->lgh_hdr->llh_bitmap))
532                         count++;
533         }
534
535         l = snprintf(out, remains, "\t[Log ID]: #"LPX64"#"LPX64"#%08x\n"
536                      "\tLog Size: %llu\n\tLast Index: %d\n"
537                      "\tUncanceled Records: %d\n",
538                      logid->lgl_oid, logid->lgl_ogr, logid->lgl_ogen,
539                      i_size_read(handle->lgh_file->f_dentry->d_inode),
540                      handle->lgh_last_idx, count);
541         out += l;
542         remains -= l;
543         cbd->out = out;
544         cbd->remains = remains;
545         if (remains <= 0) {
546                 CWARN("Not enough memory\n");
547                 rc = -ENOMEM;
548         }
549
550 out_close:
551         llog_close(handle);
552         RETURN(rc);
553 }
554
555 static int llog_catinfo_deletions(struct obd_device *obd, char *buf,
556                                   int buf_len)
557 {
558         struct mds_obd *mds = &obd->u.mds;
559         struct llog_handle *handle;
560         struct lvfs_run_ctxt saved;
561         int size, i, count;
562         struct llog_catid *idarray;
563         char name[32] = CATLIST;
564         struct cb_data data;
565         struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
566         int rc;
567
568         if (ctxt == NULL || mds == NULL)
569                 GOTO(release_ctxt, rc = -EOPNOTSUPP);
570
571         count = mds->mds_lov_desc.ld_tgt_count;
572         size = sizeof(*idarray) * count;
573
574         OBD_VMALLOC(idarray, size);
575         if (!idarray)
576                 GOTO(release_ctxt, rc = -ENOMEM);
577
578         rc = llog_get_cat_list(obd, obd, name, 0, count, idarray);
579         if (rc)
580                 GOTO(out_free, rc);
581
582         push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
583
584         data.ctxt = ctxt;
585         data.out = buf;
586         data.remains = buf_len;
587         for (i = 0; i < count; i++) {
588                 int l, index, uncanceled = 0;
589
590                 rc = llog_create(ctxt, &handle, &idarray[i].lci_logid, NULL);
591                 if (rc)
592                         GOTO(out_pop, rc);
593                 rc = llog_init_handle(handle, 0, NULL);
594                 if (rc) {
595                         llog_close(handle);
596                         GOTO(out_pop, rc = -ENOENT);
597                 }
598                 for (index = 1; index < (LLOG_BITMAP_BYTES * 8); index++) {
599                         if (ext2_test_bit(index, handle->lgh_hdr->llh_bitmap))
600                                 uncanceled++;
601                 }
602                 l = snprintf(data.out, data.remains,
603                              "\n[Catlog ID]: #"LPX64"#"LPX64"#%08x  "
604                              "[Log Count]: %d\n",
605                              idarray[i].lci_logid.lgl_oid,
606                              idarray[i].lci_logid.lgl_ogr,
607                              idarray[i].lci_logid.lgl_ogen, uncanceled);
608
609                 data.out += l;
610                 data.remains -= l;
611                 data.init = 1;
612
613                 llog_process(handle, llog_catinfo_cb, &data, NULL);
614                 llog_close(handle);
615
616                 if (data.remains <= 0)
617                         break;
618         }
619         EXIT;
620 out_pop:
621         pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
622 out_free:
623         OBD_VFREE(idarray, size);
624 release_ctxt:
625         llog_ctxt_put(ctxt);
626
627         return(rc);
628 }
629
630 int llog_catinfo(struct ptlrpc_request *req)
631 {
632         struct obd_export *exp = req->rq_export;
633         struct obd_device *obd = exp->exp_obd;
634         char              *keyword;
635         char              *buf, *reply;
636         int                rc;
637
638         OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
639         if (buf == NULL)
640                 return -ENOMEM;
641         memset(buf, 0, LLOG_CHUNK_SIZE);
642
643         keyword = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
644         LASSERT(keyword);
645
646         if (strcmp(keyword, "config") == 0) {
647                 char *client = req_capsule_client_get(&req->rq_pill,
648                                                       &RMF_STRING);
649
650                 LASSERT(client);
651                 rc = llog_catinfo_config(obd, buf, LLOG_CHUNK_SIZE, client);
652         } else if (strcmp(keyword, "deletions") == 0) {
653                 rc = llog_catinfo_deletions(obd, buf, LLOG_CHUNK_SIZE);
654         } else {
655                 rc = -EOPNOTSUPP;
656         }
657
658         req_capsule_set_size(&req->rq_pill, &RMF_STRING, RCL_SERVER,
659                              LLOG_CHUNK_SIZE);
660         rc = req_capsule_server_pack(&req->rq_pill);
661         if (rc)
662                 GOTO(out_free, rc = -ENOMEM);
663
664         reply = req_capsule_server_get(&req->rq_pill, &RMF_STRING);
665         if (strlen(buf) == 0)
666                 sprintf(buf, "%s", "No log informations\n");
667         memcpy(reply, buf, LLOG_CHUNK_SIZE);
668
669 out_free:
670         OBD_FREE(buf, LLOG_CHUNK_SIZE);
671         return rc;
672 }
673
674 #else /* !__KERNEL__ */
675 int llog_origin_handle_create(struct ptlrpc_request *req)
676 {
677         LBUG();
678         return 0;
679 }
680
681 int llog_origin_handle_destroy(struct ptlrpc_request *req)
682 {
683         LBUG();
684         return 0;
685 }
686
687 int llog_origin_handle_next_block(struct ptlrpc_request *req)
688 {
689         LBUG();
690         return 0;
691 }
692 int llog_origin_handle_prev_block(struct ptlrpc_request *req)
693 {
694         LBUG();
695         return 0;
696 }
697 int llog_origin_handle_read_header(struct ptlrpc_request *req)
698 {
699         LBUG();
700         return 0;
701 }
702 int llog_origin_handle_close(struct ptlrpc_request *req)
703 {
704         LBUG();
705         return 0;
706 }
707 int llog_origin_handle_cancel(struct ptlrpc_request *req)
708 {
709         LBUG();
710         return 0;
711 }
712 #endif