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