Whamcloud - gitweb
land b_inodebits
[fs/lustre-release.git] / lustre / llite / dir.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 1992, 1993, 1994, 1995
5  * Remy Card (card@masi.ibp.fr)
6  * Laboratoire MASI - Institut Blaise Pascal
7  * Universite Pierre et Marie Curie (Paris VI)
8  *
9  *  from
10  *
11  *  linux/fs/minix/dir.c
12  *  linux/fs/ext2/dir.c
13  *
14  *  Copyright (C) 1991, 1992  Linus Torvalds
15  *
16  *  ext2 directory handling functions
17  *
18  *  Big-endian to little-endian byte-swapping/bitmaps by
19  *        David S. Miller (davem@caip.rutgers.edu), 1995
20  *
21  *  All code that works with directory layout had been switched to pagecache
22  *  and moved here. AV
23  *
24  *  Adapted for Lustre Light
25  *  Copyright (C) 2002-2003, Cluster File Systems, Inc.
26  *
27  */
28
29 #include <linux/fs.h>
30 #include <linux/ext2_fs.h>
31 #include <linux/pagemap.h>
32 #include <linux/mm.h>
33 #include <linux/version.h>
34 #include <linux/smp_lock.h>
35 #include <asm/uaccess.h>
36 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
37 # include <linux/locks.h>   // for wait_on_buffer
38 #else
39 # include <linux/buffer_head.h>   // for wait_on_buffer
40 #endif
41
42 #define DEBUG_SUBSYSTEM S_LLITE
43
44 #include <linux/obd_support.h>
45 #include <linux/obd_class.h>
46 #include <linux/lustre_lib.h>
47 #include <linux/lustre_idl.h>
48 #include <linux/lustre_mds.h>
49 #include <linux/lustre_lite.h>
50 #include <linux/lustre_dlm.h>
51 #include "llite_internal.h"
52
53 typedef struct ext2_dir_entry_2 ext2_dirent;
54
55 #define PageChecked(page)        test_bit(PG_checked, &(page)->flags)
56 #define SetPageChecked(page)     set_bit(PG_checked, &(page)->flags)
57
58 /* returns the page unlocked, but with a reference */
59 static int ll_dir_readpage(struct file *file, struct page *page)
60 {
61         struct inode *inode = page->mapping->host;
62         struct ll_fid mdc_fid;
63         __u64 offset;
64         struct ptlrpc_request *request;
65         struct mds_body *body;
66         int rc = 0;
67         ENTRY;
68
69         CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
70                inode->i_generation, inode);
71
72         mdc_pack_fid(&mdc_fid, inode->i_ino, inode->i_generation, S_IFDIR);
73
74         offset = page->index << PAGE_SHIFT;
75         rc = mdc_readpage(ll_i2sbi(inode)->ll_mdc_exp, &mdc_fid,
76                           offset, page, &request);
77         if (!rc) {
78                 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body));
79                 LASSERT (body != NULL);         /* checked by mdc_readpage() */
80                 LASSERT_REPSWABBED (request, 0); /* swabbed by mdc_readpage() */
81
82                 inode->i_size = body->size;
83                 SetPageUptodate(page);
84         }
85         ptlrpc_req_finished(request);
86
87         unlock_page(page);
88         EXIT;
89         return rc;
90 }
91
92 struct address_space_operations ll_dir_aops = {
93         readpage: ll_dir_readpage,
94 };
95
96 /*
97  * ext2 uses block-sized chunks. Arguably, sector-sized ones would be
98  * more robust, but we have what we have
99  */
100 static inline unsigned ext2_chunk_size(struct inode *inode)
101 {
102         return inode->i_sb->s_blocksize;
103 }
104
105 static inline void ext2_put_page(struct page *page)
106 {
107         kunmap(page);
108         page_cache_release(page);
109 }
110
111 static inline unsigned long dir_pages(struct inode *inode)
112 {
113         return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
114 }
115
116
117 static void ext2_check_page(struct page *page)
118 {
119         struct inode *dir = page->mapping->host;
120         unsigned chunk_size = ext2_chunk_size(dir);
121         char *kaddr = page_address(page);
122         //      u32 max_inumber = le32_to_cpu(sb->u.ext2_sb.s_es->s_inodes_count);
123         unsigned offs, rec_len;
124         unsigned limit = PAGE_CACHE_SIZE;
125         ext2_dirent *p;
126         char *error;
127
128         if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
129                 limit = dir->i_size & ~PAGE_CACHE_MASK;
130                 if (limit & (chunk_size - 1)) {
131                         CERROR("limit %d dir size %lld index %ld\n",
132                                limit, dir->i_size, page->index);
133                         goto Ebadsize;
134                 }
135                 for (offs = limit; offs<PAGE_CACHE_SIZE; offs += chunk_size) {
136                         ext2_dirent *p = (ext2_dirent*)(kaddr + offs);
137                         p->rec_len = cpu_to_le16(chunk_size);
138                         p->name_len = 0;
139                         p->inode = 0;
140                 }
141                 if (!limit)
142                         goto out;
143         }
144         for (offs = 0; offs <= limit - EXT2_DIR_REC_LEN(1); offs += rec_len) {
145                 p = (ext2_dirent *)(kaddr + offs);
146                 rec_len = le16_to_cpu(p->rec_len);
147
148                 if (rec_len < EXT2_DIR_REC_LEN(1))
149                         goto Eshort;
150                 if (rec_len & 3)
151                         goto Ealign;
152                 if (rec_len < EXT2_DIR_REC_LEN(p->name_len))
153                         goto Enamelen;
154                 if (((offs + rec_len - 1) ^ offs) & ~(chunk_size-1))
155                         goto Espan;
156                 //              if (le32_to_cpu(p->inode) > max_inumber)
157                 //goto Einumber;
158         }
159         if (offs != limit)
160                 goto Eend;
161 out:
162         SetPageChecked(page);
163         return;
164
165         /* Too bad, we had an error */
166
167 Ebadsize:
168         CERROR("ext2_check_page"
169                 "size of directory #%lu is not a multiple of chunk size\n",
170                 dir->i_ino
171         );
172         goto fail;
173 Eshort:
174         error = "rec_len is smaller than minimal";
175         goto bad_entry;
176 Ealign:
177         error = "unaligned directory entry";
178         goto bad_entry;
179 Enamelen:
180         error = "rec_len is too small for name_len";
181         goto bad_entry;
182 Espan:
183         error = "directory entry across blocks";
184         goto bad_entry;
185         //Einumber:
186         // error = "inode out of bounds";
187 bad_entry:
188         CERROR("ext2_check_page: bad entry in directory #%lu: %s - "
189                 "offset=%lu+%u, inode=%lu, rec_len=%d, name_len=%d",
190                 dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT), offs,
191                 (unsigned long) le32_to_cpu(p->inode),
192                 rec_len, p->name_len);
193         goto fail;
194 Eend:
195         p = (ext2_dirent *)(kaddr + offs);
196         CERROR("ext2_check_page"
197                 "entry in directory #%lu spans the page boundary"
198                 "offset=%lu, inode=%lu",
199                 dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs,
200                 (unsigned long) le32_to_cpu(p->inode));
201 fail:
202         SetPageChecked(page);
203         SetPageError(page);
204         LBUG();
205 }
206
207 static struct page *ll_get_dir_page(struct inode *dir, unsigned long n)
208 {
209         struct ldlm_res_id res_id =
210                 { .name = { dir->i_ino, (__u64)dir->i_generation} };
211         struct lustre_handle lockh;
212         struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_mdc_exp);
213         struct address_space *mapping = dir->i_mapping;
214         struct page *page;
215         ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_UPDATE } };
216         int rc;
217
218         rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED,
219                              &res_id, LDLM_IBITS, &policy, LCK_PR, &lockh);
220         if (!rc) {
221                 struct lookup_intent it = { .it_op = IT_READDIR };
222                 struct ptlrpc_request *request;
223                 struct mdc_op_data data;
224
225                 ll_prepare_mdc_op_data(&data, dir, NULL, NULL, 0, 0);
226
227                 rc = mdc_enqueue(ll_i2sbi(dir)->ll_mdc_exp, LDLM_IBITS, &it,
228                                  LCK_PR, &data, &lockh, NULL, 0,
229                                  ldlm_completion_ast, ll_mdc_blocking_ast, dir);
230
231                 request = (struct ptlrpc_request *)it.d.lustre.it_data;
232                 if (request)
233                         ptlrpc_req_finished(request);
234                 if (rc < 0) {
235                         CERROR("lock enqueue: rc: %d\n", rc);
236                         return ERR_PTR(rc);
237                 }
238         }
239         ldlm_lock_dump_handle(D_OTHER, &lockh);
240
241         page = read_cache_page(mapping, n,
242                                (filler_t*)mapping->a_ops->readpage, NULL);
243         if (!IS_ERR(page)) {
244                 wait_on_page(page);
245                 (void)kmap(page);
246                 if (!PageUptodate(page))
247                         goto fail;
248                 if (!PageChecked(page))
249                         ext2_check_page(page);
250                 if (PageError(page))
251                         goto fail;
252         }
253
254 out_unlock:
255         ldlm_lock_decref(&lockh, LCK_PR);
256         return page;
257
258 fail:
259         ext2_put_page(page);
260         page = ERR_PTR(-EIO);
261         goto out_unlock;
262 }
263
264 /*
265  * p is at least 6 bytes before the end of page
266  */
267 static inline ext2_dirent *ext2_next_entry(ext2_dirent *p)
268 {
269         return (ext2_dirent *)((char*)p + le16_to_cpu(p->rec_len));
270 }
271
272 static inline unsigned
273 ext2_validate_entry(char *base, unsigned offset, unsigned mask)
274 {
275         ext2_dirent *de = (ext2_dirent*)(base + offset);
276         ext2_dirent *p = (ext2_dirent*)(base + (offset&mask));
277         while ((char*)p < (char*)de)
278                 p = ext2_next_entry(p);
279         return (char *)p - base;
280 }
281
282 static unsigned char ext2_filetype_table[EXT2_FT_MAX] = {
283         [EXT2_FT_UNKNOWN]       DT_UNKNOWN,
284         [EXT2_FT_REG_FILE]      DT_REG,
285         [EXT2_FT_DIR]           DT_DIR,
286         [EXT2_FT_CHRDEV]        DT_CHR,
287         [EXT2_FT_BLKDEV]        DT_BLK,
288         [EXT2_FT_FIFO]          DT_FIFO,
289         [EXT2_FT_SOCK]          DT_SOCK,
290         [EXT2_FT_SYMLINK]       DT_LNK,
291 };
292
293
294 int ll_readdir(struct file * filp, void * dirent, filldir_t filldir)
295 {
296         struct inode *inode = filp->f_dentry->d_inode;
297         loff_t pos = filp->f_pos;
298         // XXX struct super_block *sb = inode->i_sb;
299         unsigned offset = pos & ~PAGE_CACHE_MASK;
300         unsigned long n = pos >> PAGE_CACHE_SHIFT;
301         unsigned long npages = dir_pages(inode);
302         unsigned chunk_mask = ~(ext2_chunk_size(inode)-1);
303         unsigned char *types = NULL;
304         int need_revalidate = (filp->f_version != inode->i_version);
305         int rc = 0;
306         ENTRY;
307
308         CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %llu/%llu\n",
309                inode->i_ino, inode->i_generation, inode, pos, inode->i_size);
310
311         if (pos > inode->i_size - EXT2_DIR_REC_LEN(1))
312                 RETURN(0);
313
314         types = ext2_filetype_table;
315
316         for ( ; n < npages; n++, offset = 0) {
317                 char *kaddr, *limit;
318                 ext2_dirent *de;
319                 struct page *page;
320
321                 CDEBUG(D_EXT2,"read %lu of dir %lu/%u page %lu/%lu size %llu\n",
322                        PAGE_CACHE_SIZE, inode->i_ino, inode->i_generation,
323                        n, npages, inode->i_size);
324                 page = ll_get_dir_page(inode, n);
325
326                 /* size might have been updated by mdc_readpage */
327                 npages = dir_pages(inode);
328
329                 if (IS_ERR(page)) {
330                         rc = PTR_ERR(page);
331                         CERROR("error reading dir %lu/%u page %lu: rc %d\n",
332                                inode->i_ino, inode->i_generation, n, rc);
333                         continue;
334                 }
335
336                 kaddr = page_address(page);
337                 if (need_revalidate) {
338                         offset = ext2_validate_entry(kaddr, offset, chunk_mask);
339                         need_revalidate = 0;
340                 }
341                 de = (ext2_dirent *)(kaddr+offset);
342                 limit = kaddr + PAGE_CACHE_SIZE - EXT2_DIR_REC_LEN(1);
343                 for ( ;(char*)de <= limit; de = ext2_next_entry(de)) {
344                         if (de->inode) {
345                                 int over;
346                                 unsigned char d_type = DT_UNKNOWN;
347
348                                 rc = 0; /* no error if we return something */
349                                 if (types && de->file_type < EXT2_FT_MAX)
350                                         d_type = types[de->file_type];
351
352                                 offset = (char *)de - kaddr;
353                                 over = filldir(dirent, de->name, de->name_len,
354                                                (n<<PAGE_CACHE_SHIFT) | offset,
355                                                le32_to_cpu(de->inode), d_type);
356                                 if (over) {
357                                         ext2_put_page(page);
358                                         GOTO(done, rc);
359                                 }
360                         }
361                 }
362                 ext2_put_page(page);
363         }
364
365 done:
366         filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset;
367         filp->f_version = inode->i_version;
368         update_atime(inode);
369         RETURN(rc);
370 }
371
372 static int ll_dir_ioctl(struct inode *inode, struct file *file,
373                         unsigned int cmd, unsigned long arg)
374 {
375         struct ll_sb_info *sbi = ll_i2sbi(inode);
376         struct obd_ioctl_data *data;
377         ENTRY;
378
379         CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), cmd=%#x\n",
380                inode->i_ino, inode->i_generation, inode, cmd);
381
382         if (_IOC_TYPE(cmd) == 'T') /* tty ioctls */
383                 return -ENOTTY;
384
385         lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_IOCTL);
386         switch(cmd) {
387         case EXT3_IOC_GETFLAGS:
388         case EXT3_IOC_SETFLAGS:
389                 RETURN(ll_iocontrol(inode, file, cmd, arg));
390         case IOC_MDC_LOOKUP: {
391                 struct ptlrpc_request *request = NULL;
392                 struct ll_fid fid;
393                 char *buf = NULL;
394                 char *filename;
395                 int namelen, rc, len = 0;
396                 unsigned long valid;
397
398                 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
399                 if (rc)
400                         RETURN(rc);
401                 data = (void *)buf;
402
403                 filename = data->ioc_inlbuf1;
404                 namelen = data->ioc_inllen1;
405
406                 if (namelen < 1) {
407                         CDEBUG(D_INFO, "IOC_MDC_LOOKUP missing filename\n");
408                         GOTO(out, rc = -EINVAL);
409                 }
410
411                 valid = OBD_MD_FLID;
412                 ll_inode2fid(&fid, inode);
413                 rc = mdc_getattr_name(sbi->ll_mdc_exp, &fid,
414                                       filename, namelen, valid, 0, &request);
415                 if (rc < 0) {
416                         CDEBUG(D_INFO, "mdc_getattr_name: %d\n", rc);
417                         GOTO(out, rc);
418                 }
419
420                 ptlrpc_req_finished(request);
421
422                 EXIT;
423         out:
424                 obd_ioctl_freedata(buf, len);
425                 return rc;
426         }
427         case LL_IOC_LOV_SETSTRIPE: {
428                 struct ptlrpc_request *request = NULL;
429                 struct mdc_op_data op_data;
430                 struct iattr attr = { 0 };
431                 struct lov_user_md lum, *lump = (struct lov_user_md *)arg;
432                 int rc = 0;
433
434                 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
435
436                 LASSERT(sizeof(lum) == sizeof(*lump));
437                 LASSERT(sizeof(lum.lmm_objects[0]) ==
438                         sizeof(lump->lmm_objects[0]));
439                 rc = copy_from_user(&lum, lump, sizeof(lum));
440                 if (rc)
441                         return(-EFAULT);
442
443                 if (lum.lmm_magic != LOV_USER_MAGIC)
444                         RETURN(-EINVAL);
445
446                 rc = mdc_setattr(sbi->ll_mdc_exp, &op_data,
447                                  &attr, &lum, sizeof(lum), NULL, 0, &request);
448                 if (rc) {
449                         ptlrpc_req_finished(request);
450                         if (rc != -EPERM && rc != -EACCES)
451                                 CERROR("mdc_setattr fails: rc = %d\n", rc);
452                         return rc;
453                 }
454                 ptlrpc_req_finished(request);
455
456                 return rc;
457         }
458         case LL_IOC_LOV_GETSTRIPE: {
459                 struct ptlrpc_request *request = NULL;
460                 struct lov_user_md *lump = (struct lov_user_md *)arg;
461                 struct lov_mds_md *lmm;
462                 struct ll_fid fid;
463                 struct mds_body *body;
464                 unsigned long valid = 0;
465                 int rc, lmmsize;
466
467                 valid |= OBD_MD_FLDIREA;
468
469                 ll_inode2fid(&fid, inode);
470                 rc = mdc_getattr(sbi->ll_mdc_exp, &fid, valid,
471                                  obd_size_diskmd(sbi->ll_osc_exp, NULL),
472                                  &request);
473                 if (rc < 0) {
474                         CDEBUG(D_INFO, "mdc_getattr failed: rc = %d\n", rc);
475                         RETURN(rc);
476                 }
477
478                 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
479                 LASSERT(body != NULL);         /* checked by mdc_getattr_name */
480                 LASSERT_REPSWABBED(request, 0);/* swabbed by mdc_getattr_name */
481
482                 lmmsize = body->eadatasize;
483                 if (lmmsize == 0)
484                         GOTO(out_get, rc = -ENODATA);
485
486                 lmm = lustre_msg_buf(request->rq_repmsg, 1, lmmsize);
487                 LASSERT(lmm != NULL);
488                 LASSERT_REPSWABBED(request, 1);
489                 rc = copy_to_user(lump, lmm, lmmsize);
490                 if (rc)
491                         GOTO(out_get, rc = -EFAULT);
492
493                 EXIT;
494         out_get:
495                 ptlrpc_req_finished(request);
496                 RETURN(rc);
497         }
498         case IOC_MDC_GETSTRIPE: {
499                 struct ptlrpc_request *request = NULL;
500                 struct ll_fid fid;
501                 struct mds_body *body;
502                 struct lov_user_md *lump = (struct lov_user_md *)arg;
503                 struct lov_mds_md *lmm;
504                 char *filename;
505                 int rc, lmmsize;
506
507                 filename = getname((const char *)arg);
508                 if (IS_ERR(filename))
509                         RETURN(PTR_ERR(filename));
510
511                 ll_inode2fid(&fid, inode);
512                 rc = mdc_getattr_name(sbi->ll_mdc_exp, &fid, filename,
513                                       strlen(filename)+1, OBD_MD_FLEASIZE,
514                                       obd_size_diskmd(sbi->ll_osc_exp, NULL),
515                                       &request);
516                 if (rc < 0) {
517                         CDEBUG(D_INFO, "mdc_getattr_name failed on %s: rc %d\n",
518                                filename, rc);
519                         GOTO(out_name, rc);
520                 }
521
522                 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body));
523                 LASSERT(body != NULL);         /* checked by mdc_getattr_name */
524                 LASSERT_REPSWABBED(request, 0);/* swabbed by mdc_getattr_name */
525
526                 lmmsize = body->eadatasize;
527
528                 if (!(body->valid & OBD_MD_FLEASIZE) || lmmsize == 0)
529                         GOTO(out_req, rc = -ENODATA);
530
531                 if (lmmsize > 4096)
532                         GOTO(out_req, rc = -EFBIG);
533
534                 lmm = lustre_msg_buf(request->rq_repmsg, 1, lmmsize);
535                 LASSERT(lmm != NULL);
536                 LASSERT_REPSWABBED(request, 1);
537
538                 rc = copy_to_user(lump, lmm, lmmsize);
539                 if (rc)
540                         GOTO(out_req, rc = -EFAULT);
541
542                 EXIT;
543         out_req:
544                 ptlrpc_req_finished(request);
545         out_name:
546                 putname(filename);
547                 return rc;
548         }
549         case OBD_IOC_PING: {
550                 struct ptlrpc_request *req = NULL;
551                 char *buf = NULL;
552                 int rc, len=0;
553                 struct client_obd *cli;
554                 struct obd_device *obd;
555
556                 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
557                 if (rc)
558                         RETURN(rc);
559                 data = (void *)buf;
560
561                 obd = class_name2obd(data->ioc_inlbuf1);
562
563                 if (!obd )
564                         GOTO(out_ping, rc = -ENODEV);
565
566                 if (!obd->obd_attached) {
567                         CERROR("Device %d not attached\n", obd->obd_minor);
568                         GOTO(out_ping, rc = -ENODEV);
569                 }
570                 if (!obd->obd_set_up) {
571                         CERROR("Device %d still not setup\n", obd->obd_minor);
572                         GOTO(out_ping, rc = -ENODEV);
573                 }
574                 cli = &obd->u.cli;
575                 req = ptlrpc_prep_req(cli->cl_import, OBD_PING, 0, NULL, NULL);
576                 if (!req)
577                         GOTO(out_ping, rc = -ENOMEM);
578
579                 req->rq_replen = lustre_msg_size(0, NULL);
580                 req->rq_send_state = LUSTRE_IMP_FULL;
581
582                 rc = ptlrpc_queue_wait(req);
583
584                 ptlrpc_req_finished(req);
585         out_ping:
586                 obd_ioctl_freedata(buf, len);
587                 return rc;
588         }
589         case OBD_IOC_LLOG_CATINFO: {
590                 struct ptlrpc_request *req = NULL;
591                 char *buf = NULL;
592                 int rc, len = 0;
593                 char *bufs[2], *str;
594                 int lens[2], size;
595
596                 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
597                 if (rc)
598                         RETURN(rc);
599                 data = (void *)buf;
600
601                 if (!data->ioc_inlbuf1) {
602                         obd_ioctl_freedata(buf, len);
603                         RETURN(-EINVAL);
604                 }
605
606                 lens[0] = data->ioc_inllen1;
607                 bufs[0] = data->ioc_inlbuf1;
608                 if (data->ioc_inllen2) {
609                         lens[1] = data->ioc_inllen2;
610                         bufs[1] = data->ioc_inlbuf2;
611                 } else {
612                         lens[1] = 0;
613                         bufs[1] = NULL;
614                 }
615                 size = data->ioc_plen1;
616                 req = ptlrpc_prep_req(sbi2mdc(sbi)->cl_import, LLOG_CATINFO,
617                                       2, lens, bufs);
618                 if (!req)
619                         GOTO(out_catinfo, rc = -ENOMEM);
620                 req->rq_replen = lustre_msg_size(1, &size);
621
622                 rc = ptlrpc_queue_wait(req);
623                 str = lustre_msg_string(req->rq_repmsg, 0, data->ioc_plen1);
624                 if (!rc)
625                         rc = copy_to_user(data->ioc_pbuf1, str,
626                                           data->ioc_plen1);
627                 ptlrpc_req_finished(req);
628         out_catinfo:
629                 obd_ioctl_freedata(buf, len);
630                 RETURN(rc);
631         }
632         default:
633                 return obd_iocontrol(cmd, sbi->ll_osc_exp,0,NULL,(void *)arg);
634         }
635 }
636
637 int ll_dir_open(struct inode *inode, struct file *file)
638 {
639         return ll_file_open(inode, file);
640 }
641
642 int ll_dir_release(struct inode *inode, struct file *file)
643 {
644         return ll_file_release(inode, file);
645 }
646
647 struct file_operations ll_dir_operations = {
648         open: ll_dir_open,
649         release: ll_dir_release,
650         read: generic_read_dir,
651         readdir: ll_readdir,
652         ioctl: ll_dir_ioctl
653 };
654