1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
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)
11 * linux/fs/minix/dir.c
14 * Copyright (C) 1991, 1992 Linus Torvalds
16 * ext2 directory handling functions
18 * Big-endian to little-endian byte-swapping/bitmaps by
19 * David S. Miller (davem@caip.rutgers.edu), 1995
21 * All code that works with directory layout had been switched to pagecache
24 * Adapted for Lustre Light
25 * Copyright (C) 2002-2003, Cluster File Systems, Inc.
30 #include <linux/ext2_fs.h>
31 #include <linux/pagemap.h>
33 #include <linux/version.h>
34 #include <linux/smp_lock.h>
35 #include <asm/uaccess.h>
36 #include <linux/file.h>
37 #include <linux/kmod.h>
38 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
39 # include <linux/locks.h> // for wait_on_buffer
41 # include <linux/buffer_head.h> // for wait_on_buffer
44 #define DEBUG_SUBSYSTEM S_LLITE
46 #include <linux/obd_support.h>
47 #include <linux/obd_class.h>
48 #include <linux/lustre_lib.h>
49 #include <linux/lustre_idl.h>
50 #include <linux/lustre_mds.h>
51 #include <linux/lustre_lite.h>
52 #include <linux/lustre_dlm.h>
53 #include <linux/lustre_sec.h>
54 #include <linux/lustre_audit.h>
55 #include <linux/lustre_acl.h>
56 #include "llite_internal.h"
58 typedef struct ext2_dir_entry_2 ext2_dirent;
60 #define PageChecked(page) test_bit(PG_checked, &(page)->flags)
61 #define SetPageChecked(page) set_bit(PG_checked, &(page)->flags)
63 /* returns the page unlocked, but with a reference */
64 static int ll_dir_readpage(struct file *file, struct page *page)
66 struct inode *inode = page->mapping->host;
67 struct ptlrpc_request *request;
68 struct mds_body *body;
74 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
75 inode->i_generation, inode);
77 mdc_pack_id(&id, inode->i_ino, inode->i_generation,
78 S_IFDIR, id_group(&ll_i2info(inode)->lli_id),
79 id_fid(&ll_i2info(inode)->lli_id));
81 offset = page->index << PAGE_SHIFT;
82 rc = md_readpage(ll_i2sbi(inode)->ll_md_exp, &id, offset,
85 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
86 LASSERT (body != NULL); /* checked by md_readpage() */
87 LASSERT_REPSWABBED (request, 0); /* swabbed by md_readpage() */
89 #warning "FIXME ASAP!"
90 //inode->i_size = body->size;
91 SetPageUptodate(page);
93 ptlrpc_req_finished(request);
99 struct address_space_operations ll_dir_aops = {
100 .readpage = ll_dir_readpage,
104 * ext2 uses block-sized chunks. Arguably, sector-sized ones would be
105 * more robust, but we have what we have
107 static inline unsigned ext2_chunk_size(struct inode *inode)
109 return inode->i_sb->s_blocksize;
112 static inline void ext2_put_page(struct page *page)
115 page_cache_release(page);
118 static inline unsigned long dir_pages(struct inode *inode)
120 return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
123 static void ext2_check_page(struct page *page)
125 struct inode *dir = page->mapping->host;
126 unsigned chunk_size = ext2_chunk_size(dir);
127 char *kaddr = page_address(page);
128 // u32 max_inumber = le32_to_cpu(sb->u.ext2_sb.s_es->s_inodes_count);
129 unsigned offs, rec_len;
130 unsigned limit = PAGE_CACHE_SIZE;
134 if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
135 limit = dir->i_size & ~PAGE_CACHE_MASK;
136 if (limit & (chunk_size - 1)) {
137 CERROR("limit %d dir size %lld index %ld\n",
138 limit, dir->i_size, page->index);
141 for (offs = limit; offs<PAGE_CACHE_SIZE; offs += chunk_size) {
142 ext2_dirent *p = (ext2_dirent*)(kaddr + offs);
143 p->rec_len = cpu_to_le16(chunk_size);
150 for (offs = 0; offs <= limit - EXT2_DIR_REC_LEN(1); offs += rec_len) {
151 p = (ext2_dirent *)(kaddr + offs);
152 rec_len = le16_to_cpu(p->rec_len);
154 if (rec_len < EXT2_DIR_REC_LEN(1))
158 if (rec_len < EXT2_DIR_REC_LEN(p->name_len))
160 if (((offs + rec_len - 1) ^ offs) & ~(chunk_size-1))
162 // if (le32_to_cpu(p->inode) > max_inumber)
168 SetPageChecked(page);
171 /* Too bad, we had an error */
174 CERROR("ext2_check_page"
175 "size of directory #%lu is not a multiple of chunk size\n",
180 error = "rec_len is smaller than minimal";
183 error = "unaligned directory entry";
186 error = "rec_len is too small for name_len";
189 error = "directory entry across blocks";
192 // error = "inode out of bounds";
194 CERROR("ext2_check_page: bad entry in directory #%lu: %s - "
195 "offset=%lu+%u, inode=%lu, rec_len=%d, name_len=%d",
196 dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT), offs,
197 (unsigned long) le32_to_cpu(p->inode),
198 rec_len, p->name_len);
201 p = (ext2_dirent *)(kaddr + offs);
202 CERROR("ext2_check_page"
203 "entry in directory #%lu spans the page boundary"
204 "offset=%lu, inode=%lu",
205 dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs,
206 (unsigned long) le32_to_cpu(p->inode));
208 SetPageChecked(page);
212 static struct page *ll_get_dir_page(struct inode *dir, unsigned long n)
214 struct ll_inode_info *li = ll_i2info(dir);
215 struct ldlm_res_id res_id =
216 { .name = { id_fid(&li->lli_id), id_group(&li->lli_id)} };
217 struct lustre_handle lockh;
218 struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_md_exp);
219 struct address_space *mapping = dir->i_mapping;
221 ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_UPDATE } };
224 obddev = md_get_real_obd(ll_i2sbi(dir)->ll_md_exp, &li->lli_id);
225 rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED,
226 &res_id, LDLM_IBITS, &policy, LCK_PR, &lockh);
228 struct lookup_intent it = { .it_op = IT_READDIR };
229 struct ptlrpc_request *request;
230 struct mdc_op_data *op_data;
232 OBD_ALLOC(op_data, sizeof(*op_data));
234 return ERR_PTR(-ENOMEM);
236 ll_inode2mdc_data(op_data, dir, (OBD_MD_FLID | OBD_MD_MEA));
238 rc = ll_intent_alloc(&it);
242 rc = md_enqueue(ll_i2sbi(dir)->ll_md_exp, LDLM_IBITS, &it,
243 LCK_PR, op_data, &lockh, NULL, 0,
244 ldlm_completion_ast, ll_mdc_blocking_ast, dir);
245 OBD_FREE(op_data, sizeof(*op_data));
247 request = (struct ptlrpc_request *)LUSTRE_IT(&it)->it_data;
251 ptlrpc_req_finished(request);
253 CERROR("lock enqueue: rc: %d\n", rc);
257 if (ptlrpcs_check_cred(obddev->u.cli.cl_import)) {
258 /* return immediately if no credential held */
259 ldlm_lock_decref(&lockh, LCK_PR);
260 return ERR_PTR(-EACCES);
263 ldlm_lock_dump_handle(D_OTHER, &lockh);
265 page = read_cache_page(mapping, n,
266 (filler_t*)mapping->a_ops->readpage, NULL);
270 if (!PageUptodate(page))
272 if (!PageChecked(page))
273 ext2_check_page(page);
279 ldlm_lock_decref(&lockh, LCK_PR);
284 page = ERR_PTR(-EIO);
289 * p is at least 6 bytes before the end of page
291 static inline ext2_dirent *ext2_next_entry(ext2_dirent *p)
293 return (ext2_dirent *)((char*)p + le16_to_cpu(p->rec_len));
296 static inline unsigned
297 ext2_validate_entry(char *base, unsigned offset, unsigned mask)
299 ext2_dirent *de = (ext2_dirent*)(base + offset);
300 ext2_dirent *p = (ext2_dirent*)(base + (offset&mask));
301 while ((char*)p < (char*)de)
302 p = ext2_next_entry(p);
303 return (char *)p - base;
306 static unsigned char ext2_filetype_table[EXT2_FT_MAX] = {
307 [EXT2_FT_UNKNOWN] DT_UNKNOWN,
308 [EXT2_FT_REG_FILE] DT_REG,
309 [EXT2_FT_DIR] DT_DIR,
310 [EXT2_FT_CHRDEV] DT_CHR,
311 [EXT2_FT_BLKDEV] DT_BLK,
312 [EXT2_FT_FIFO] DT_FIFO,
313 [EXT2_FT_SOCK] DT_SOCK,
314 [EXT2_FT_SYMLINK] DT_LNK,
318 int ll_readdir(struct file * filp, void * dirent, filldir_t filldir)
320 struct inode *inode = filp->f_dentry->d_inode;
321 loff_t pos = filp->f_pos;
322 // XXX struct super_block *sb = inode->i_sb;
323 unsigned offset = pos & ~PAGE_CACHE_MASK;
324 unsigned long n = pos >> PAGE_CACHE_SHIFT;
325 unsigned long npages = dir_pages(inode);
326 unsigned chunk_mask = ~(ext2_chunk_size(inode)-1);
327 unsigned char *types = ext2_filetype_table;
328 int need_revalidate = (filp->f_version != inode->i_version);
332 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %llu/%llu\n",
333 inode->i_ino, inode->i_generation, inode, pos, inode->i_size);
335 if (pos > inode->i_size - EXT2_DIR_REC_LEN(1))
338 for ( ; n < npages; n++, offset = 0) {
343 CDEBUG(D_EXT2,"read %lu of dir %lu/%u page %lu/%lu size %llu\n",
344 PAGE_CACHE_SIZE, inode->i_ino, inode->i_generation,
345 n, npages, inode->i_size);
346 page = ll_get_dir_page(inode, n);
348 /* size might have been updated by md_readpage() */
349 npages = dir_pages(inode);
353 CERROR("error reading dir %lu/%u page %lu: rc %d\n",
354 inode->i_ino, inode->i_generation, n, rc);
358 kaddr = page_address(page);
359 if (need_revalidate) {
360 offset = ext2_validate_entry(kaddr, offset, chunk_mask);
363 de = (ext2_dirent *)(kaddr+offset);
364 limit = kaddr + PAGE_CACHE_SIZE - EXT2_DIR_REC_LEN(1);
365 for ( ;(char*)de <= limit; de = ext2_next_entry(de)) {
369 rc = 0; /* no error if we return something */
371 offset = (char *)de - kaddr;
372 over = filldir(dirent, de->name, de->name_len,
373 (n<<PAGE_CACHE_SHIFT) | offset,
374 le32_to_cpu(de->inode),
375 types[de->file_type &
389 filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset;
390 filp->f_version = inode->i_version;
395 static int ll_mkdir_stripe(struct inode *inode, unsigned long arg)
397 struct ptlrpc_request *request = NULL;
398 struct ll_sb_info *sbi = ll_i2sbi(inode);
399 struct ll_user_mkdir_stripe lums;
400 struct mdc_op_data *op_data;
407 if (copy_from_user(&lums, (void *)arg, sizeof(lums)))
410 if (lums.lums_namelen <= 0)
412 OBD_ALLOC(name, lums.lums_namelen);
416 if (copy_from_user(name, lums.lums_name, lums.lums_namelen))
417 GOTO(out, err = -EFAULT);
419 CDEBUG(D_VFSTRACE, "ioctl Op:name=%s,dir=%lu/%u(%p)\n",
420 name, inode->i_ino, inode->i_generation, inode);
421 nstripes = lums.lums_nstripes;
423 mode = lums.lums_mode;
424 mode = (mode & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR;
426 OBD_ALLOC(op_data, sizeof(*op_data));
428 GOTO(out, err = -ENOMEM);
429 ll_prepare_mdc_data(op_data, inode, NULL, name, lums.lums_namelen, 0);
430 err = md_create(sbi->ll_md_exp, op_data, &nstripes, sizeof(nstripes),
431 mode, current->fsuid, current->fsgid, 0, &request);
432 OBD_FREE(op_data, sizeof(*op_data));
433 ptlrpc_req_finished(request);
436 OBD_FREE(name, lums.lums_namelen);
441 * we don't call getxattr_internal/setxattr_internal because we
442 * need more precisely control.
444 static int ll_ioctl_getfacl(struct inode *inode,
446 struct ll_acl_ioctl_data *ioc)
448 struct ptlrpc_request *req = NULL;
449 struct mds_body *body;
455 if (!ioc->cmd || !ioc->cmd_len ||
456 !ioc->res || !ioc->res_len) {
457 CERROR("error: cmd %p, len %lu, res %p, len %lu\n",
458 ioc->cmd, ioc->cmd_len, ioc->res, ioc->res_len);
462 OBD_ALLOC(cmd, ioc->cmd_len);
465 if (copy_from_user(cmd, ioc->cmd, ioc->cmd_len))
466 GOTO(out, rc = -EFAULT);
468 /* we didn't call ll_getxattr_internal() because we'd like to
469 * copy from reply buffer to user space directly.
471 ll_inode2id(&id, inode);
472 rc = md_getattr(ll_i2sbi(inode)->ll_md_exp, &id, OBD_MD_FLXATTR,
473 XATTR_NAME_LUSTRE_ACL,
474 cmd, ioc->cmd_len, ioc->res_len, NULL, &req);
476 CERROR("rc: %d\n", rc);
480 res = lustre_msg_buf(req->rq_repmsg, 1, ioc->res_len);
482 if (copy_to_user(ioc->res, res, ioc->res_len))
485 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
487 ioc->status = (__s32) body->flags;
492 ptlrpc_req_finished(req);
493 OBD_FREE(cmd, ioc->cmd_len);
498 static int ll_ioctl_setfacl(struct inode *inode,
500 struct ll_acl_ioctl_data *ioc)
502 struct ptlrpc_request *req = NULL;
503 struct mdc_op_data *op_data;
504 struct mds_body *body;
510 if (!ioc->cmd || !ioc->cmd_len) {
511 CERROR("error: cmd %p, len %lu\n", ioc->cmd, ioc->cmd_len);
515 OBD_ALLOC(cmd, ioc->cmd_len);
518 if (copy_from_user(cmd, ioc->cmd, ioc->cmd_len))
519 GOTO(out, rc = -EFAULT);
521 memset(&attr, 0x0, sizeof(attr));
522 attr.ia_valid |= ATTR_EA;
523 attr.ia_attr_flags = 0;
525 OBD_ALLOC(op_data, sizeof(*op_data));
527 GOTO(out, rc = -ENOMEM);
529 ll_inode2mdc_data(op_data, inode, (OBD_MD_FLID | OBD_MD_MEA));
531 rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, &attr,
532 (void *)XATTR_NAME_LUSTRE_ACL,
533 sizeof(XATTR_NAME_LUSTRE_ACL),
534 (void *)cmd, ioc->cmd_len, NULL, 0, &req);
535 OBD_FREE(op_data, sizeof(*op_data));
538 CERROR("md_setattr fails: rc = %d\n", rc);
542 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
544 ioc->status = (__s32) body->flags;
546 LASSERT(req->rq_repmsg->bufcount == 2);
547 replen = req->rq_repmsg->buflens[1];
548 LASSERT(replen <= LUSTRE_ACL_SIZE_MAX);
550 if (replen > ioc->res_len)
551 replen = ioc->res_len;
552 if (copy_to_user(ioc->res,
553 lustre_msg_buf(req->rq_repmsg, 1, replen),
560 ptlrpc_req_finished(req);
561 OBD_FREE(cmd, ioc->cmd_len);
566 static int ll_dir_ioctl(struct inode *inode, struct file *file,
567 unsigned int cmd, unsigned long arg)
569 struct ll_sb_info *sbi = ll_i2sbi(inode);
570 struct obd_ioctl_data *data;
573 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), cmd=%#x\n",
574 inode->i_ino, inode->i_generation, inode, cmd);
576 if (_IOC_TYPE(cmd) == 'T') /* tty ioctls */
579 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_IOCTL);
581 case EXT3_IOC_GETFLAGS:
582 case EXT3_IOC_SETFLAGS:
583 RETURN(ll_iocontrol(inode, file, cmd, arg));
584 case IOC_MDC_LOOKUP: {
585 struct ptlrpc_request *request = NULL;
589 int namelen, rc, len = 0;
592 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
597 filename = data->ioc_inlbuf1;
598 namelen = data->ioc_inllen1;
601 CDEBUG(D_INFO, "IOC_MDC_LOOKUP missing filename\n");
602 GOTO(out, rc = -EINVAL);
606 ll_inode2id(&id, inode);
607 rc = md_getattr_lock(sbi->ll_md_exp, &id,
608 filename, namelen, valid, 0, &request);
610 CDEBUG(D_INFO, "md_getattr_lock: %d\n", rc);
614 ptlrpc_req_finished(request);
618 obd_ioctl_freedata(buf, len);
621 case LL_IOC_KEY_TYPE: {
624 int typelen, rc, len = 0;
626 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
631 type = data->ioc_inlbuf1;
632 typelen = data->ioc_inllen1;
635 CDEBUG(D_INFO, "LL_IOC_KEY_TYPE missing filename\n");
636 GOTO(out_free, rc = -EINVAL);
638 ll_set_sb_gksinfo(inode->i_sb, type);
641 obd_ioctl_freedata(buf, len);
644 case LL_IOC_MDC_MKDIRSTRIPE:
645 RETURN(ll_mkdir_stripe(inode, arg));
646 case LL_IOC_LOV_SETSTRIPE: {
647 struct ptlrpc_request *request = NULL;
648 struct mdc_op_data *op_data;
649 struct iattr attr = { 0 };
650 struct lov_user_md lum, *lump = (struct lov_user_md *)arg;
653 LASSERT(sizeof(lum) == sizeof(*lump));
654 LASSERT(sizeof(lum.lmm_objects[0]) ==
655 sizeof(lump->lmm_objects[0]));
656 rc = copy_from_user(&lum, lump, sizeof(lum));
660 if (lum.lmm_magic != LOV_USER_MAGIC)
663 OBD_ALLOC(op_data, sizeof(*op_data));
667 ll_inode2mdc_data(op_data, inode, (OBD_MD_FLID | OBD_MD_MEA));
669 rc = md_setattr(sbi->ll_md_exp, op_data, &attr, &lum,
670 sizeof(lum), NULL, 0, NULL, 0, &request);
671 OBD_FREE(op_data, sizeof(*op_data));
672 ptlrpc_req_finished(request);
675 if (rc != -EPERM && rc != -EACCES)
676 CERROR("md_setattr fails: rc = %d\n", rc);
680 case LL_IOC_LOV_GETSTRIPE: {
681 struct ptlrpc_request *request = NULL;
682 struct lov_user_md *lump = (struct lov_user_md *)arg;
683 struct lov_mds_md *lmm;
685 struct mds_body *body;
689 valid |= OBD_MD_FLDIREA;
691 ll_inode2id(&id, inode);
692 rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, NULL, 0,
693 obd_size_diskmd(sbi->ll_dt_exp, NULL),
696 CDEBUG(D_INFO, "md_getattr failed: rc = %d\n", rc);
700 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
701 LASSERT(body != NULL); /* checked by md_getattr_lock */
702 LASSERT_REPSWABBED(request, 0);/* swabbed by md_getattr_lock */
704 lmmsize = body->eadatasize;
706 GOTO(out_get, rc = -ENODATA);
708 lmm = lustre_msg_buf(request->rq_repmsg, 1, lmmsize);
709 LASSERT(lmm != NULL);
710 LASSERT_REPSWABBED(request, 1);
711 rc = copy_to_user(lump, lmm, lmmsize);
713 GOTO(out_get, rc = -EFAULT);
717 ptlrpc_req_finished(request);
720 case IOC_MDC_SHOWFID: {
721 struct lustre_id *idp = (struct lustre_id *)arg;
726 filename = getname((const char *)arg);
727 if (IS_ERR(filename))
728 RETURN(PTR_ERR(filename));
730 ll_inode2id(&id, inode);
732 rc = ll_get_fid(sbi->ll_md_exp, &id, filename, &id);
734 GOTO(out_filename, rc);
736 rc = copy_to_user(idp, &id, sizeof(*idp));
738 GOTO(out_filename, rc = -EFAULT);
745 case IOC_MDC_GETSTRIPE: {
746 struct lov_user_md *lump = (struct lov_user_md *)arg;
747 struct ptlrpc_request *request = NULL;
748 struct lov_mds_md *lmm;
749 struct mds_body *body;
754 filename = getname((const char *)arg);
755 if (IS_ERR(filename))
756 RETURN(PTR_ERR(filename));
758 ll_inode2id(&id, inode);
759 rc = md_getattr_lock(sbi->ll_md_exp, &id, filename,
760 strlen(filename) + 1, OBD_MD_FLEASIZE,
761 obd_size_diskmd(sbi->ll_dt_exp, NULL),
764 CDEBUG(D_INFO, "md_getattr_lock failed on %s: rc %d\n",
769 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body));
770 LASSERT(body != NULL); /* checked by md_getattr_lock */
771 LASSERT_REPSWABBED(request, 0);/* swabbed by md_getattr_lock */
773 lmmsize = body->eadatasize;
775 if (!(body->valid & OBD_MD_FLEASIZE) || lmmsize == 0)
776 GOTO(out_req, rc = -ENODATA);
779 GOTO(out_req, rc = -EFBIG);
781 lmm = lustre_msg_buf(request->rq_repmsg, 1, lmmsize);
782 LASSERT(lmm != NULL);
783 LASSERT_REPSWABBED(request, 1);
785 rc = copy_to_user(lump, lmm, lmmsize);
787 GOTO(out_req, rc = -EFAULT);
791 ptlrpc_req_finished(request);
797 struct ptlrpc_request *req = NULL;
800 struct client_obd *cli;
801 struct obd_device *obd;
803 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
808 obd = class_name2obd(data->ioc_inlbuf1);
811 GOTO(out_ping, rc = -ENODEV);
813 if (!obd->obd_attached) {
814 CERROR("Device %d not attached\n", obd->obd_minor);
815 GOTO(out_ping, rc = -ENODEV);
817 if (!obd->obd_set_up) {
818 CERROR("Device %d still not setup\n", obd->obd_minor);
819 GOTO(out_ping, rc = -ENODEV);
822 req = ptlrpc_prep_req(cli->cl_import, LUSTRE_OBD_VERSION,
823 OBD_PING, 0, NULL, NULL);
825 GOTO(out_ping, rc = -ENOMEM);
827 req->rq_replen = lustre_msg_size(0, NULL);
828 req->rq_send_state = LUSTRE_IMP_FULL;
830 rc = ptlrpc_queue_wait(req);
832 ptlrpc_req_finished(req);
834 obd_ioctl_freedata(buf, len);
837 case OBD_IOC_LLOG_CATINFO: {
838 struct ptlrpc_request *req = NULL;
844 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
849 if (!data->ioc_inlbuf1) {
850 obd_ioctl_freedata(buf, len);
854 lens[0] = data->ioc_inllen1;
855 bufs[0] = data->ioc_inlbuf1;
856 if (data->ioc_inllen2) {
857 lens[1] = data->ioc_inllen2;
858 bufs[1] = data->ioc_inlbuf2;
863 size = data->ioc_plen1;
864 req = ptlrpc_prep_req(sbi2md(sbi)->cl_import,
865 LUSTRE_LOG_VERSION, LLOG_CATINFO,
868 GOTO(out_catinfo, rc = -ENOMEM);
870 req->rq_replen = lustre_msg_size(1, &size);
872 rc = ptlrpc_queue_wait(req);
873 str = lustre_msg_string(req->rq_repmsg, 0, data->ioc_plen1);
875 rc = copy_to_user(data->ioc_pbuf1, str,
877 ptlrpc_req_finished(req);
879 obd_ioctl_freedata(buf, len);
882 case LL_IOC_GETFACL: {
883 struct ll_acl_ioctl_data ioc, *uioc;
886 if (copy_from_user(&ioc, (void *) arg, sizeof(ioc)))
889 rc = ll_ioctl_getfacl(inode, file, &ioc);
891 uioc = (struct ll_acl_ioctl_data *) arg;
892 if (copy_to_user(&uioc->status, &ioc.status,
898 case LL_IOC_SETFACL: {
899 struct ll_acl_ioctl_data ioc, *uioc;
902 if (copy_from_user(&ioc, (void *) arg, sizeof(ioc)))
905 rc = ll_ioctl_setfacl(inode, file, &ioc);
907 uioc = (struct ll_acl_ioctl_data *) arg;
908 if (copy_to_user(&uioc->status, &ioc.status,
914 case LL_IOC_FLUSH_CRED:
915 RETURN(ll_flush_cred(inode));
917 RETURN(ll_set_audit(inode, SET_AUDIT_OP(arg, AUDIT_DIR)));
919 return obd_iocontrol(cmd, sbi->ll_dt_exp, 0,
924 int ll_dir_open(struct inode *inode, struct file *file)
926 return ll_file_open(inode, file);
929 int ll_dir_release(struct inode *inode, struct file *file)
931 return ll_file_release(inode, file);
934 struct file_operations ll_dir_operations = {
936 .release = ll_dir_release,
937 .read = generic_read_dir,
938 .readdir = ll_readdir,
939 .ioctl = ll_dir_ioctl