oit.it_flags |= 2;
it = file->f_it;
- /*
- * sometimes LUSTRE_IT(it) may not be allocated like opening file by
- * dentry_open() from GNS stuff.
- */
+
+ /* sometimes LUSTRE_IT(it) may not be allocated like opening file by
+ * dentry_open() from GNS stuff. */
if (!it || !LUSTRE_IT(it)) {
it = &oit;
rc = ll_intent_alloc(it);
lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_OPEN);
- /*
- * mdc_intent_lock() didn't get a request ref if there was an open
- * error, so don't do cleanup on the * request here (bug 3430)
- */
+ /* mdc_intent_lock() didn't get a request ref if there was an open
+ * error, so don't do cleanup on the * request here (bug 3430) */
if (LUSTRE_IT(it)->it_disposition) {
rc = it_open_error(DISP_OPEN_OPEN, it);
if (rc)
GOTO(out, rc);
out:
/* audit stuff if there was no RPC */
- if (LUSTRE_IT(it)->it_data == 0) {
+ if (LUSTRE_IT(it)->it_data == 0)
ll_audit_log(inode, AUDIT_OPEN, rc);
- }
req = LUSTRE_IT(it)->it_data;
ll_intent_drop_lock(it);
ll_intent_release(it);
- ptlrpc_req_finished(req);
+
+ if (req)
+ ptlrpc_req_finished(req);
if (rc == 0) {
ll_open_complete(inode);
} else {
if (!S_ISREG(inode->i_mode))
return 0;
+ /* GNS code path will have no req */
+ if (!req)
+ return 0;
+
body = lustre_msg_buf(req->rq_repmsg, 1, sizeof (*body));
LASSERT(body != NULL); /* reply already checked out */
LASSERT_REPSWABBED(req, 1); /* and swabbed down */
strlen(sbi->ll_gns_oname));
up(&sbi->ll_gns_sem);
- cleanup_phase = 2;
-
if (IS_ERR(dchild)) {
rc = PTR_ERR(dchild);
CERROR("can't find mount object %*s/%*s err = %d.\n",
}
/* mount object is not found */
- if (!dchild->d_inode)
+ if (!dchild->d_inode) {
+ dput(dchild);
GOTO(cleanup, rc = -ENOENT);
+ }
/* check if found child is regular file */
- if (!S_ISREG(dchild->d_inode->i_mode))
+ if (!S_ISREG(dchild->d_inode->i_mode)) {
+ dput(dchild);
GOTO(cleanup, rc = -EBADF);
-
- mntget(mnt);
+ }
/* ok, mount object if found, opening it. */
- mntinfo_fd = dentry_open(dchild, mnt, 0);
+ mntinfo_fd = dentry_open(dchild, mntget(mnt), 0);
if (IS_ERR(mntinfo_fd)) {
CERROR("can't open mount object %*s/%*s err = %d.\n",
(int)dentry->d_name.len, dentry->d_name.name,
strlen(sbi->ll_gns_oname), sbi->ll_gns_oname,
(int)PTR_ERR(mntinfo_fd));
mntput(mnt);
+ dput(dchild);
GOTO(cleanup, rc = PTR_ERR(mntinfo_fd));
}
- cleanup_phase = 3;
+ cleanup_phase = 2;
if (mntinfo_fd->f_dentry->d_inode->i_size > PAGE_SIZE - 1) {
CERROR("mount object %*s/%*s is too big (%Ld)\n",
if (!datapage)
GOTO(cleanup, rc = -ENOMEM);
- cleanup_phase = 4;
+ cleanup_phase = 3;
/* read data from mount object. */
rc = kernel_read(mntinfo_fd, 0, datapage, PAGE_SIZE - 1);
EXIT;
cleanup:
switch (cleanup_phase) {
- case 4:
- free_page((unsigned long)datapage);
case 3:
- if (mntinfo_fd != NULL)
- fput(mntinfo_fd);
+ free_page((unsigned long)datapage);
case 2:
- if (dchild != NULL)
- dput(dchild);
+ if (mntinfo_fd != NULL) {
+ fput(mntinfo_fd);
+ dchild = NULL;
+ }
case 1:
free_page((unsigned long)pathpage);
case 0:
run_test 2d " odd conditions (mount object is absent) =============="
+test_2d1() {
+ local UPCALL="$TMP/gns-upcall-2d1.sh"
+ local LOG="$TMP/gns-log"
+ local OBJECT=".mntinfo"
+ local TIMOUT=5
+ local TICK=1
+
+ disable_gns
+
+ setup_gns $OBJECT $TIMOUT $TICK ||
+ error
+
+ setup_upcall $UPCALL GENERIC $LOG FG ||
+ error
+
+ mkdir -p $DIR/gns_test_2d1
+ cp /etc/termcap $DIR/gns_test_2d1/$OBJECT
+ size=`ls -la $DIR/gns_test_2d1/$OBJECT | awk '{print $5}'`
+ echo "mount object $DIR/gns_test_2d1/$OBJECT size: ${size} bytes"
+ chmod u+s $DIR/gns_test_2d1
+
+ enable_gns
+
+ check_gns $DIR/gns_test_2d1 $DIR/gns_test_2d1 $TIMOUT $TICK GENERIC OPEN 1
+
+ disable_gns
+ chmod u-s $DIR/gns_test_2d1
+ rm -fr $DIR/gns_test_2d1
+
+ return 0
+}
+
+run_test 2d1 " odd conditions (mount object is too big) ============"
+
test_2e() {
local OBJECT=".mntinfo"
local TIMOUT=5