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 //inode->i_size = body->size;
90 SetPageUptodate(page);
92 ptlrpc_req_finished(request);
98 struct address_space_operations ll_dir_aops = {
99 .readpage = ll_dir_readpage,
103 * ext2 uses block-sized chunks. Arguably, sector-sized ones would be
104 * more robust, but we have what we have
106 static inline unsigned ext2_chunk_size(struct inode *inode)
108 return inode->i_sb->s_blocksize;
111 static inline void ext2_put_page(struct page *page)
114 page_cache_release(page);
117 static inline unsigned long dir_pages(struct inode *inode)
119 return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
122 static void ext2_check_page(struct page *page)
124 struct inode *dir = page->mapping->host;
125 unsigned chunk_size = ext2_chunk_size(dir);
126 char *kaddr = page_address(page);
127 // u32 max_inumber = le32_to_cpu(sb->u.ext2_sb.s_es->s_inodes_count);
128 unsigned offs, rec_len;
129 unsigned limit = PAGE_CACHE_SIZE;
133 if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
134 limit = dir->i_size & ~PAGE_CACHE_MASK;
135 if (limit & (chunk_size - 1)) {
136 CERROR("limit %d dir size %lld index %ld\n",
137 limit, dir->i_size, page->index);
140 for (offs = limit; offs<PAGE_CACHE_SIZE; offs += chunk_size) {
141 ext2_dirent *p = (ext2_dirent*)(kaddr + offs);
142 p->rec_len = cpu_to_le16(chunk_size);
149 for (offs = 0; offs <= limit - EXT2_DIR_REC_LEN(1); offs += rec_len) {
150 p = (ext2_dirent *)(kaddr + offs);
151 rec_len = le16_to_cpu(p->rec_len);
153 if (rec_len < EXT2_DIR_REC_LEN(1))
157 if (rec_len < EXT2_DIR_REC_LEN(p->name_len))
159 if (((offs + rec_len - 1) ^ offs) & ~(chunk_size-1))
161 // if (le32_to_cpu(p->inode) > max_inumber)
167 SetPageChecked(page);
170 /* Too bad, we had an error */
173 CERROR("ext2_check_page"
174 "size of directory #%lu is not a multiple of chunk size\n",
179 error = "rec_len is smaller than minimal";
182 error = "unaligned directory entry";
185 error = "rec_len is too small for name_len";
188 error = "directory entry across blocks";
191 // error = "inode out of bounds";
193 CERROR("ext2_check_page: bad entry in directory #%lu: %s - "
194 "offset=%lu+%u, inode=%lu, rec_len=%d, name_len=%d",
195 dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT), offs,
196 (unsigned long) le32_to_cpu(p->inode),
197 rec_len, p->name_len);
200 p = (ext2_dirent *)(kaddr + offs);
201 CERROR("ext2_check_page"
202 "entry in directory #%lu spans the page boundary"
203 "offset=%lu, inode=%lu",
204 dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs,
205 (unsigned long) le32_to_cpu(p->inode));
207 SetPageChecked(page);
211 static struct page *ll_get_dir_page(struct inode *dir, unsigned long n)
213 struct ll_inode_info *li = ll_i2info(dir);
214 struct ldlm_res_id res_id =
215 { .name = { id_fid(&li->lli_id), id_group(&li->lli_id)} };
216 struct lustre_handle lockh;
217 struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_md_exp);
218 struct address_space *mapping = dir->i_mapping;
220 ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_UPDATE } };
223 obddev = md_get_real_obd(ll_i2sbi(dir)->ll_md_exp, &li->lli_id);
224 rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED,
225 &res_id, LDLM_IBITS, &policy, LCK_PR, &lockh);
227 struct lookup_intent it = { .it_op = IT_READDIR };
228 struct ptlrpc_request *request;
229 struct mdc_op_data *op_data;
231 OBD_ALLOC(op_data, sizeof(*op_data));
233 return ERR_PTR(-ENOMEM);
235 ll_inode2mdc_data(op_data, dir, (OBD_MD_FLID | OBD_MD_MEA));
237 rc = ll_intent_alloc(&it);
241 rc = md_enqueue(ll_i2sbi(dir)->ll_md_exp, LDLM_IBITS, &it,
242 LCK_PR, op_data, &lockh, NULL, 0,
243 ldlm_completion_ast, ll_mdc_blocking_ast, dir);
244 OBD_FREE(op_data, sizeof(*op_data));
246 request = (struct ptlrpc_request *)LUSTRE_IT(&it)->it_data;
250 ptlrpc_req_finished(request);
252 CERROR("lock enqueue: rc: %d\n", rc);
256 if (ptlrpcs_check_cred(obddev->u.cli.cl_import)) {
257 /* return immediately if no credential held */
258 ldlm_lock_decref(&lockh, LCK_PR);
259 return ERR_PTR(-EACCES);
262 ldlm_lock_dump_handle(D_OTHER, &lockh);
264 page = read_cache_page(mapping, n,
265 (filler_t*)mapping->a_ops->readpage, NULL);
269 if (!PageUptodate(page))
271 if (!PageChecked(page))
272 ext2_check_page(page);
278 ldlm_lock_decref(&lockh, LCK_PR);
283 page = ERR_PTR(-EIO);
288 * p is at least 6 bytes before the end of page
290 static inline ext2_dirent *ext2_next_entry(ext2_dirent *p)
292 return (ext2_dirent *)((char*)p + le16_to_cpu(p->rec_len));
295 static inline unsigned
296 ext2_validate_entry(char *base, unsigned offset, unsigned mask)
298 ext2_dirent *de = (ext2_dirent*)(base + offset);
299 ext2_dirent *p = (ext2_dirent*)(base + (offset&mask));
300 while ((char*)p < (char*)de)
301 p = ext2_next_entry(p);
302 return (char *)p - base;
305 static unsigned char ext2_filetype_table[EXT2_FT_MAX] = {
306 [EXT2_FT_UNKNOWN] DT_UNKNOWN,
307 [EXT2_FT_REG_FILE] DT_REG,
308 [EXT2_FT_DIR] DT_DIR,
309 [EXT2_FT_CHRDEV] DT_CHR,
310 [EXT2_FT_BLKDEV] DT_BLK,
311 [EXT2_FT_FIFO] DT_FIFO,
312 [EXT2_FT_SOCK] DT_SOCK,
313 [EXT2_FT_SYMLINK] DT_LNK,
317 int ll_readdir(struct file * filp, void * dirent, filldir_t filldir)
319 struct inode *inode = filp->f_dentry->d_inode;
320 loff_t pos = filp->f_pos;
321 // XXX struct super_block *sb = inode->i_sb;
322 unsigned offset = pos & ~PAGE_CACHE_MASK;
323 unsigned long n = pos >> PAGE_CACHE_SHIFT;
324 unsigned long npages = dir_pages(inode);
325 unsigned chunk_mask = ~(ext2_chunk_size(inode)-1);
326 unsigned char *types = ext2_filetype_table;
327 int need_revalidate = (filp->f_version != inode->i_version);
331 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %llu/%llu\n",
332 inode->i_ino, inode->i_generation, inode, pos, inode->i_size);
334 if (pos > inode->i_size - EXT2_DIR_REC_LEN(1))
337 for ( ; n < npages; n++, offset = 0) {
342 CDEBUG(D_EXT2,"read %lu of dir %lu/%u page %lu/%lu size %llu\n",
343 PAGE_CACHE_SIZE, inode->i_ino, inode->i_generation,
344 n, npages, inode->i_size);
345 page = ll_get_dir_page(inode, n);
347 /* size might have been updated by md_readpage() */
348 npages = dir_pages(inode);
352 CERROR("error reading dir %lu/%u page %lu: rc %d\n",
353 inode->i_ino, inode->i_generation, n, rc);
357 kaddr = page_address(page);
358 if (need_revalidate) {
359 offset = ext2_validate_entry(kaddr, offset, chunk_mask);
362 de = (ext2_dirent *)(kaddr+offset);
363 limit = kaddr + PAGE_CACHE_SIZE - EXT2_DIR_REC_LEN(1);
364 for ( ;(char*)de <= limit; de = ext2_next_entry(de)) {
368 rc = 0; /* no error if we return something */
370 offset = (char *)de - kaddr;
371 over = filldir(dirent, de->name, de->name_len,
372 (n<<PAGE_CACHE_SHIFT) | offset,
373 le32_to_cpu(de->inode),
374 types[de->file_type &
388 filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset;
389 filp->f_version = inode->i_version;
394 static int ll_mkdir_stripe(struct inode *inode, unsigned long arg)
396 struct ptlrpc_request *request = NULL;
397 struct ll_sb_info *sbi = ll_i2sbi(inode);
398 struct ll_user_mkdir_stripe lums;
399 struct mdc_op_data *op_data;
406 if (copy_from_user(&lums, (void *)arg, sizeof(lums)))
409 if (lums.lums_namelen <= 0)
411 OBD_ALLOC(name, lums.lums_namelen);
415 if (copy_from_user(name, lums.lums_name, lums.lums_namelen))
416 GOTO(out, err = -EFAULT);
418 CDEBUG(D_VFSTRACE, "ioctl Op:name=%s,dir=%lu/%u(%p)\n",
419 name, inode->i_ino, inode->i_generation, inode);
420 nstripes = lums.lums_nstripes;
422 mode = lums.lums_mode;
423 mode = (mode & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR;
425 OBD_ALLOC(op_data, sizeof(*op_data));
427 GOTO(out, err = -ENOMEM);
428 ll_prepare_mdc_data(op_data, inode, NULL, name, lums.lums_namelen, 0);
429 err = md_create(sbi->ll_md_exp, op_data, &nstripes, sizeof(nstripes),
430 mode, current->fsuid, current->fsgid, 0, &request);
431 OBD_FREE(op_data, sizeof(*op_data));
432 ptlrpc_req_finished(request);
435 OBD_FREE(name, lums.lums_namelen);
440 * we don't call getxattr_internal/setxattr_internal because we
441 * need more precisely control.
443 static int ll_ioctl_getfacl(struct inode *inode,
445 struct ll_acl_ioctl_data *ioc)
447 struct ptlrpc_request *req = NULL;
448 struct mds_body *body;
454 if (!ioc->cmd || !ioc->cmd_len ||
455 !ioc->res || !ioc->res_len) {
456 CERROR("error: cmd %p, len %lu, res %p, len %lu\n",
457 ioc->cmd, ioc->cmd_len, ioc->res, ioc->res_len);
461 OBD_ALLOC(cmd, ioc->cmd_len);
464 if (copy_from_user(cmd, ioc->cmd, ioc->cmd_len))
465 GOTO(out, rc = -EFAULT);
467 /* we didn't call ll_getxattr_internal() because we'd like to
468 * copy from reply buffer to user space directly.
470 ll_inode2id(&id, inode);
471 rc = md_getattr(ll_i2sbi(inode)->ll_md_exp, &id, OBD_MD_FLXATTR,
472 XATTR_NAME_LUSTRE_ACL,
473 cmd, ioc->cmd_len, ioc->res_len, NULL, &req);
475 CERROR("rc: %d\n", rc);
479 res = lustre_msg_buf(req->rq_repmsg, 1, ioc->res_len);
481 if (copy_to_user(ioc->res, res, ioc->res_len))
484 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
486 ioc->status = (__s32) body->flags;
491 ptlrpc_req_finished(req);
492 OBD_FREE(cmd, ioc->cmd_len);
497 static int ll_ioctl_setfacl(struct inode *inode,
499 struct ll_acl_ioctl_data *ioc)
501 struct ptlrpc_request *req = NULL;
502 struct mdc_op_data *op_data;
503 struct mds_body *body;
509 if (!ioc->cmd || !ioc->cmd_len) {
510 CERROR("error: cmd %p, len %lu\n", ioc->cmd, ioc->cmd_len);
514 OBD_ALLOC(cmd, ioc->cmd_len);
517 if (copy_from_user(cmd, ioc->cmd, ioc->cmd_len))
518 GOTO(out, rc = -EFAULT);
520 memset(&attr, 0x0, sizeof(attr));
521 attr.ia_valid |= ATTR_EA;
522 attr.ia_attr_flags = 0;
524 OBD_ALLOC(op_data, sizeof(*op_data));
526 GOTO(out, rc = -ENOMEM);
528 ll_inode2mdc_data(op_data, inode, (OBD_MD_FLID | OBD_MD_MEA));
530 rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, &attr,
531 (void *)XATTR_NAME_LUSTRE_ACL,
532 sizeof(XATTR_NAME_LUSTRE_ACL),
533 (void *)cmd, ioc->cmd_len, NULL, 0, &req);
534 OBD_FREE(op_data, sizeof(*op_data));
537 CERROR("md_setattr fails: rc = %d\n", rc);
541 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
543 ioc->status = (__s32) body->flags;
545 LASSERT(req->rq_repmsg->bufcount == 2);
546 replen = req->rq_repmsg->buflens[1];
547 LASSERT(replen <= LUSTRE_ACL_SIZE_MAX);
549 if (replen > ioc->res_len)
550 replen = ioc->res_len;
551 if (copy_to_user(ioc->res,
552 lustre_msg_buf(req->rq_repmsg, 1, replen),
559 ptlrpc_req_finished(req);
560 OBD_FREE(cmd, ioc->cmd_len);
565 static int ll_dir_ioctl(struct inode *inode, struct file *file,
566 unsigned int cmd, unsigned long arg)
568 struct ll_sb_info *sbi = ll_i2sbi(inode);
569 struct obd_ioctl_data *data;
572 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), cmd=%#x\n",
573 inode->i_ino, inode->i_generation, inode, cmd);
575 if (_IOC_TYPE(cmd) == 'T') /* tty ioctls */
578 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_IOCTL);
580 case EXT3_IOC_GETFLAGS:
581 case EXT3_IOC_SETFLAGS:
582 RETURN(ll_iocontrol(inode, file, cmd, arg));
583 case IOC_MDC_LOOKUP: {
584 struct ptlrpc_request *request = NULL;
588 int namelen, rc, len = 0;
591 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
596 filename = data->ioc_inlbuf1;
597 namelen = data->ioc_inllen1;
600 CDEBUG(D_INFO, "IOC_MDC_LOOKUP missing filename\n");
601 GOTO(out, rc = -EINVAL);
605 ll_inode2id(&id, inode);
606 rc = md_getattr_lock(sbi->ll_md_exp, &id,
607 filename, namelen, valid, 0, &request);
609 CDEBUG(D_INFO, "md_getattr_lock: %d\n", rc);
613 ptlrpc_req_finished(request);
617 obd_ioctl_freedata(buf, len);
620 case LL_IOC_KEY_TYPE: {
623 int typelen, rc, len = 0;
625 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
630 type = data->ioc_inlbuf1;
631 typelen = data->ioc_inllen1;
634 CDEBUG(D_INFO, "LL_IOC_KEY_TYPE missing filename\n");
635 GOTO(out_free, rc = -EINVAL);
637 ll_set_sb_gksinfo(inode->i_sb, type);
640 obd_ioctl_freedata(buf, len);
643 case LL_IOC_MDC_MKDIRSTRIPE:
644 RETURN(ll_mkdir_stripe(inode, arg));
645 case LL_IOC_LOV_SETSTRIPE: {
646 struct ptlrpc_request *request = NULL;
647 struct mdc_op_data *op_data;
648 struct iattr attr = { 0 };
649 struct lov_user_md lum, *lump = (struct lov_user_md *)arg;
652 LASSERT(sizeof(lum) == sizeof(*lump));
653 LASSERT(sizeof(lum.lmm_objects[0]) ==
654 sizeof(lump->lmm_objects[0]));
655 rc = copy_from_user(&lum, lump, sizeof(lum));
659 if (lum.lmm_magic != LOV_USER_MAGIC)
662 OBD_ALLOC(op_data, sizeof(*op_data));
666 ll_inode2mdc_data(op_data, inode, (OBD_MD_FLID | OBD_MD_MEA));
668 rc = md_setattr(sbi->ll_md_exp, op_data, &attr, &lum,
669 sizeof(lum), NULL, 0, NULL, 0, &request);
670 OBD_FREE(op_data, sizeof(*op_data));
671 ptlrpc_req_finished(request);
674 if (rc != -EPERM && rc != -EACCES)
675 CERROR("md_setattr fails: rc = %d\n", rc);
679 case LL_IOC_LOV_GETSTRIPE: {
680 struct ptlrpc_request *request = NULL;
681 struct lov_user_md *lump = (struct lov_user_md *)arg;
682 struct lov_mds_md *lmm;
684 struct mds_body *body;
688 valid |= OBD_MD_FLDIREA;
690 ll_inode2id(&id, inode);
691 rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, NULL, 0,
692 obd_size_diskmd(sbi->ll_dt_exp, NULL),
695 CDEBUG(D_INFO, "md_getattr failed: rc = %d\n", rc);
699 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
700 LASSERT(body != NULL); /* checked by md_getattr_lock */
701 LASSERT_REPSWABBED(request, 0);/* swabbed by md_getattr_lock */
703 lmmsize = body->eadatasize;
705 GOTO(out_get, rc = -ENODATA);
707 lmm = lustre_msg_buf(request->rq_repmsg, 1, lmmsize);
708 LASSERT(lmm != NULL);
709 LASSERT_REPSWABBED(request, 1);
710 rc = copy_to_user(lump, lmm, lmmsize);
712 GOTO(out_get, rc = -EFAULT);
716 ptlrpc_req_finished(request);
719 case IOC_MDC_SHOWFID: {
720 struct lustre_id *idp = (struct lustre_id *)arg;
725 filename = getname((const char *)arg);
726 if (IS_ERR(filename))
727 RETURN(PTR_ERR(filename));
729 ll_inode2id(&id, inode);
731 rc = ll_get_fid(sbi->ll_md_exp, &id, filename, &id);
733 GOTO(out_filename, rc);
735 rc = copy_to_user(idp, &id, sizeof(*idp));
737 GOTO(out_filename, rc = -EFAULT);
744 case IOC_MDC_GETSTRIPE: {
745 struct lov_user_md *lump = (struct lov_user_md *)arg;
746 struct ptlrpc_request *request = NULL;
747 struct lov_mds_md *lmm;
748 struct mds_body *body;
753 filename = getname((const char *)arg);
754 if (IS_ERR(filename))
755 RETURN(PTR_ERR(filename));
757 ll_inode2id(&id, inode);
758 rc = md_getattr_lock(sbi->ll_md_exp, &id, filename,
759 strlen(filename) + 1, OBD_MD_FLEASIZE,
760 obd_size_diskmd(sbi->ll_dt_exp, NULL),
763 CDEBUG(D_INFO, "md_getattr_lock failed on %s: rc %d\n",
768 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body));
769 LASSERT(body != NULL); /* checked by md_getattr_lock */
770 LASSERT_REPSWABBED(request, 0);/* swabbed by md_getattr_lock */
772 lmmsize = body->eadatasize;
774 if (!(body->valid & OBD_MD_FLEASIZE) || lmmsize == 0)
775 GOTO(out_req, rc = -ENODATA);
778 GOTO(out_req, rc = -EFBIG);
780 lmm = lustre_msg_buf(request->rq_repmsg, 1, lmmsize);
781 LASSERT(lmm != NULL);
782 LASSERT_REPSWABBED(request, 1);
784 rc = copy_to_user(lump, lmm, lmmsize);
786 GOTO(out_req, rc = -EFAULT);
790 ptlrpc_req_finished(request);
796 struct ptlrpc_request *req = NULL;
799 struct client_obd *cli;
800 struct obd_device *obd;
802 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
807 obd = class_name2obd(data->ioc_inlbuf1);
810 GOTO(out_ping, rc = -ENODEV);
812 if (!obd->obd_attached) {
813 CERROR("Device %d not attached\n", obd->obd_minor);
814 GOTO(out_ping, rc = -ENODEV);
816 if (!obd->obd_set_up) {
817 CERROR("Device %d still not setup\n", obd->obd_minor);
818 GOTO(out_ping, rc = -ENODEV);
821 req = ptlrpc_prep_req(cli->cl_import, LUSTRE_OBD_VERSION,
822 OBD_PING, 0, NULL, NULL);
824 GOTO(out_ping, rc = -ENOMEM);
826 req->rq_replen = lustre_msg_size(0, NULL);
827 req->rq_send_state = LUSTRE_IMP_FULL;
829 rc = ptlrpc_queue_wait(req);
831 ptlrpc_req_finished(req);
833 obd_ioctl_freedata(buf, len);
836 case OBD_IOC_LLOG_CATINFO: {
837 struct ptlrpc_request *req = NULL;
843 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
848 if (!data->ioc_inlbuf1) {
849 obd_ioctl_freedata(buf, len);
853 lens[0] = data->ioc_inllen1;
854 bufs[0] = data->ioc_inlbuf1;
855 if (data->ioc_inllen2) {
856 lens[1] = data->ioc_inllen2;
857 bufs[1] = data->ioc_inlbuf2;
862 size = data->ioc_plen1;
863 req = ptlrpc_prep_req(sbi2md(sbi)->cl_import,
864 LUSTRE_LOG_VERSION, LLOG_CATINFO,
867 GOTO(out_catinfo, rc = -ENOMEM);
869 req->rq_replen = lustre_msg_size(1, &size);
871 rc = ptlrpc_queue_wait(req);
872 str = lustre_msg_string(req->rq_repmsg, 0, data->ioc_plen1);
874 rc = copy_to_user(data->ioc_pbuf1, str,
876 ptlrpc_req_finished(req);
878 obd_ioctl_freedata(buf, len);
881 case LL_IOC_GETFACL: {
882 struct ll_acl_ioctl_data ioc, *uioc;
885 if (copy_from_user(&ioc, (void *) arg, sizeof(ioc)))
888 rc = ll_ioctl_getfacl(inode, file, &ioc);
890 uioc = (struct ll_acl_ioctl_data *) arg;
891 if (copy_to_user(&uioc->status, &ioc.status,
897 case LL_IOC_SETFACL: {
898 struct ll_acl_ioctl_data ioc, *uioc;
901 if (copy_from_user(&ioc, (void *) arg, sizeof(ioc)))
904 rc = ll_ioctl_setfacl(inode, file, &ioc);
906 uioc = (struct ll_acl_ioctl_data *) arg;
907 if (copy_to_user(&uioc->status, &ioc.status,
913 case LL_IOC_FLUSH_CRED:
914 RETURN(ll_flush_cred(inode));
916 RETURN(ll_set_audit(inode, SET_AUDIT_OP(arg, AUDIT_DIR)));
918 return obd_iocontrol(cmd, sbi->ll_dt_exp, 0,
923 int ll_dir_open(struct inode *inode, struct file *file)
925 return ll_file_open(inode, file);
928 int ll_dir_release(struct inode *inode, struct file *file)
930 return ll_file_release(inode, file);
933 struct file_operations ll_dir_operations = {
935 .release = ll_dir_release,
936 .read = generic_read_dir,
937 .readdir = ll_readdir,
938 .ioctl = ll_dir_ioctl