Whamcloud - gitweb
b=255
authorpschwan <pschwan>
Wed, 6 Nov 2002 23:52:07 +0000 (23:52 +0000)
committerpschwan <pschwan>
Wed, 6 Nov 2002 23:52:07 +0000 (23:52 +0000)
- Don't call cancel_unused until the last CLOSE for a given inode.

lustre/include/linux/lustre_lite.h
lustre/llite/file.c
lustre/llite/super.c
lustre/lov/lov_obd.c

index 53388f2..4f2d8ff 100644 (file)
@@ -57,6 +57,7 @@ struct ll_inode_info {
         char                 *lli_symlink_name;
         struct lustre_handle  lli_intent_lock_handle;
         struct semaphore      lli_open_sem;
+        atomic_t              lli_open_count; /* see ll_file_release */
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
         struct inode          lli_vfs_inode;
 #endif
index 5648826..8008fb3 100644 (file)
@@ -132,6 +132,8 @@ static int ll_file_open(struct inode *inode, struct file *file)
         if (rc)
                 GOTO(out_mdc, rc = -abs(rc));
 
+        atomic_inc(&lli->lli_open_count);
+
         file->private_data = fd;
 
         RETURN(0);
@@ -325,16 +327,21 @@ out_mdc:
                         rc = -abs(rc2);
                 GOTO(out_fd, rc);
         }
-        CDEBUG(D_HA, "matched req %p xid "LPD64" transno "LPD64" op %d->%s:%d\n",
-               fd->fd_req, fd->fd_req->rq_xid, fd->fd_req->rq_repmsg->transno,
-               fd->fd_req->rq_reqmsg->opc,
+        CDEBUG(D_HA, "matched req %p xid "LPD64" transno "LPD64" op "
+               "%d->%s:%d\n", fd->fd_req, fd->fd_req->rq_xid,
+               fd->fd_req->rq_repmsg->transno, fd->fd_req->rq_reqmsg->opc,
                fd->fd_req->rq_import->imp_connection->c_remote_uuid,
                fd->fd_req->rq_import->imp_client->cli_request_portal);
         ptlrpc_req_finished(fd->fd_req);
 
-        rc = obd_cancel_unused(ll_i2obdconn(inode), lsm, 0);
-        if (rc)
-                CERROR("obd_cancel_unused: %d\n", rc);
+        if (atomic_dec_and_test(&lli->lli_open_count)) {
+                CDEBUG(D_INFO, "last close, cancelling unused locks\n");
+                rc = obd_cancel_unused(ll_i2obdconn(inode), lsm, 0);
+                if (rc)
+                        CERROR("obd_cancel_unused: %d\n", rc);
+        } else {
+                CDEBUG(D_INFO, "not last close, not cancelling unused locks\n");
+        }
 
         EXIT;
 
@@ -346,7 +353,6 @@ out:
         return rc;
 }
 
