From: yury Date: Fri, 9 Sep 2005 11:53:06 +0000 (+0000) Subject: - fixes in GNS stuff - bug #9283 X-Git-Tag: 1.4.10~572 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=8a8d1fbac00a362d0204899b747b9f773bffdd7b;p=fs%2Flustre-release.git - fixes in GNS stuff - bug #9283 --- diff --git a/lustre/llite/file.c b/lustre/llite/file.c index ef2b04b..1190339 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -443,10 +443,9 @@ int ll_file_open(struct inode *inode, struct file *file) 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); @@ -456,10 +455,8 @@ int ll_file_open(struct inode *inode, struct file *file) 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) @@ -579,14 +576,15 @@ int ll_file_open(struct inode *inode, struct file *file) 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 { diff --git a/lustre/llite/llite_capa.c b/lustre/llite/llite_capa.c index 132ae45..4f34a80 100644 --- a/lustre/llite/llite_capa.c +++ b/lustre/llite/llite_capa.c @@ -236,6 +236,10 @@ int ll_set_capa(struct inode *inode, struct lookup_intent *it, 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 */ diff --git a/lustre/llite/llite_gns.c b/lustre/llite/llite_gns.c index 9cc66d7..b8531d9 100644 --- a/lustre/llite/llite_gns.c +++ b/lustre/llite/llite_gns.c @@ -194,8 +194,6 @@ ll_gns_mount_object(struct dentry *dentry, struct vfsmount *mnt) 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", @@ -206,26 +204,29 @@ ll_gns_mount_object(struct dentry *dentry, struct vfsmount *mnt) } /* 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", @@ -239,7 +240,7 @@ ll_gns_mount_object(struct dentry *dentry, struct vfsmount *mnt) 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); @@ -327,14 +328,13 @@ ll_gns_mount_object(struct dentry *dentry, struct vfsmount *mnt) 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: diff --git a/lustre/tests/sanity-gns.sh b/lustre/tests/sanity-gns.sh index 6c529f1..7ce735c 100644 --- a/lustre/tests/sanity-gns.sh +++ b/lustre/tests/sanity-gns.sh @@ -947,6 +947,40 @@ test_2d() { 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