Whamcloud - gitweb
b=609205
authorpschwan <pschwan>
Mon, 16 Sep 2002 18:19:20 +0000 (18:19 +0000)
committerpschwan <pschwan>
Mon, 16 Sep 2002 18:19:20 +0000 (18:19 +0000)
Reenable the throwing away of data locks on file close.  This may or may not
be enough to fix 609205, depending on whether that bug is purely related to
running out of memory.

lustre/include/linux/obd.h
lustre/include/linux/obd_class.h
lustre/llite/file.c
lustre/lov/lov_obd.c
lustre/osc/osc_request.c

index 268b053..80726ae 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- * Copyright (C) 2001  Cluster File Systems, Inc.
+ * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
  *
  * This code is issued under the GNU General Public License.
  * See the file COPYING in this distribution
@@ -26,7 +26,7 @@ struct obd_type {
         int  typ_refcnt;
 };
 
-struct brw_page { 
+struct brw_page {
         struct page *pg;
         obd_size count;
         obd_off  off;
@@ -145,7 +145,7 @@ struct echo_obd {
 struct recovd_obd {
         __u32                 recovd_phase;
         __u32                 recovd_next_phase;
-        __u32                 recovd_flags; 
+        __u32                 recovd_flags;
         struct recovd_data   *recovd_current_rd;
         spinlock_t            recovd_lock;
         struct list_head      recovd_managed_items; /* items managed  */
@@ -174,9 +174,9 @@ struct ost_obd {
 };
 
 
-struct lov_tgt_desc { 
+struct lov_tgt_desc {
         uuid_t uuid;
-        struct lustre_handle conn; 
+        struct lustre_handle conn;
 };
 
 struct lov_obd {
@@ -272,7 +272,7 @@ struct obd_ops {
                        struct lov_stripe_md *);
         int (*o_brw)(int rw, struct lustre_handle *conn,
                      struct lov_stripe_md *md, obd_count oa_bufs,
-                     struct brw_page *pgarr, brw_callback_t callback, 
+                     struct brw_page *pgarr, brw_callback_t callback,
                      struct io_cb_data *data);
         int (*o_punch)(struct lustre_handle *conn, struct obdo *tgt,
                        struct lov_stripe_md *md, obd_size count,
@@ -296,11 +296,13 @@ struct obd_ops {
                           int niocount, struct niobuf_local *local,
                           void *desc_private);
         int (*o_enqueue)(struct lustre_handle *conn, struct lov_stripe_md *md,
-                         struct lustre_handle *parent_lock, 
+                         struct lustre_handle *parent_lock,
                          __u32 type, void *cookie, int cookielen, __u32 mode,
                          int *flags, void *cb, void *data, int datalen,
                          struct lustre_handle *lockh);
-        int (*o_cancel)(struct lustre_handle *, struct lov_stripe_md *md, __u32 mode, struct lustre_handle *);
+        int (*o_cancel)(struct lustre_handle *, struct lov_stripe_md *md,
+                        __u32 mode, struct lustre_handle *);
+        int (*o_cancel_unused)(struct lustre_handle *, struct lov_stripe_md *);
 };
 
 static inline void *mds_fs_start(struct mds_obd *mds, struct inode *inode,
index d1de775..1998b72 100644 (file)
@@ -406,6 +406,18 @@ static inline int obd_cancel(struct lustre_handle *conn,
         RETURN(rc);
 }
 
+static inline int obd_cancel_unused(struct lustre_handle *conn,
+                                    struct lov_stripe_md *lsm)
+{
+        int rc;
+        struct obd_export *export;
+        OBD_CHECK_SETUP(conn, export);
+        OBD_CHECK_OP(export->exp_obd, cancel_unused);
+
+        rc = OBP(export->exp_obd, cancel_unused)(conn, lsm);
+        RETURN(rc);
+}
+
 #endif
 
 /*
index a028862..a07434e 100644 (file)
@@ -286,7 +286,9 @@ static int ll_file_release(struct inode *inode, struct file *file)
         }
         ptlrpc_req_finished(fd->fd_req);
 
-        //ldlm_cli_cancel_unused();
+        rc = obd_cancel_unused(ll_i2obdconn(inode), lli->lli_smd);
+        if (rc)
+                CERROR("obd_cancel_unused: %d\n", rc);
 
         EXIT;
 
index de1e42c..36d5226 100644 (file)
@@ -806,6 +806,40 @@ static int lov_cancel(struct lustre_handle *conn, struct lov_stripe_md *lsm,
         RETURN(rc);
 }
 
+static int lov_cancel_unused(struct lustre_handle *conn,
+                             struct lov_stripe_md *lsm)
+{
+        struct obd_export *export = class_conn2export(conn);
+        struct lov_obd *lov;
+        struct lov_oinfo *loi;
+        int rc = 0, i;
+        ENTRY;
+
+        if (!lsm) {
+                CERROR("LOV requires striping ea for lock cancellation\n");
+                RETURN(-EINVAL);
+        }
+
+        if (!export || !export->exp_obd)
+                RETURN(-ENODEV);
+
+        lov = &export->exp_obd->u.lov;
+        for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
+                struct lov_stripe_md submd;
+
+                submd.lsm_object_id = loi->loi_id;
+                submd.lsm_mds_easize = lov_mds_md_size(lsm->lsm_ost_count);
+                submd.lsm_stripe_count = 0;
+                rc = obd_cancel_unused(&lov->tgts[loi->loi_ost_idx].conn,
+                                       &submd);
+                if (rc)
+                        CERROR("Error cancel unused objid "LPX64" subobj "LPX64
+                               " on OST idx %d: rc = %d\n", lsm->lsm_object_id,
+                               loi->loi_id, loi->loi_ost_idx, rc);
+        }
+        RETURN(rc);
+}
+
 static int lov_statfs(struct lustre_handle *conn, struct obd_statfs *osfs)
 {
         struct obd_export *export = class_conn2export(conn);
@@ -869,7 +903,8 @@ struct obd_ops lov_obd_ops = {
         o_brw:         lov_brw,
         o_punch:       lov_punch,
         o_enqueue:     lov_enqueue,
-        o_cancel:      lov_cancel
+        o_cancel:      lov_cancel,
+        o_cancel_unused: lov_cancel_unused
 };
 
 
index 2396323..2c6945d 100644 (file)
@@ -680,6 +680,15 @@ static int osc_cancel(struct lustre_handle *oconn, struct lov_stripe_md *md,
         RETURN(0);
 }
 
+static int osc_cancel_unused(struct lustre_handle *connh,
+                             struct lov_stripe_md *lsm)
+{
+        struct obd_device *obddev = class_conn2obd(connh);
+        __u64 res_id[RES_NAME_SIZE] = { lsm->lsm_object_id };
+
+        return ldlm_cli_cancel_unused(obddev->obd_namespace, res_id);
+}
+
 static int osc_statfs(struct lustre_handle *conn, struct obd_statfs *osfs)
 {
         struct ptlrpc_request *request;
@@ -794,6 +803,7 @@ struct obd_ops osc_obd_ops = {
         o_punch:        osc_punch,
         o_enqueue:      osc_enqueue,
         o_cancel:       osc_cancel,
+        o_cancel_unused: osc_cancel_unused,
         o_iocontrol:    osc_iocontrol
 };