Whamcloud - gitweb
Fix another nasty bug in ll_common_unlink - we were always setting the
authoradilger <adilger>
Fri, 23 Aug 2002 21:35:30 +0000 (21:35 +0000)
committeradilger <adilger>
Fri, 23 Aug 2002 21:35:30 +0000 (21:35 +0000)
inode link count to zero, instead of just decrementing it.

Use a common name for ll_inode_info variables for clarity.

lustre/llite/namei.c
lustre/llite/rw.c
lustre/llite/super.c

index 1122372..5e6000c 100644 (file)
@@ -418,7 +418,7 @@ static int ll_create(struct inode * dir, struct dentry * dentry, int mode)
         struct obdo oa;
         struct inode *inode;
         struct lov_stripe_md *smd = NULL;
-        struct ll_inode_info *ii = NULL;
+        struct ll_inode_info *lli = NULL;
         ENTRY;
 
         if (dentry->d_it->it_disposition == 0) {
@@ -443,8 +443,8 @@ static int ll_create(struct inode * dir, struct dentry * dentry, int mode)
         }
 
         if (dentry->d_it->it_disposition) {
-                ii = ll_i2info(inode);
-                memcpy(&ii->lli_intent_lock_handle,
+                lli = ll_i2info(inode);
+                memcpy(&lli->lli_intent_lock_handle,
                        dentry->d_it->it_lock_handle,
                        sizeof(struct lustre_handle));
                 d_instantiate(dentry, inode);
@@ -456,9 +456,9 @@ static int ll_create(struct inode * dir, struct dentry * dentry, int mode)
         RETURN(rc);
 
 out_destroy:
-#warning AED: verify that smd is set here
         if (smd) {
                 oa.o_easize = smd->lmd_easize;
+                oa.o_valid |= OBD_MD_FLEASIZE;
                 err = obd_destroy(ll_i2obdconn(dir), &oa, smd);
                 if (err)
                         CERROR("error destroying objid %Ld on error: err %d\n",
@@ -494,8 +494,9 @@ static int ll_symlink(struct inode *dir, struct dentry *dentry,
 {
         unsigned l = strlen(symname);
         struct inode *inode;
-        struct ll_inode_info *oinfo;
+        struct ll_inode_info *lli;
         int err = 0;
+        ENTRY;
 
         inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len,
                                symname, l, S_IFLNK | S_IRWXUGO, 0,
@@ -503,13 +504,16 @@ static int ll_symlink(struct inode *dir, struct dentry *dentry,
         if (IS_ERR(inode))
                 RETURN(PTR_ERR(inode));
 
-        oinfo = ll_i2info(inode);
+        lli = ll_i2info(inode);
 
-        OBD_ALLOC(oinfo->lli_symlink_name, l + 1);
-        if (!oinfo->lli_symlink_name)
+        OBD_ALLOC(lli->lli_symlink_name, l + 1);
+        /* this _could_ be a non-fatal error, since the symlink is already
+         * stored on the MDS by this point, and we can re-get it in readlink.
+         */
+        if (!lli->lli_symlink_name)
                 RETURN(-ENOMEM);
 
-        memcpy(oinfo->lli_symlink_name, symname, l + 1);
+        memcpy(lli->lli_symlink_name, symname, l + 1);
         inode->i_size = l;
 
         /* no directory data updates when intents rule */
@@ -518,7 +522,7 @@ static int ll_symlink(struct inode *dir, struct dentry *dentry,
         else
                 err = ext2_add_nondir(dentry, inode);
 
-        return err;
+        RETURN(err);
 }
 
 static int ll_link(struct dentry *old_dentry, struct inode * dir,
@@ -602,8 +606,6 @@ static int ll_common_unlink(struct inode *dir, struct dentry *dentry,
 
         if (dentry->d_it && dentry->d_it->it_disposition) {
                 err = dentry->d_it->it_status;
-                if (!err)
-                        inode->i_nlink = 0;
                 GOTO(out, err);
         }
 
@@ -621,8 +623,8 @@ static int ll_common_unlink(struct inode *dir, struct dentry *dentry,
                 goto out;
 
         inode->i_ctime = dir->i_ctime;
-        ext2_dec_count(inode);
 out:
+        ext2_dec_count(inode);
         return err;
 }
 
index 23ff9ec..0ac8674 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Lustre Lite I/O Page Cache
  *
- * Copyright (C) 2002 Cluster File Systems, Inc. 
+ * Copyright (C) 2002 Cluster File Systems, Inc.
  */
 
 #include <linux/config.h>
 /* SYNCHRONOUS I/O to object storage for an inode */
 static int ll_brw(int rw, struct inode *inode, struct page *page, int create)
 {
-        struct ll_inode_info *lii = ll_i2info(inode);
-        struct lov_stripe_md *md = lii->lli_smd;
-        struct brw_page pg; 
-        int              err;
+        struct ll_inode_info *lli = ll_i2info(inode);
+        struct lov_stripe_md *md = lli->lli_smd;
+        struct brw_page pg;
+        int err;
         struct io_cb_data *cbd = ll_init_cb();
         ENTRY;
-        if (!cbd) 
-                RETURN(-ENOMEM); 
+
+        if (!cbd)
+                RETURN(-ENOMEM);
 
         pg.pg = page;
         pg.count = PAGE_SIZE;
@@ -52,6 +53,7 @@ static int ll_brw(int rw, struct inode *inode, struct page *page, int create)
         pg.flag = create ? OBD_BRW_CREATE : 0;
 
         err = obd_brw(rw, ll_i2obdconn(inode), md, 1, &pg, ll_sync_io_cb, cbd);
+
         RETURN(err);
 } /* ll_brw */
 
@@ -94,8 +96,8 @@ static int ll_prepare_write(struct file *file, struct page *page, unsigned from,
         //obd_off offset = ((obd_off)page->index) << PAGE_SHIFT;
         int rc = 0;
         char *addr;
-        ENTRY; 
-        
+        ENTRY;
+
         addr = kmap(page);
         if (!PageLocked(page))
                 LBUG();
@@ -109,7 +111,7 @@ static int ll_prepare_write(struct file *file, struct page *page, unsigned from,
          * to date until commit_write */
         if (from == 0 && to == PAGE_SIZE)
                 RETURN(0);
-        
+
         /* prepare write should not read what lies beyond the end of
            the file */
         rc = ll_brw(OBD_BRW_READ, inode, page, 0);
@@ -139,7 +141,7 @@ static int ll_writepage(struct page *page)
         } else {
                 CERROR("ll_brw failure %d\n", err);
         }
-        UnlockPage(page); 
+        UnlockPage(page);
         RETURN(err);
 }
 
@@ -151,8 +153,8 @@ static int ll_commit_write(struct file *file, struct page *page,
 {
         int create = 1;
         struct inode *inode = page->mapping->host;
-        struct ll_inode_info *lii = ll_i2info(inode);
-        struct lov_stripe_md *md = lii->lli_smd;
+        struct ll_inode_info *lli = ll_i2info(inode);
+        struct lov_stripe_md *md = lli->lli_smd;
         struct brw_page pg;
         int err;
         struct iattr iattr;
@@ -179,9 +181,6 @@ static int ll_commit_write(struct file *file, struct page *page,
                       1, &pg, ll_sync_io_cb, cbd);
         kunmap(page);
 
-        if (err)
-                GOTO(out, err);
-
         iattr.ia_size = pg.off + pg.count;
         if (iattr.ia_size > inode->i_size) {
                 /* do NOT truncate when writing in the middle of a file */
@@ -195,7 +194,6 @@ static int ll_commit_write(struct file *file, struct page *page,
                 }
 #endif
         }
-out:
         RETURN(err);
 } /* ll_commit_write */
 
@@ -206,7 +204,7 @@ void ll_truncate(struct inode *inode)
         int err;
         ENTRY;
 
-        if (!md) { 
+        if (!md) {
                 /* object not yet allocated */
                 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
                 return;
@@ -238,8 +236,8 @@ int ll_direct_IO(int rw, struct inode *inode, struct kiobuf *iobuf,
                  unsigned long blocknr, int blocksize)
 {
         obd_count        bufs_per_obdo = iobuf->nr_pages;
-        struct ll_inode_info *lii = ll_i2info(inode);
-        struct lov_stripe_md *md = lii->lli_smd;
+        struct ll_inode_info *lli = ll_i2info(inode);
+        struct lov_stripe_md *md = lli->lli_smd;
         struct brw_page *pga;
         int              rc = 0;
         int i;
index 50a5bf9..e078624 100644 (file)
@@ -440,10 +440,10 @@ static void ll_read_inode2(struct inode *inode, void *opaque)
 {
         struct ll_inode_md *md = opaque;
         struct mds_body *body = md->body;
-        struct ll_inode_info *ii = ll_i2info(inode);
+        struct ll_inode_info *lli = ll_i2info(inode);
         ENTRY;
 
-        sema_init(&ii->lli_open_sem, 1);
+        sema_init(&lli->lli_open_sem, 1);
 
         /* core attributes first */
         if (body->valid & OBD_MD_FLID)
@@ -481,23 +481,23 @@ static void ll_read_inode2(struct inode *inode, void *opaque)
                                inode->i_ino);
                         LBUG();
                 }
-                size = sizeof(*ii->lli_smd) +
+                size = sizeof(*lli->lli_smd) +
                         md->md->lmd_stripe_count * sizeof(struct lov_oinfo);
-                OBD_ALLOC(ii->lli_smd, size);
-                if (!ii->lli_smd) {
+                OBD_ALLOC(lli->lli_smd, size);
+                if (!lli->lli_smd) {
                         CERROR("No memory for %d\n", size);
                         LBUG();
                 }
-                lov_unpackmd(ii->lli_smd, smd);
+                lov_unpackmd(lli->lli_smd, smd);
         } else {
-                ii->lli_smd = NULL;
+                lli->lli_smd = NULL;
         }
 
         /* Get the authoritative file size */
-        if (ii->lli_smd && (inode->i_mode & S_IFREG)) {
+        if (lli->lli_smd && (inode->i_mode & S_IFREG)) {
                 int rc;
 
-                rc = ll_file_size(inode, ii->lli_smd, &inode->i_size);
+                rc = ll_file_size(inode, lli->lli_smd, &inode->i_size);
                 if (rc) {
                         CERROR("ll_file_size: %d\n", rc);
                         /* FIXME: need to somehow prevent inode creation */