-
 static inline void ll_remove_suid(struct inode *inode)
 {
         unsigned int mode;
index cf6e39b..c58dffe 100644 (file)
@@ -120,13 +120,10 @@ static struct super_block * ll_read_super(struct super_block *sb,
         struct ll_read_inode2_cookie lic;
         class_uuid_t uuid;
 
-        
         /* Lprocfs variables */
         char mnt_name[100];
         char uuid_name[100];
         struct lprocfs_vars d_vars[3];
-        
-
 
         ENTRY;
         MOD_INC_USE_COUNT;
@@ -238,68 +235,68 @@ static struct super_block * ll_read_super(struct super_block *sb,
         ptlrpc_req_finished(request);
         request = NULL;
 
-        
+
         /* Register this mount instance with LProcFS */
-        
+
         snprintf(mnt_name, 100, "mount_%s", sbi->ll_sb_uuid);
         sbi->ll_mnt_root=lprocfs_reg_mnt(mnt_name);
         if(!sbi->ll_mnt_root)
                 goto out_dev;
 
         /* Add the static configuration info */
-        lprocfs_add_vars(sbi->ll_mnt_root, 
+        lprocfs_add_vars(sbi->ll_mnt_root,
                          (struct lprocfs_vars*)status_var_nm_1,
                          (void*)sb);
 
          /* Add the dynamic configuration stuff */
-        
+
         /* MDC */
         obd = class_uuid2obd(mdc);
-        
+
         /* Reuse mnt_name */
-        
+
         sprintf(mnt_name, "status/%s/common_name", obd->obd_type->typ_name);
 
         memset(d_vars, 0, sizeof(d_vars));
         d_vars[0].read_fptr=rd_dev_name;
         d_vars[0].write_fptr=0;
         d_vars[0].name=(char*)mnt_name;
-         
-        
-        snprintf(uuid_name, strlen(uuid_name), "status/%s/uuid", 
+
+
+        snprintf(uuid_name, strlen(uuid_name), "status/%s/uuid",
                  obd->obd_type->typ_name);
         d_vars[1].read_fptr=rd_dev_uuid;
         d_vars[1].write_fptr=0;
         d_vars[1].name=(char*)uuid_name;
-        
-        err=lprocfs_add_vars(sbi->ll_mnt_root, (struct lprocfs_vars* )d_vars, 
+
+        err=lprocfs_add_vars(sbi->ll_mnt_root, (struct lprocfs_vars* )d_vars,
                              (void*)obd);
         if (err) {
                 CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables");
         }
 
-        
+
         /* OSC or LOV*/
         obd = class_uuid2obd(osc);
         /* Reuse mnt_name */
-      
-        snprintf(mnt_name, strlen(mnt_name), "status/%s/common_name", 
+
+        snprintf(mnt_name, strlen(mnt_name), "status/%s/common_name",
                  obd->obd_type->typ_name);
 
         memset(d_vars, 0, sizeof(d_vars));
         d_vars[0].read_fptr=rd_dev_name;
         d_vars[0].write_fptr=0;
         d_vars[0].name=(char*)mnt_name;
-         
-        
-        snprintf(uuid_name, strlen(uuid_name), "status/%s/uuid", 
+
+
+        snprintf(uuid_name, strlen(uuid_name), "status/%s/uuid",
                  obd->obd_type->typ_name);
         d_vars[1].read_fptr=rd_dev_uuid;
         d_vars[1].write_fptr=0;
         d_vars[1].name=(char*)uuid_name;
-        
-        err=lprocfs_add_vars(sbi->ll_mnt_root, (struct lprocfs_vars* )d_vars, 
-                             (void*)obd);        
+
+        err=lprocfs_add_vars(sbi->ll_mnt_root, (struct lprocfs_vars* )d_vars,
+                             (void*)obd);
         if (err) {
                 CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables");
         }
@@ -368,7 +365,7 @@ static void ll_clear_inode(struct inode *inode)
 
         rc = mdc_cancel_unused(&sbi->ll_mdc_conn, inode, LDLM_FL_NO_CALLBACK);
         if (rc < 0) {
-                CERROR("obd_cancel_unused: %d\n", rc);
+                CERROR("mdc_cancel_unused: %d\n", rc);
                 /* XXX FIXME do something dramatic */
         }
 
@@ -574,6 +571,7 @@ static void ll_read_inode2(struct inode *inode, void *opaque)
         ENTRY;
 
         sema_init(&lli->lli_open_sem, 1);
+        atomic_set(&lli->lli_open_count, 0);
 
         /* core attributes first */
         ll_update_inode(inode, body);
index 5e5f6c0..ad410d6 100644 (file)
@@ -166,7 +166,7 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
                         GOTO(out_disc, rc);
                 }
                 rc = obd_iocontrol(IOC_OSC_REGISTER_LOV, &lov->tgts[i].conn,
-                                   sizeof(struct obd_device *), obd, NULL); 
+                                   sizeof(struct obd_device *), obd, NULL);
                 if (rc) {
                         CERROR("Target %s REGISTER_LOV error %d\n",
                                uuidarray[i], rc);
@@ -1355,21 +1355,21 @@ static int lov_iocontrol(long cmd, struct lustre_handle *conn, int len,
         RETURN(rc);
 }
 
-int lov_attach(struct obd_device *dev, 
+int lov_attach(struct obd_device *dev,
                obd_count len, void *data)
 {
         int rc;
-        rc = lprocfs_reg_obd(dev, (struct lprocfs_vars*)status_var_nm_1, 
+        rc = lprocfs_reg_obd(dev, (struct lprocfs_vars*)status_var_nm_1,
                              (void*)dev);
-        return rc; 
+        return rc;
 }
 
 int lov_detach(struct obd_device *dev)
-{        
+{
         int rc;
         rc = lprocfs_dereg_obd(dev);
         return rc;
+
  }
 
 struct obd_ops lov_obd_ops = {
@@ -1399,7 +1399,7 @@ struct obd_ops lov_obd_ops = {
 static int __init lov_init(void)
 {
         int rc;
-        
+
         printk(KERN_INFO "Lustre Logical Object Volume driver " LOV_VERSION
                ", info@clusterfs.com\n");
         lov_file_cache = kmem_cache_create("ll_lov_file_data",
@@ -1411,20 +1411,17 @@ static int __init lov_init(void)
         rc = class_register_type(&lov_obd_ops,
                                  (struct lprocfs_vars*)status_class_var,
                                  OBD_LOV_DEVICENAME);
-        if (rc) RETURN(rc);
-        
-        return 0;
+        if (rc)
+                RETURN(rc);
 
-        
+        return 0;
 }
 
 static void __exit lov_exit(void)
 {
-                
         if (kmem_cache_destroy(lov_file_cache))
                 CERROR("couldn't free LOV open cache\n");
         class_unregister_type(OBD_LOV_DEVICENAME);
-     
 }
 
 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");